Skip to content

Commit d19c255

Browse files
authored
Merge pull request scilus#1289 from karanphil/reconst_doc
Adding visualization commands and cleaning b-tensor files (to the docs)
2 parents 7016560 + e455381 commit d19c255

9 files changed

Lines changed: 136 additions & 23 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail # Will fail on error
3+
4+
# ==============
5+
# How to run this script
6+
# 1) Load the input data
7+
# https://scilpy.readthedocs.io/en/latest/documentation/getting_started.html
8+
# 2) Call this script with
9+
# ---> bash btensor_metrics.sh path/to/your/data path/to/save/outputs
10+
# ==============
11+
in_dir=$1
12+
out_dir=$2
13+
14+
in_dir=$in_dir/btensor
15+
16+
# For now, the tutorial data only contains the masks.
17+
# Other necessary data can be obtained with:
18+
scil_data_download -v ERROR
19+
cp $HOME/.scilpy/btensor_testdata/* $in_dir/
20+
21+
# ==============
22+
# Now let's run the tutorial
23+
# ==============
24+
cd $out_dir
25+
26+
echo "Compute metrics"
27+
echo "*****************"
28+
scil_btensor_metrics \
29+
--in_dwis $in_dir/dwi_linear.nii.gz $in_dir/dwi_planar.nii.gz $in_dir/dwi_spherical.nii.gz \
30+
--in_bvals $in_dir/linear.bvals $in_dir/planar.bvals $in_dir/spherical.bvals \
31+
--in_bvecs $in_dir/linear.bvecs $in_dir/planar.bvecs $in_dir/spherical.bvecs \
32+
--in_bdeltas 1 -0.5 0 --fa $in_dir/fa.nii.gz --processes 8 --mask $in_dir/mask.nii.gz
33+
echo "Resulting files: "
34+
ls ./

docs/source/_static/bash/reconst/btensor_scripts.sh renamed to docs/source/_static/bash/reconst/memsmt_fodf.sh

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set -euo pipefail # Will fail on error
66
# 1) Load the input data
77
# https://scilpy.readthedocs.io/en/latest/documentation/getting_started.html
88
# 2) Call this script with
9-
# ---> bash btensor_scripts.sh path/to/your/data path/to/save/outputs
9+
# ---> bash memsmt_fodf.sh path/to/your/data path/to/save/outputs
1010
# ==============
1111
in_dir=$1
1212
out_dir=$2
@@ -41,12 +41,10 @@ scil_fodf_memsmt wm_frf.txt gm_frf.txt csf_frf.txt \
4141
--in_bvecs $in_dir/linear.bvecs $in_dir/planar.bvecs $in_dir/spherical.bvecs \
4242
--in_bdeltas 1 -0.5 0 --processes 8 --mask $in_dir/mask.nii.gz
4343

44-
echo "Compute metrics"
45-
echo "*****************"
46-
scil_btensor_metrics \
47-
--in_dwis $in_dir/dwi_linear.nii.gz $in_dir/dwi_planar.nii.gz $in_dir/dwi_spherical.nii.gz \
48-
--in_bvals $in_dir/linear.bvals $in_dir/planar.bvals $in_dir/spherical.bvals \
49-
--in_bvecs $in_dir/linear.bvecs $in_dir/planar.bvecs $in_dir/spherical.bvecs \
50-
--in_bdeltas 1 -0.5 0 --fa $in_dir/fa.nii.gz --processes 8 --mask $in_dir/mask.nii.gz
44+
echo "3 - Visualizing the fODF"
45+
echo "************************"
46+
# Here, the --silent flag is used to avoid opening a visualization window.
47+
# It should be remove if you want to see the interactive visualization.
48+
scil_viz_fodf wm_fodf.nii.gz --silent --output fodf_memsmt.png
5149
echo "Resulting files: "
5250
ls ./

docs/source/_static/bash/reconst/msmt_fodf.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,9 @@ echo "Creating the fODF"
5050
echo "*****************"
5151
scil_fodf_msmt $in_dir/dwi.nii.gz $in_dir/dwi.bval $in_dir/dwi.bvec \
5252
wm_frf.txt gm_frf.txt csf_frf.txt --mask $in_dir/mask.nii.gz -v
53+
54+
echo "Visualizing the fODF"
55+
echo "********************"
56+
# Here, the --silent flag is used to avoid opening a visualization window.
57+
# It should be remove if you want to see the interactive visualization.
58+
scil_viz_fodf wm_fodf.nii.gz --silent --output fodf_msmt.png

docs/source/_static/bash/reconst/ssst_fodf.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ scil_frf_ssst $in_dir/dwi.nii.gz $in_dir/dwi.bval $in_dir/dwi.bvec frf.txt \
3434
--mask $in_dir/mask.nii.gz --mask_wm $in_dir/wm_mask.nii.gz -v
3535

3636
echo "2 - Preparing the fODF"
37-
echo "*********************"
37+
echo "**********************"
3838
scil_fodf_ssst $in_dir/dwi.nii.gz $in_dir/dwi.bval $in_dir/dwi.bvec frf.txt fodf.nii.gz \
3939
--mask $in_dir/mask.nii.gz
40+
41+
echo "3 - Visualizing the fODF"
42+
echo "************************"
43+
# Here, the --silent flag is used to avoid opening a visualization window.
44+
# It should be remove if you want to see the interactive visualization.
45+
scil_viz_fodf fodf.nii.gz --silent --output fodf_ssst.png
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Tensor-valued dMRI metrics reconstruction using DIVIDE
2+
======================================================
3+
4+
This tutorial explains how to compute b-tensor metrics like uFA (microscopic fractional anisotropy) using the DIVIDE method [divide]_. Your data should contain more than one type of b-tensor encoding (ex: linear, planar, spherical). The following instructions are specific to b-tensor data and based on [divide]_.
5+
6+
Preparing data for this tutorial
7+
********************************
8+
9+
To run lines below, you need a various volumes, b-vector information and masks. The tutorial data is still in preparation, meanwhile you can use this: `
10+
11+
.. code-block:: bash
12+
13+
in_dir=where/you/downloaded/tutorial/data
14+
in_dir=$in_dir/btensor
15+
16+
# For now, the tutorial data only contains the masks.
17+
# Other necessary data can be obtained with:
18+
scil_data_download -v ERROR
19+
cp $HOME/.scilpy/btensor_testdata/* $in_dir/
20+
21+
.. tip::
22+
You may download the complete bash script to run the whole tutorial in one step `⭳ here <../../_static/bash/reconst/btensor_scripts.sh>`_.
23+
24+
Computing b-tensor metrics
25+
**************************
26+
27+
To run DIVIDE on your b-tensor data, you should use the following command. It will save files for the MD, uFA, OP, MK_I, MK_A and MK_T. This script should run in about 1-2 hours for a full brain.
28+
29+
.. code-block:: bash
30+
31+
scil_btensor_metrics \
32+
--in_dwis $in_dir/dwi_linear.nii.gz $in_dir/dwi_planar.nii.gz $in_dir/dwi_spherical.nii.gz \
33+
--in_bvals $in_dir/linear.bvals $in_dir/planar.bvals $in_dir/spherical.bvals \
34+
--in_bvecs $in_dir/linear.bvecs $in_dir/planar.bvecs $in_dir/spherical.bvecs \
35+
--in_bdeltas 1 -0.5 0 --fa $in_dir/fa.nii.gz --processes 8 --mask $in_dir/mask.nii.gz
36+
37+
References
38+
**********
39+
40+
.. [divide] F. Szczepankiewicz et al., Tensor-valued diffusion encoding for diffusional variance decomposition (DIVIDE): Technical feasibility in clinical MRI systems. PloS one (2019)

docs/source/documentation/reconstruction/index.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ This section covers local reconstruction methods in scilpy. They mainly use func
88

99
ssst_fodf
1010
msmt_fodf
11-
btensor_scripts
11+
memsmt_fodf
1212
aodf_scripts
1313
qball_metrics
14-
mti_scripts
14+
mti_scripts
15+
btensor_metrics

docs/source/documentation/reconstruction/btensor_scripts.rst renamed to docs/source/documentation/reconstruction/memsmt_fodf.rst

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Tensor-valued dMRI scripts (b-tensor)
2-
=====================================
1+
Multi-encoding multi-shell multi-tissue fODF (memsmt-fODF)
2+
==========================================================
33

4-
The scripts for multi-encoding multi-shell multi-tissue CSD (memsmt-CSD) are based on [memst]_. We recommend reading it to understand the scope of the memsmt-CSD problem.
4+
This tutorial explains how to compute multi-encoding multi-shell multi-tissue fiber orientation distribution functions (fODFs) using multi-encoding multi-shell multi-tissue constrained spherical deconvolution (memsmt-CSD) [memstCSD]_. You data should contain more than one type of b-tensor encoding (ex: linear, planar, spherical). The following instructions are specific to multi-encdoding and based on [memstCSD]_.
55

66
Preparing data for this tutorial
77
********************************
@@ -54,17 +54,20 @@ Then, you should compute the fODFs and volume fractions. The following command w
5454
5555
The resulting files are: csf_fodf.nii.gz gm_fodf.nii.gz wm_fodf.nii.gz., as well as the volume fraction map: vf.nii.gz and vf_rgb.nii.gz.
5656

57-
If you want to do DIVIDE with b-tensor data, you should use the following command. It will save files for the MD, uFA, OP, MK_I, MK_A and MK_T. This script should run in about 1-2 hours for a full brain.
57+
58+
3. Visualizing the fODF
59+
***********************
60+
61+
The resulting fODFs can be visualized using the following command:
5862

5963
.. code-block:: bash
6064
61-
scil_btensor_metrics \
62-
--in_dwis $in_dir/dwi_linear.nii.gz $in_dir/dwi_planar.nii.gz $in_dir/dwi_spherical.nii.gz \
63-
--in_bvals $in_dir/linear.bvals $in_dir/planar.bvals $in_dir/spherical.bvals \
64-
--in_bvecs $in_dir/linear.bvecs $in_dir/planar.bvecs $in_dir/spherical.bvecs \
65-
--in_bdeltas 1 -0.5 0 --fa $in_dir/fa.nii.gz --processes 8 --mask $in_dir/mask.nii.gz
65+
scil_viz_fodf wm_fodf.nii.gz
66+
67+
See :ref:`scil_viz_fodf` for more information about the visualization options.
68+
6669

6770
References
6871
**********
6972

70-
.. [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)
73+
.. [memstCSD] P. Karan et al., Bridging the gap between constrained spherical deconvolution and diffusional variance decomposition via tensor-valued diffusion MRI. Medical Image Analysis (2022)

docs/source/documentation/reconstruction/msmt_fodf.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Multi-shell multi-tissue fODF (msmt-fODF)
44
=========================================
55

6-
This tutorial explains how to compute multi-shell multi-tissue fiber orientation distribution functions (fODFs) using multi-shell multi-tissue constrained spherical deconvolution (msmt-CSD) [multitissueCSD]_. If your data contains less than three b-values, you might want to consider using single-shell single-tissue CSD (ssst-CSD) instead. See the :ref:`ssst_fodf` instructions for that. The following instructions are specific to multi-shell and based on [multi-tissue_CSD]_.
6+
This tutorial explains how to compute multi-shell multi-tissue fiber orientation distribution functions (fODFs) using multi-shell multi-tissue constrained spherical deconvolution (msmt-CSD) [multitissueCSD]_. If your data contains less than three b-values, you might want to consider using single-shell single-tissue CSD (ssst-CSD) instead. See the :ref:`ssst_fodf` instructions for that. The following instructions are specific to multi-shell and based on [multitissueCSD]_.
77

88

99
Preparing data for this tutorial
@@ -61,6 +61,19 @@ The second step is to perform multi-shell multi-tissue CSD (msmt-CSD) using :ref
6161
6262
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`.
6363

64+
65+
3. Visualizing the fODF
66+
***********************
67+
68+
The resulting fODFs can be visualized using the following command:
69+
70+
.. code-block:: bash
71+
72+
scil_viz_fodf wm_fodf.nii.gz
73+
74+
See :ref:`scil_viz_fodf` for more information about the visualization options.
75+
76+
6477
References
6578
**********
6679

docs/source/documentation/reconstruction/ssst_fodf.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,16 @@ The second step is to perform single-shell single-tissue CSD (ssst-CSD) using :r
5151
scil_fodf_ssst $in_dir/dwi.nii.gz $in_dir/dwi.bval $in_dir/dwi.bvec frf.txt fodf.nii.gz \
5252
--mask $in_dir/mask.nii.gz
5353
54-
The script will output the fODFs in a nifti file (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. To visualize the fODFs, you can use :ref:`scil_viz_fodf`.
54+
The script will output the fODFs in a nifti file (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.
55+
56+
57+
3. Visualizing the fODF
58+
***********************
59+
60+
The resulting fODFs can be visualized using the following command:
61+
62+
.. code-block:: bash
63+
64+
scil_viz_fodf fodf.nii.gz
65+
66+
See :ref:`scil_viz_fodf` for more information about the visualization options.

0 commit comments

Comments
 (0)