Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/source/_static/my_style.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,14 @@
/* Make citations use full page width instead of narrow blocks */
div.citation {
display: flex !important;
}

/* Default font size is 0.9rem. A bit small. Making it bigger. */
div.citation a, p {
font-size: 1rem !important;
}

/* Making links from :ref: gray. With blue, it was becoming heavy */
.internal {
color: #878787;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Creating a bundle template from a chosen population

Scilpy scripts enable users to create a WM bundle population template, such as described in figure 3 in our upcoming paper. Such a pipeline includes:

1) segmenting the bundle of interest in each subject’s tractogram. The segmentation of bundles can be based on ROIs of inclusion / exclusion (`scil_tractogram_segment_with_ROI_and_score` or `scil_tractogram_filter_by_roi`) or based on the general shape of the streamlines (`scil_tractogram_segment_with_recobundles`, `scil_tractogram_segment_with_bundleseg`). See :ref:`page_tractogram_segmentation` for more information on this.
1) segmenting the bundle of interest in each subject’s tractogram. The segmentation of bundles can be based on ROIs of inclusion / exclusion (:ref:`scil_tractogram_segment_with_ROI_and_score` or :ref:`scil_tractogram_filter_by_roi`) or based on the general shape of the streamlines (:ref:`scil_tractogram_segment_with_recobundles`, :ref:`scil_tractogram_segment_with_bundleseg`). See :ref:`page_tractogram_segmentation` for more information on this.

2) registering the bundles to a reference space (e.g., MNI space) and analysing the inter-subject variability,

Expand All @@ -23,7 +23,7 @@ Then, registration can be performed (see :ref:`page_tractogram_registration`). T
Preparing data for this tutorial
********************************

To download data for this tutorial, see page :ref:`page_getting_started`_. Then do:
To download data for this tutorial, see page :ref:`page_getting_started`. Then do:

