Skip to content

Commit 9036777

Browse files
authored
Merge pull request #1248 from AntoineTheb/atheb/tutorial_reconst
ENH: reconst tutorial
2 parents c70bb19 + 379a99a commit 9036777

File tree

8 files changed

+144
-1
lines changed

8 files changed

+144
-1
lines changed

docs/source/_static/b0_mean.png

100 KB
Loading
4.44 MB
Loading

docs/source/_static/fa.png

121 KB
Loading
4.79 MB
Loading

docs/source/_static/rgb.png

196 KB
Loading
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
From raw diffusion to DTI, fODF, and tractogram
2+
======================================================
3+
4+
scilpy provides a set of scripts to go from raw diffusion data to a full tractogram. This includes preprocessing, DTI fitting, fODF computation, and tractography.
5+
6+
First, make sure you have the required data. You will need:
7+
8+
* A diffusion-weighted image (DWI) in NIfTI format (e.g., `dwi.nii.gz`)
9+
* Corresponding b-values and b-vectors files (e.g., `dwi.bval` and `dwi.bvec`)
10+
* A brain mask (e.g., `brainmask.nii.gz`)
11+
* A white matter mask (e.g., `wm_mask.nii.gz`)
12+
13+
Preprocessing
14+
-----------------
15+
16+
We will then extract the b0 images from the DWI using :ref:`scil_dwi_extract_b0` and compute their mean to use as a reference for registration and visualization.
17+
::
18+
19+
scil_dwi_extract_b0 dwi.nii.gz dwi.bval dwi.bvec b0_mean.nii.gz --mean
20+
21+
This should produce a file named `b0_mean.nii.gz` which is the average of all b0 images. It should look like this:
22+
23+
.. image:: ../../_static/b0_mean.png
24+
:scale: 20%
25+
26+
(See :ref:`Create overlapping slice mosaics<create_overlapping_slice_mosaics>` for instructions on how to create such a screenshot.)
27+
28+
Preprocessing of the DWI can include rejecting problematic volumes with :ref:`scil_dwi_detect_volume_outliers` or denoising with :ref:`scil_denoising_nlmeans`. The user may include other preprocessing steps of their choice, such as registration to the MNI template with ANTS or skull-stripping with FSL.
29+
30+
Reconstruction
31+
----------------
32+
33+
scilpy has scripts to compute various local reconstruction methods (:ref:`scil_dti_metrics`, :ref:`scil_dki_metrics`, :ref:`scil_qball_metrics`, :ref:`scil_freewater_maps`, :ref:`scil_NODDI_maps`), particularly many variations of fODFs (:ref:`scil_fodf_metrics`, :ref:`scil_fodf_msmt`, :ref:`scil_fodf_memsmt`, :ref:`scil_fodf_ssst`).
34+
35+
Let's start with diffusion tensor imaging (DTI).
36+
37+
DTI reconstruction
38+
----------------
39+
40+
We will extract the shell with a b-value around 1000 s/mm² for DTI fitting using :ref:`scil_dwi_extract_shell`. We will also include the b0 images.
41+
::
42+
43+
scil_dwi_extract_shell dwi.nii.gz dwi.bval dwi.bvec 0 1000 dwi_b1000.nii.gz \
44+
dwi_b1000.bval dwi_b1000.bvec
45+
46+
Now, we can reconstruct the DTI tensor volume using :ref:`scil_dti_metrics`. scilpy automatically computes the FA, MD, RGB, and eigenvectors maps in addition to the tensor volume. To ease computation, we will constrain the fitting to the brain mask.
47+
::
48+
49+
scil_dti_metrics dwi_b1000.nii.gz dwi_b1000.bval dwi_b1000.bvec --mask brainmask.nii.gz
50+
51+
This will produce a lot of files, including:
52+
53+
* `tensor.nii.gz`: The diffusion tensor volume
54+
* `fa.nii.gz`: Fractional Anisotropy map
55+
* `md.nii.gz`: Mean Diffusivity map
56+
* `rd.nii.gz`: Radial Diffusivity map
57+
* `rgb.nii.gz`: RGB map of the principal diffusion direction
58+
* `tensor_evecs.nii.gz`: Eigenvectors of the diffusion tensor
59+
* `tensor_evals.nii.gz`: Eigenvalues of the diffusion tensor
60+
61+
See :ref:`scil_dti_metrics` for a full list of outputs and more details.
62+
63+
Here is an example FA map:
64+
65+
.. image:: ../../_static/fa.png
66+
:scale: 20%
67+
68+
and an RGB map:
69+
70+
.. image:: ../../_static/rgb.png
71+
:scale: 20%
72+
73+
74+
DTI Tractography
75+
------------------
76+
77+
Finally, we can do some basic deterministic tractography using the principal eigenvector (`tensor_evecs_v1.nii.gz`) of the DTI. We will use :ref:`scil_tracking_local` with the [EUDX]_ algorithm. We will seed from the white matter mask and constrain tracking to stay within it. We will generate 20,000 seeds and only keep streamline with lengths between 20 and 200 mm. We will also apply a compression factor of 0.1 to reduce file size.
78+
::
79+
80+
scil_tracking_local tensor_evecs_v1.nii.gz wm_mask.nii.gz wm_mask.nii.gz \
81+
tractogram.trk --algo eudx --nt 20000 --min_length 20 --max_length 200 --compress 0.1
82+
83+
The output tractogram (`tractogram.trk`) can be visualized with :ref:`scil_viz_bundle` and should look something like this:
84+
85+
.. image:: ../../_static/eudx_tractogram.png
86+
:scale: 20%
87+
88+
89+
Next, let's move on to fiber orientation distribution functions (fODFs).
90+
91+
fODF reconstruction
92+
------------------
93+
94+
fODFs require the compuation of a response function [Descoteaux07]_. We will use the `ssst` algorithm from :ref:`scil_frf_ssst` to compute a **s**\ ingle-**s**\ hell **s**\ ingle-**t**\ issue response function from the b=1000 shell we extracted earlier. We will also use the brain mask and a white matter mask to constrain the selection of voxels used for the estimation.
95+
::
96+
97+
scil_frf_ssst dwi_b1000.nii.gz dwi_b1000.bval dwi_b1000.bvec frf.txt \
98+
--mask brainmask.nii.gz --mask_wm wm_mask.nii.gz
99+
100+
We can then compute the fODF using :ref:`scil_fodf_ssst`. We will use the same shell and brain mask as before, and the response function we just computed. We will use the default `descoteaux07_legacy` spherical harmonics basis, which is commonly used in scilpy. The `tournier07` basis is also available and is compatible with MrTrix3 tools. Finally, as we have fewer than 45 directions, we will use a lower spherical harmonics order of 6.
101+
::
102+
103+
scil_fodf_ssst dwi_b1000.nii.gz dwi_b1000.bval dwi_b1000.bvec frf.txt \
104+
fodf.nii.gz --mask brainmask.nii.gz --sh_order 6
105+
106+
As opposed to DTI fitting, the script :ref:`scil_fodf_ssst` only produces the fODF volume. We can compute various useful metrics from the fODF using :ref:`scil_fodf_metrics`. We will again use the brain mask to constrain computation. As the script also produces an rgb msp, we will use the `-f` flag and overwrite the previous `rgb.nii.gz` file.
107+
::
108+
109+
scil_fodf_metrics fodf.nii.gz --mask brainmask.nii.gz -f
110+
111+
This will produce several files, including:
112+
113+
* `nufo.nii.gz`: Number of fiber orientations per voxel
114+
* `afd_sum.nii.gz`: Sum of the apparent fiber density (AFD) across all fiber orientations
115+
* `peaks.nii.gz`: fODF maxima directions
116+
117+
For more information on fodf reconstruction, see :ref:`ssst_fodf` and :ref:`msmt_fodf`.
118+
119+
fODF Tractography
120+
------------------
121+
122+
Tractography on fODFs can be performed using either probabilistic (`--algo prob`) or deterministic (`--algo det`) algorithms in :ref:`scil_tracking_local`. We will use the same white matter mask for seeding and constraining tracking. We will generate 200,000 seeds and only keep streamlines with lengths between 20 and 200 mm, and apply a compression factor of 0.1 to reduce file size.
123+
::
124+
125+
scil_tracking_local fodf.nii.gz wm_mask.nii.gz wm_mask.nii.gz \
126+
prob_tractogram.trk --algo prob --nt 200000 --min_length 20 \
127+
--max_length 200 --compress 0.1
128+
129+
The output tractogram (`prob_tractogram.trk`) can be visualized with :ref:`scil_viz_bundle` and should look something like this:
130+
131+
.. image:: ../../_static/prob_tractogram.png
132+
:scale: 20%
133+
134+
You have now gone from raw diffusion data to both DTI and fODF-based tractograms using scilpy!
135+
136+
References:
137+
----------------------
138+
139+
.. [EUDX] Garyfallidis, E. (2013). Towards an accurate brain tractography (Doctoral dissertation, University of Cambridge).
140+
.. [Descoteaux07] Descoteaux, M., Angelino, E., Fitzgibbons, S., & Deriche, R. (2007). Regularized, fast, and robust analytical q-ball imaging. Magnetic Resonance in Medicine: An Official Journal of the International Society for Magnetic Resonance in Medicine, 58(3), 497-510.

docs/source/documentation/reconstruction/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ This section covers reconstruction methods in scilpy.
66
.. toctree::
77
:maxdepth: 1
88

9-
btensor_scripts
9+
btensor_scripts
10+
from_raw_data_to_tractogram

docs/source/documentation/visualization/create_overlapping_slice_mosaics.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _create_overlapping_slice_mosaics:
2+
13
Create overlapping slice mosaics
24
================================
35

0 commit comments

Comments
 (0)