Skip to content

Commit

Permalink
update dev docs
Browse files Browse the repository at this point in the history
  • Loading branch information
skoudoro committed Mar 7, 2024
1 parent 37cd033 commit 4c350d2
Show file tree
Hide file tree
Showing 709 changed files with 32,730 additions and 20,565 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,17 @@ def run(self, input_files, out_dir='', out_file='processed.nii.gz'):
#
# This is it for the combined workflow class! Now to be able to call it easily
# via command line, you need to add this workflow in 2 different files:
#
# - ``<dipy_root>/pyproject.toml``: open this file and add the following line
# to the ``[project.scripts]`` section:
# ``dipy_denoise_segment = "dipy.workflows.cli:run"``
#
# - ``<dipy_root>/dipy/workflows/cli.py``: open this file and add the workflow
# information to the ``cli_flows`` dictionary. The key is the name of the
# command line command and the value is a tuple with the module name and the
# workflow class name. In this case it would be:
# ``"dipy_denoise_segment": ("dipy.workflows.my_combined_workflow",
# "DenoiseAndSegment")``
# "DenoiseAndSegment")``
#
# That`s it! Now you can call your workflow from anywhere with the command line.
# Let's just call the script you just made with ``-h`` to see the argparser help
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Use ``self.get_io_iterator()`` in every workflow you create. This creates\nan ``IOIterator`` object that create output file names and directory\nstructure based on the inputs and some other advanced output strategy\nparameters.\n\nIterating on the ``IOIterator`` object you created previously you\nconveniently get all input and output paths for every input file\nfound when globbin the input parameters.\n\nIn the ``IOIterator`` loop you can see how we create a new ``NLMeans``\nworkflow then run it using ``self.run_sub_flow``. Running it this way will\npass any workflow specific parameter that was retrieved from the command line\nand will append the ones you specify as optional parameters (``out_dir``\nin this case).\n\nLastly, the outputs paths are retrieved using\n``workflow.last_generated_outputs``. This allows to use ``denoise`` as the\ninput for the ``MedianOtsuFlow``.\n\n\nThis is it for the combined workflow class! Now to be able to call it easily\nvia command line, you need to add this workflow in 2 different files:\n- ``<dipy_root>/pyproject.toml``: open this file and add the following line\n to the ``[project.scripts]`` section:\n ``dipy_denoise_segment = \"dipy.workflows.cli:run\"``\n- ``<dipy_root>/dipy/workflows/cli.py``: open this file and add the workflow\n information to the ``cli_flows`` dictionary. The key is the name of the\n command line command and the value is a tuple with the module name and the\n workflow class name. In this case it would be:\n ``\"dipy_denoise_segment\": (\"dipy.workflows.my_combined_workflow\",\n \"DenoiseAndSegment\")``\n\nThat`s it! Now you can call your workflow from anywhere with the command line.\nLet's just call the script you just made with ``-h`` to see the argparser help\ntext::\n\n dipy_denoise_segment --help\n\nYou should see all your parameters available along with some extra common\nones like logging file and force overwrite. Also all the documentation you\nwrote about each parameter is there.\n\n"
"Use ``self.get_io_iterator()`` in every workflow you create. This creates\nan ``IOIterator`` object that create output file names and directory\nstructure based on the inputs and some other advanced output strategy\nparameters.\n\nIterating on the ``IOIterator`` object you created previously you\nconveniently get all input and output paths for every input file\nfound when globbin the input parameters.\n\nIn the ``IOIterator`` loop you can see how we create a new ``NLMeans``\nworkflow then run it using ``self.run_sub_flow``. Running it this way will\npass any workflow specific parameter that was retrieved from the command line\nand will append the ones you specify as optional parameters (``out_dir``\nin this case).\n\nLastly, the outputs paths are retrieved using\n``workflow.last_generated_outputs``. This allows to use ``denoise`` as the\ninput for the ``MedianOtsuFlow``.\n\n\nThis is it for the combined workflow class! Now to be able to call it easily\nvia command line, you need to add this workflow in 2 different files:\n\n- ``<dipy_root>/pyproject.toml``: open this file and add the following line\n to the ``[project.scripts]`` section:\n ``dipy_denoise_segment = \"dipy.workflows.cli:run\"``\n\n- ``<dipy_root>/dipy/workflows/cli.py``: open this file and add the workflow\n information to the ``cli_flows`` dictionary. The key is the name of the\n command line command and the value is a tuple with the module name and the\n workflow class name. In this case it would be:\n ``\"dipy_denoise_segment\": (\"dipy.workflows.my_combined_workflow\",\n \"DenoiseAndSegment\")``\n\nThat`s it! Now you can call your workflow from anywhere with the command line.\nLet's just call the script you just made with ``-h`` to see the argparser help\ntext::\n\n dipy_denoise_segment --help\n\nYou should see all your parameters available along with some extra common\nones like logging file and force overwrite. Also all the documentation you\nwrote about each parameter is there.\n\n"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
plt.subplot(1, 2, 2).set_axis_off()
plt.imshow(histeq(b0_mask[:, :, sli].astype('float')).T,
cmap='gray', origin='lower')
plt.savefig(f'{fname}_median_otsu.png', bbox_inches='tight')