.. code-block:: bash
Expand All @@ -34,10 +34,10 @@ To download data for this tutorial, see page :ref:`page_getting_started`_. Then
--data_type int16 -f $in_dir/sub-01/sub-01__wmparc.nii.gz
The labels come from a Freesurfer segmentation (https://surfer.nmr.mgh.harvard.edu/ ), and the labels that it contains are found here: https://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/AnatomicalROI/FreeSurferColorLUT .
The labels come from a `Freesurfer <https://surfer.nmr.mgh.harvard.edu/>`_ segmentation, and the labels that it contains are found `in the FsWiki's Color Look-up Table (LUT) <https://surfer.nmr.mgh.harvard.edu/fswiki/FsTutorial/AnatomicalROI/FreeSurferColorLUT>`_ .

.. tip::
You may download the complete bash script to run the whole tutorial in one step `here </_static/bash/bundle_analysis/create_population_template.sh>`_.
You may download the complete bash script to run the whole tutorial in one step `here <../../_static/bash/bundle_analysis/create_population_template.sh>`_.


Step A. Prepare the bundle of interest in each subject
Expand Down
10 changes: 6 additions & 4 deletions docs/source/documentation/bundle_analysis/profilometry.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
Profilometry (statistics on bundles)
====================================

Defining profilometry
*********************

Using a clean bundle from a single subject, scilpy allows performing a profilometry [1]_ analysis, which is the analysis of the evolution of any dMRI metrics along its subsections. A simple example is shown in Figure 4, and for further examples of such processes, users can refer to Tractometry-flow (https://github.com/scilus/tractometry_flow), a nextflow process using many scilpy scripts, or to the study by Cousineau et. al [2]_.

The creation of the bundles required tractogram segmentation (:ref:`page_tractogram_segmentation`).
The creation of the bundles requires tractogram segmentation (:ref:`page_tractogram_segmentation`).

The profilometry analysis requires segmenting the bundles into as many subsections as desired. This is not straightforward, as the division of sections can be performed arbitrarily. We generally cut the section perpendicularly to the direction of the bundle, measured from a centroid, a single streamline-like shape representing the average of all streamlines in the bundle (`scil_bundle_compute_centroid`, `scil_bundle_label_map`). Then, any metric can be associated with the subsections. Figure 4 shows the example of the sections’ volume and diameter, or mean underlying value of any given map, such as the FA map. The resulting json file’s values can be plotted with scil_plot_stats_per_point.

Beyond profilometry, other analysis steps could also be performed on the whole bundle. For instance, it is possible to compute the map of the head and tail of a bundle (the starting and ending regions of the bundle, assuming all streamlines are aligned in the same direction) with scil_bundle_uniformize_endpoints and scil_bundle_compute_endpoints_map. It is also possible to extract various information with `scil_bundle_shape_measures`.

Example: reproducing figure 4 in scilpy paper
---------------------------------------------

.. image:: /_static/images/scilpy_paper_figure4.png
:alt: Figure 4 in upcoming paper.

References
**********

.. [1] Yeatman JD, Dougherty RF, Myall NJ, Wandell BA, Feldman HM. Tract Profiles of White Matter Properties: Automating Fiber-Tract Quantification. PLOS ONE. 2012;7(11):e49790. doi:10.1371/journal.pone.0049790
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,3 @@ Tractogram Segmentation into bundles
Scilpy scripts offer many options to segment a tractogram into bundles.

The resulting bundles can be cleaned more thoroughly than whole-brain tractograms, considering that their shapes should be quite uniform, and spurious streamlines can be discarded automatically with scil_bundle_reject_outliers or visually with `scil_bundle_clean_qbx_clusters`. The bundle could also be cut or trimmed using a binary mask, allowing it to focus on a specific region, using scil_tractogram_cut_streamlines. Optionally, metrics and statistics can be measured for each individual subject using our various scripts for bundle analysis, such as presented in :ref:`profilometry`.

Examples of usage
-----------------

- Creating a template. See :ref:`page_population_template`.
10 changes: 5 additions & 5 deletions docs/source/documentation/reconstruction/aodf_scripts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ Suggestion. For a faster processing of this tutorial data, you could crop the fo
}
.. tip::
You may download the complete bash script to run the whole tutorial in one step `here </_static/bash/reconst/aodf_scripts.sh>`_.
You may download the complete bash script to run the whole tutorial in one step `here <../../_static/bash/reconst/aodf_scripts.sh>`_.

Creating the aodf
*****************
1. Creating the aodf
********************

Although there is an automatic way to set the parameters, it is not yet implemented in scilpy. We recommend that you experiment with the parameters to find the best configuration for your data. Here, we use the smallest sphere available in Dipy, for a fast test. You can run the command as follows:

Expand All @@ -52,8 +52,8 @@ The default script runs a pure python implementation, which is slow. To speed up
The script will output the asymmetric ODF image (``afodf.nii.gz``) in the current directory. At the difference of a symmetric ODF image, which is represented using a symmetric spherical harmonics basis, the asymmetric ODF image is represented using a full spherical harmonics basis. Therefore, the output image will have more SH coefficients than the input image. For instance, for a maximum SH order of 8, the input image will have 45 coefficients per voxel, while the output image will have 81 coefficients per voxel.

Computing metrics
*****************
2. Computing metrics
********************

From the estimated AODF, we can compute a bunch of metrics using the script :ref:`scil_aodf_metrics`:.

Expand Down
5 changes: 4 additions & 1 deletion docs/source/documentation/reconstruction/btensor_scripts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ To run lines below, you need a various volumes, b-vector information and masks.
cp $HOME/.scilpy/btensor_testdata/* $in_dir/

.. tip::
You may download the complete bash script to run the whole tutorial in one step `here </_static/bash/reconst/btensor_scripts.sh>`_.
You may download the complete bash script to run the whole tutorial in one step `here <../../_static/bash/reconst/btensor_scripts.sh>`_.

1. Computing the frf
********************
Expand Down Expand Up @@ -64,4 +64,7 @@ If you want to do DIVIDE with b-tensor data, you should use the following comman
--in_bvecs $in_dir/linear.bvecs $in_dir/planar.bvecs $in_dir/spherical.bvecs \
--in_bdeltas 1 -0.5 0 --fa $in_dir/fa.nii.gz --processes 8 --mask $in_dir/mask.nii.gz
References
**********

.. [memst] P. Karan et al., Bridging the gap between constrained spherical deconvolution and diffusional variance decomposition via tensor-valued diffusion MRI. Medical Image Analysis (2022)
16 changes: 11 additions & 5 deletions docs/source/documentation/reconstruction/msmt_fodf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ To run lines below, you need a various volumes, b-vector information and masks.
cp $HOME/.scilpy/commit_amico/* $in_dir/

.. tip::
You may download the complete bash script to run the whole tutorial in one step `here </_static/bash/reconst/msmt_scripts.sh>`_.
You may download the complete bash script to run the whole tutorial in one step `here <../../_static/bash/reconst/msmt_fodf.sh>`_.

1. Computing the frf
********************
Expand All @@ -40,7 +40,13 @@ When available, it is possible to add following options (not available with curr
--mask_wm $in_dir/wm_mask.nii.gz --mask_gm $in_dir/gm_mask.nii.gz --mask_csf $in_dir/csf_mask.nii.gz
The script will output one FRF per tissue type: white matter (WM), gray matter (GM), cerebrospinal fluid (CSF), in three text files (wm_frf.txt, gm_frf.txt and csf_frf.txt) that will be used in the next step. Each line in those files correspond to the response function of a b-value (in decreasing order from top to bottom). The first three numbers in each line are the parallel diffusivity and the perpendicular diffusivity (written twice) of the corresponding tissue type and b-value. These should typically be around 1.2-2.0 x 10^-3 mm^2/s and 0.25-0.5 x 10^-3 mm^2/s for WM, 0.6-1.0 x 10^-3 mm^2/s and 0.5-0.8 x 10^-3 mm^2/s for GM, and 1.5-3.0 x 10^-3 mm^2/s and 1.5-3.0 x 10^-3 mm^2/s for CSF, respectively. The last number is the average value of the b0 signal of the corresponding tissue type. If the FRFs look very different from these values or if you get an error from the script, you might be able to resolve the issue by changing some parameters and making sure the inputed tissue masks are correct. Indeed, the script works better with a mask for each tissue type (WM, GM and CSF) in addition to the brain mask. Moreover, you can change the FA and MD thresholds of used to refine the tissue masks, using the ``--fa_thr_wm``, ``--fa_thr_gm``, ``--fa_thr_csf``, ``--md_thr_wm``, ``--md_thr_gm`` and ``--md_thr_csf`` options. You can also change the minimum number of voxels required to compute each FRF using the ``--min_nvox`` option (default is 100). This is particularly helpful in the case of small images. In such cases, the ``--roi_radii`` and ``--roi_center`` options can also be used to specify regions of interest (ROIs) in each tissue type. In any case, the ``-v`` (verbose) option can be used to get more information about the process. Once you have computed the FRFs, you can proceed to compute the fODFs.
The script will output one FRF per tissue type: white matter (WM), gray matter (GM), cerebrospinal fluid (CSF), in three text files (wm_frf.txt, gm_frf.txt and csf_frf.txt) that will be used in the next step. Each line in those files correspond to the response function of a b-value (in decreasing order from top to bottom). The first three numbers in each line are the parallel diffusivity and the perpendicular diffusivity (written twice) of the corresponding tissue type and b-value. These should typically be respectively around

- :math:`1.2 \text{ to } 2.0 \times 10^{-3}\ \text{mm}^2/\text{s}`, and :math:`0.25 \text{ to } 0.5 \times 10^{-3}\ \text{mm}^2/\text{s}` for WM
- :math:`0.6 \text{ to } 1.0 \times 10^{-3}\ \text{mm}^2/\text{s}`, and :math:`0.5 \text{ to } 0.8 \times 10^{-3}\ \text{mm}^2/\text{s}` for GM
- :math:`1.5 \text{ to } 3.0 \times 10^{-3}\ \text{mm}^2/\text{s}`, and :math:`1.5 \text{ to } 3.0 \times 10^{-3}\ \text{mm}^2/\text{s}` for CSF

The last number is the average value of the b0 signal of the corresponding tissue type. If the FRFs look very different from these values or if you get an error from the script, you might be able to resolve the issue by changing some parameters and making sure the inputed tissue masks are correct. Indeed, the script works better with a mask for each tissue type (WM, GM and CSF) in addition to the brain mask. Moreover, you can change the FA and MD thresholds of used to refine the tissue masks, using the ``--fa_thr_wm``, ``--fa_thr_gm``, ``--fa_thr_csf``, ``--md_thr_wm``, ``--md_thr_gm`` and ``--md_thr_csf`` options. You can also change the minimum number of voxels required to compute each FRF using the ``--min_nvox`` option (default is 100). This is particularly helpful in the case of small images. In such cases, the ``--roi_radii`` and ``--roi_center`` options can also be used to specify regions of interest (ROIs) in each tissue type. In any case, the ``-v`` (verbose) option can be used to get more information about the process. Once you have computed the FRFs, you can proceed to compute the fODFs.


2. Computing the fODF
Expand All @@ -55,7 +61,7 @@ The second step is to perform multi-shell multi-tissue CSD (msmt-CSD) using :ref
The script will output one fODFs file per tissue type, in nifti format (wm_fodf.nii.gz, gm_fodf.nii.gz and csf_fodf.nii.gz). The only optional arguments are the ``--sh_order`` option (default is 8) to set the maximum spherical harmonics order used to represent the fODFs and the ``--sh_basis`` option (default is 'descoteaux07') to set the spherical harmonics basis. The ``--processes`` option is used to speed up the computation by using multiple CPU cores. By default, the script will also output the volume fractions map (in default and RGB versions), with names vf.nii.gz and vf_rgb.nii.gz. To change any of the output names and paths or output only a selection of files, use the ``--not_all`` option along with the ``--wm_out_fODF``, ``--gm_out_fODF``, ``--csf_out_fODF``, ``--vf`` and ``--vf_rgb`` arguments. To visualize the fODFs, you can use :ref:`scil_viz_fodf`.

.. [multitissueCSD] Jeurissen et al. NeuroImage 2014, "Multi-tissue constrained spherical deconvolution for improved analysis of multi-shell diffusion MRI data".
References
**********

`The complete b-tensor scripts tutorial bash script <msmt_fodf.sh>`_.
.. [multitissueCSD] Jeurissen et al. NeuroImage 2014, "Multi-tissue constrained spherical deconvolution for improved analysis of multi-shell diffusion MRI data".
4 changes: 2 additions & 2 deletions docs/source/documentation/reconstruction/mti_scripts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Overall, we have data for a subject, containing:


.. tip::
You may download the complete bash script to run the whole tutorial in one step `here </_static/bash/reconst/mti_scripts.sh>`_.
You may download the complete bash script to run the whole tutorial in one step `here <../../_static/bash/reconst/mti_scripts.sh>`_.

Step-by-step processing
***********************
Expand Down Expand Up @@ -267,7 +267,7 @@ This workflow handles conversion, registration, and execution of the ``scil_mti_


References
----------
**********

[1] Varma G, Girard OM, Prevost VH, Grant AK, Duhamel G, Alsop DC.
Interpretation of magnetization transfer from inhomogeneously broadened
Expand Down
2 changes: 1 addition & 1 deletion docs/source/documentation/reconstruction/qball_metrics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ To run the script, you need a DWI image with its corresponding b-values and b-ve
.. tip::
You may download the complete bash script to run the whole tutorial in one step `here </_static/bash/reconst/qball_metrics.sh>`_.
You may download the complete bash script to run the whole tutorial in one step `here <../../_static/bash/reconst/qball_metrics.sh>`_.


Running Q-ball
Expand Down
2 changes: 1 addition & 1 deletion docs/source/documentation/reconstruction/ssst_fodf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The tutorial data is still in preparation, meanwhile you can use this:
cp $HOME/.scilpy/processing/fa_thr.nii.gz $in_dir/wm_mask.nii.gz
.. tip::
You may download the complete bash script to run the whole tutorial in one step `here </_static/bash/reconst/ssst_fodf.sh>`_.
You may download the complete bash script to run the whole tutorial in one step `here <../../_static/bash/reconst/ssst_fodf.sh>`_.


1. Computing the frf
Expand Down
2 changes: 0 additions & 2 deletions docs/source/documentation/tracking/fibertube_tracking.rst
Original file line number Diff line number Diff line change
Expand Up @@ -362,5 +362,3 @@ This reconstruction is not very good, but it is to be expected with
a --blur_radius and --step_size of 0.1. If you have a few minutes,
try again with 0.01!

End of Demo
-----------
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ This section covers tractogram manipulation methods in scilpy. Most of the funct
tractogram_registration
tractogram_math
streamlines_math
tractogram_filtering
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _page_streamlines_math:

Streamlines manipulation (resampling, smoothing)
================================================
Streamlines manipulation
========================

Here, we discuss scripts allowing modifying the streamlines themselves, for instance by resampling the number of points on each streamline (:ref:`scil_tractogram_resample_nb_points`, :ref:`scil_tractogram_compress`), or smoothing the streamlines’ trajectories (:ref:`scil_tractogram_smooth`).

Expand Down Expand Up @@ -32,7 +32,7 @@ To look at your data in a viewer, you may use the subject's T1 volume:
t1=$in_folder/sub-01/sub-01__t1.nii.gz
.. tip::
You may download the complete bash script to run the whole tutorial in one step `here </_static/bash/tractogram_manipulation/streamlines_math.sh>`_.
You may download the complete bash script to run the whole tutorial in one step `here <../../_static/bash/tractogram_manipulation/streamlines_math.sh>`_.

Resampling the number of points in each streamline
**************************************************
Expand Down

This file was deleted.

Loading