###############################################################################
# .. rst-class:: centered small fst-italic fw-semibold
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Applying image-based deformations to streamlines\n\nThis example shows how to register streamlines into a template space by\napplying non-rigid deformations.\n\nAt times we will be interested in bringing a set of streamlines into some\ncommon, reference space to compute statistics out of the registered\nstreamlines. For a discussion on the effects of spatial normalization\napproaches on tractography the work by Green et al. [Greene17]_ can be read.\n\nFor brevity, we will include in this example only streamlines going through\nthe corpus callosum connecting left to right superior frontal cortex. The\nprocess of tracking and finding these streamlines is fully demonstrated in\nthe `sphx_glr_examples_built_streamline_analysis_streamline_tools`\nexample.\n"
"\n# Applying image-based deformations to streamlines\n\nThis example shows how to register streamlines into a template space by\napplying non-rigid deformations.\n\nAt times we will be interested in bringing a set of streamlines into some\ncommon, reference space to compute statistics out of the registered\nstreamlines. For a discussion on the effects of spatial normalization\napproaches on tractography the work by Green et al. [Greene17]_ can be read.\n\nFor brevity, we will include in this example only streamlines going through\nthe corpus callosum connecting left to right superior frontal cortex. The\nprocess of tracking and finding these streamlines is fully demonstrated in\nthe `sphx_glr_examples_built_streamline_analysis_streamline_tools.py`\nexample.\n"
]
},
{
Expand Down Expand Up @@ -238,7 +238,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Finally, we save the two registered streamlines:\n- `mni-lr-sft_in_t2_using_aff_reg.trk` is the streamlines registered using\n the affine registration.\n- `sft_in_t2_using_syn` is the streamlines registered using the\n SyN registration and prealigned with the affine registration.\n\n"
"Finally, we save the two registered streamlines:\n\n- `mni-lr-sft_in_t2_using_aff_reg.trk` is the streamlines registered using\n the affine registration.\n- `sft_in_t2_using_syn` is the streamlines registered using the\n SyN registration and prealigned with the affine registration.\n\n"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,16 @@
# Replacing streamlines is possible, but if the state was modified between
# operations such as this one is not recommended:
# -> cc_sft.streamlines = cc_streamlines_vox

#
# It is recommended to re-create a new StatefulTractogram object and
# explicitly specify in which space the streamlines are. Be careful to follow
# the order of operations.

#
# If the tractogram was from a Trk file with metadata, this will be lost.
# If you wish to keep metadata while manipulating the number or the order
# look at the function StatefulTractogram.remove_invalid_streamlines() for more
# details

#
# It is important to mention that once the object is created in a consistent
# state the ``save_tractogram`` function will save a valid file. And then the
# function ``load_tractogram`` will load them in a valid state.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Reconstruction of the diffusion signal with the kurtosis tensor model\n\nThe diffusion kurtosis model is an expansion of the diffusion tensor model\n(see `sphx_glr_examples_built_reconstruction_reconst_dti.py`). In\naddition to the diffusion tensor (DT), the diffusion kurtosis model\nquantifies the degree to which water diffusion in biological tissues is\nnon-Gaussian using the kurtosis tensor (KT) [Jensen2005]_.\n\nMeasurements of non-Gaussian diffusion from the diffusion kurtosis model are of\ninterest because they can be used to characterize tissue microstructural\nheterogeneity [Jensen2010]_. Moreover, DKI can be used to: 1) derive concrete\nbiophysical parameters, such as the density of axonal fibers and diffusion\ntortuosity [Fierem2011]_ (see\n`sphx_glr_examples_built_reconstruction_reconst_dki_micro.py`); and 2)\nresolve crossing fibers in tractography and to obtain invariant rotational\nmeasures not limited to well-aligned fiber populations [NetoHe2015]_.\n\nThe diffusion kurtosis model expresses the diffusion-weighted signal as:\n\n\\begin{align}S(n,b)=S_{0}e^{-bD(n)+\\frac{1}{6}b^{2}D(n)^{2}K(n)}\\end{align}\n\nwhere $\\mathbf{b}$ is the applied diffusion weighting (which is dependent on\nthe measurement parameters), $S_0$ is the signal in the absence of diffusion\ngradient sensitization, $\\mathbf{D(n)}$ is the value of diffusion along\ndirection $\\mathbf{n}$, and $\\mathbf{K(n)}$ is the value of kurtosis along\ndirection $\\mathbf{n}$. The directional diffusion $\\mathbf{D(n)}$ and kurtosis\n$\\mathbf{K(n)}$ can be related to the diffusion tensor (DT) and kurtosis tensor\n(KT) using the following equations:\n\n\\begin{align}D(n)=\\sum_{i=1}^{3}\\sum_{j=1}^{3}n_{i}n_{j}D_{ij}\\end{align}\n\nand\n\n\\begin{align}K(n)=\\frac{MD^{2}}{D(n)^{2}}\\sum_{i=1}^{3}\\sum_{j=1}^{3}\\sum_{k=1}^{3}\n \\sum_{l=1}^{3}n_{i}n_{j}n_{k}n_{l}W_{ijkl}\\end{align}\n\nwhere $D_{ij}$ are the elements of the second-order DT, and $W_{ijkl}$ the\nelements of the fourth-order KT and $MD$ is the mean diffusivity. As the DT,\nKT has antipodal symmetry and thus only 15 Wijkl elements are needed to fully\ncharacterize the KT:\n\n\\begin{align}\\begin{matrix} ( & W_{xxxx} & W_{yyyy} & W_{zzzz} & W_{xxxy} & W_{xxxz}\n & ... \\\n & W_{xyyy} & W_{yyyz} & W_{xzzz} & W_{yzzz} & W_{xxyy}\n & ... \\\n & W_{xxzz} & W_{yyzz} & W_{xxyz} & W_{xyyz} & W_{xyzz}\n & & )\\end{matrix}\\end{align}\n\nIn the following example we show how to fit the diffusion kurtosis model on\ndiffusion-weighted multi-shell datasets and how to estimate diffusion kurtosis\nbased statistics.\n\nFirst, we import all relevant modules:\n"
"\n# Reconstruction of the diffusion signal with the kurtosis tensor model\n\nThe diffusion kurtosis model is an expansion of the diffusion tensor model\n(see `sphx_glr_examples_built_reconstruction_reconst_dti.py`). In\naddition to the diffusion tensor (DT), the diffusion kurtosis model\nquantifies the degree to which water diffusion in biological tissues is\nnon-Gaussian using the kurtosis tensor (KT) [Jensen2005]_.\n\nMeasurements of non-Gaussian diffusion from the diffusion kurtosis model are of\ninterest because they can be used to characterize tissue microstructural\nheterogeneity [Jensen2010]_. Moreover, DKI can be used to: 1) derive concrete\nbiophysical parameters, such as the density of axonal fibers and diffusion\ntortuosity [Fierem2011]_ (see\n`sphx_glr_examples_built_reconstruction_reconst_dki_micro.py`); and 2)\nresolve crossing fibers in tractography and to obtain invariant rotational\nmeasures not limited to well-aligned fiber populations [NetoHe2015]_.\n\nThe diffusion kurtosis model expresses the diffusion-weighted signal as:\n\n\\begin{align}S(n,b)=S_{0}e^{-bD(n)+\\frac{1}{6}b^{2}D(n)^{2}K(n)}\\end{align}\n\nwhere $\\mathbf{b}$ is the applied diffusion weighting (which is dependent on\nthe measurement parameters), $S_0$ is the signal in the absence of diffusion\ngradient sensitization, $\\mathbf{D(n)}$ is the value of diffusion along\ndirection $\\mathbf{n}$, and $\\mathbf{K(n)}$ is the value of kurtosis along\ndirection $\\mathbf{n}$. The directional diffusion $\\mathbf{D(n)}$ and kurtosis\n$\\mathbf{K(n)}$ can be related to the diffusion tensor (DT) and kurtosis tensor\n(KT) using the following equations:\n\n\\begin{align}D(n)=\\sum_{i=1}^{3}\\sum_{j=1}^{3}n_{i}n_{j}D_{ij}\\end{align}\n\nand\n\n\\begin{align}K(n)=\\frac{MD^{2}}{D(n)^{2}}\\sum_{i=1}^{3}\\sum_{j=1}^{3}\\sum_{k=1}^{3}\n \\sum_{l=1}^{3}n_{i}n_{j}n_{k}n_{l}W_{ijkl}\\end{align}\n\nwhere $D_{ij}$ are the elements of the second-order DT, and $W_{ijkl}$ the\nelements of the fourth-order KT and $MD$ is the mean diffusivity. As the DT,\nKT has antipodal symmetry and thus only 15 Wijkl elements are needed to fully\ncharacterize the KT:\n\n\\begin{align}\\begin{matrix} ( & W_{xxxx} & W_{yyyy} & W_{zzzz} & W_{xxxy} & W_{xxxz}\n & ... \\\\\n & W_{xyyy} & W_{yyyz} & W_{xzzz} & W_{yzzz} & W_{xxyy}\n & ... \\\\\n & W_{xxzz} & W_{yyzz} & W_{xxyz} & W_{xyyz} & W_{xyzz}\n & & )\\end{matrix}\\end{align}\n\nIn the following example we show how to fit the diffusion kurtosis model on\ndiffusion-weighted multi-shell datasets and how to estimate diffusion kurtosis\nbased statistics.\n\nFirst, we import all relevant modules:\n"
]
},
{
Expand Down
Binary file not shown.
Loading

0 comments on commit 4c350d2

Please sign in to comment.