|
a |
|
b/docs/source/usage.rst |
|
|
1 |
.. _usage_cli: |
|
|
2 |
|
|
|
3 |
Application |
|
|
4 |
================================================================================ |
|
|
5 |
This page discusses general usage tips for both the command line and graphical user interface (GUI). |
|
|
6 |
Because the GUI is a wrapper around the command line and is typically easier to use, we will focus on detailing how to |
|
|
7 |
use DOSMA from the command line. |
|
|
8 |
|
|
|
9 |
The details here assume that :ref:`installation <installation>` and :ref:`verification <install-verification>` |
|
|
10 |
worked as expected. |
|
|
11 |
|
|
|
12 |
.. _usage-session: |
|
|
13 |
|
|
|
14 |
Starting A Session |
|
|
15 |
-------------------------------------------------------------------------------- |
|
|
16 |
To being a session using DOSMA from the command-line or GUI, follow the step below: |
|
|
17 |
|
|
|
18 |
1. Open new Terminal window. |
|
|
19 |
2. Activate DOSMA Anaconda environment:: |
|
|
20 |
|
|
|
21 |
$ conda activate dosma_env |
|
|
22 |
|
|
|
23 |
3. Run DOSMA:: |
|
|
24 |
|
|
|
25 |
# Run DOSMA from command line. |
|
|
26 |
$ python -m dosma.cli <ARGS...> |
|
|
27 |
|
|
|
28 |
# Or run DOSMA as a user interface (UI). |
|
|
29 |
$ python -m dosma.app |
|
|
30 |
|
|
|
31 |
.. note:: |
|
|
32 |
|
|
|
33 |
If you are using a remote connection, enable X11 port-forwarding to execute Step 4. If it is not enabled, the GUI |
|
|
34 |
cannot be used for remote connections. |
|
|
35 |
|
|
|
36 |
|
|
|
37 |
.. _usage-cli: |
|
|
38 |
|
|
|
39 |
Command-Line (Terminal) |
|
|
40 |
-------------------------------------------------------------------------------- |
|
|
41 |
DOSMA was designed to be a script-friendly library, where wrapper scripts can be used to |
|
|
42 |
execute and parallelize DOSMA computations. As scripting is often done using command-line enabled scripts (bash, shell, |
|
|
43 |
perl, etc.), DOSMA has a command-line interface. |
|
|
44 |
|
|
|
45 |
The DOSMA command-line parser hierarchy funnels from scan type to action. Scan types are specified first and are |
|
|
46 |
followed by the action to execute and corresponding arguments. For example, the code below computes |T2| for femoral |
|
|
47 |
cartilage (fc) and patellar cartilage (pc) from qDESS scans:: |
|
|
48 |
|
|
|
49 |
$ python -m dosma.cli --dicom subject01/dicoms/qdess --save subject01/data qdess --fc --pc generate_t2_map |
|
|
50 |
|
|
|
51 |
Scans |
|
|
52 |
^^^^^ |
|
|
53 |
:ref:`Scans <scans>` and corresponding actions are specified as subparsers. For example, the code below is the skeleton |
|
|
54 |
for segmenting tissues in qDESS scans:: |
|
|
55 |
|
|
|
56 |
$ python -m dosma.cli qdess segment .... |
|
|
57 |
|
|
|
58 |
|
|
|
59 |
Tissues |
|
|
60 |
^^^^^^^ |
|
|
61 |
:ref:`Tissues <tissues>` are specified as arguments of the subparser using the tissue's abbreviated name. |
|
|
62 |
For example, ``... qdess --fc ...`` would be performing a qDESS-specific action on femoral cartilage. |
|
|
63 |
|
|
|
64 |
To analyze multiple tissues, add additional flags. For example, the argument below |
|
|
65 |
generates a |T2| map for both femoral and patellar cartilage:: |
|
|
66 |
|
|
|
67 |
$ python -m dosma.cli --dicom subject01/dicoms/qdess --save subject01/data qdess --fc --pc generate_t2_map |
|
|
68 |
|
|
|
69 |
Analysis |
|
|
70 |
^^^^^^^^ |
|
|
71 |
DOSMA also has a command-line subparser for creating visualizations and analyze quantitative values for tissues. |
|
|
72 |
This subparser is identified by the anatomical region being analyzed. |
|
|
73 |
|
|
|
74 |
DOSMA currently supports knee-related analyses. To run the analysis on |T2| for femoral cartilage and tibial cartilage, use the following skeleton:: |
|
|
75 |
|
|
|
76 |
$ python -m dosma.cli --load subject01/data knee --fc --tc --t2 |
|
|
77 |
|
|
|
78 |
Help |
|
|
79 |
^^^^ |
|
|
80 |
To get more information, start a new session and run ``python -m dosma.cli --help``. To get the help menu of subparsers, add the |
|
|
81 |
subparser name to the help menu:: |
|
|
82 |
|
|
|
83 |
# Print high-level help menu for DOSMA. |
|
|
84 |
$ python -m dosma.cli --help |
|
|
85 |
|
|
|
86 |
# Print help menu for qDESS scan. |
|
|
87 |
$ python -m dosma.cli qdess --help |
|
|
88 |
|
|
|
89 |
# Print help menu for qDESS segmentation. |
|
|
90 |
$ python -m dosma.cli qdess segment --help |
|
|
91 |
|
|
|
92 |
Examples |
|
|
93 |
^^^^^^^^ |
|
|
94 |
We detail some examples that could be useful for analyzing data. Note there any any number of combinations with how the |
|
|
95 |
data is analyzed. Below are just examples for how they have commonly been used by current users. |
|
|
96 |
|
|
|
97 |
We assume the folder structure looks something like below: |
|
|
98 |
|
|
|
99 |
:: |
|
|
100 |
|
|
|
101 |
research_data |
|
|
102 |
├── patient01 |
|
|
103 |
├── qdess (qDESS dicoms) |
|
|
104 |
| └── I0001.dcm |
|
|
105 |
| └── I0002.dcm |
|
|
106 |
| └── I0003.dcm |
|
|
107 |
| .... |
|
|
108 |
├── cubequant (CubeQuant dicoms) |
|
|
109 |
├── cones (UTE Cones dicoms) |
|
|
110 |
├── patient02 |
|
|
111 |
├── mapss (MAPSS dicoms) |
|
|
112 |
├── patient03 |
|
|
113 |
├── weights (segmentation weights) |
|
|
114 |
├── oai_unet2d |
|
|
115 |
├── iwoai-2019-t6 |
|
|
116 |
├── iwoai-2019-t6-normalized |
|
|
117 |
|
|
|
118 |
|
|
|
119 |
|
|
|
120 |
qDESS |
|
|
121 |
##### |
|
|
122 |
Analyze patient01's femoral cartilage |T2| properties using qDESS sequence*:: |
|
|
123 |
|
|
|
124 |
# 1. Calculate 3D T2 map - suppress fat and fluid to reduce noise |
|
|
125 |
$ python -m dosma.cli --dicom research_data/patient01/dess --save research_data/patient01/data qdess --fc t2 --suppress_fat --suppress_fluid |
|
|
126 |
|
|
|
127 |
# 2. Segment femoral cartilage on root sum of squares (RSS) of two echo qDESS echos using OAI 2D U-Net model. |
|
|
128 |
$ python -m dosma.cli --dicom research_data/patient01/dess --save research_data/patient01/data qdess --fc segment --rss --weights_dir weights/oai_unet2d --model oai-unet2d |
|
|
129 |
|
|
|
130 |
# 3. Calculate/visualize T2 for femoral cartilage |
|
|
131 |
$ python -m dosma.cli --load research_data/patient01/data --save research_data/patient01/data knee --fc --t2 |
|
|
132 |
|
|
|
133 |
|
|
|
134 |
CubeQuant |
|
|
135 |
######### |
|
|
136 |
Analyze patient01 femoral cartilage |T1rho| properties using Cubequant sequence:: |
|
|
137 |
|
|
|
138 |
# 1. Register cubequant volumes (i.e. different spin-lock-times) to one another (intraregistration) |
|
|
139 |
$ python -m dosma.cli --dicom research_data/patient01/cubequant --save research_data/patient01/data cubequant intraregister |
|
|
140 |
|
|
|
141 |
# 2. Register cubequant volume to first echo of qDESS sequence |
|
|
142 |
$ python -m dosma.cli --load research_data/patient01/data cubequant --fc interregister --target_path research_data/patient01/data/dess/echo1.nii.gz --target_mask research_data/patient01/data/fc/fc.nii.gz |
|
|
143 |
|
|
|
144 |
# 3. Calculate 3D T1-rho map only for femoral cartilage region |
|
|
145 |
$ python -m dosma.cli --load research_data/patient01/data cubequant --fc t1_rho --mask_path research_data/patient01/data/fc/fc.nii.gz |
|
|
146 |
|
|
|
147 |
# 4. Calculate/visualize T1-rho for femoral cartilage |
|
|
148 |
$ python -m dosma.cli --load research_data/patient01/data --fc --t1_rho |
|
|
149 |
|
|
|
150 |
|
|
|
151 |
UTE Cones |
|
|
152 |
######### |
|
|
153 |
Analyze patient01 femoral cartilage |T2star| properties using UTE Cones sequence:: |
|
|
154 |
|
|
|
155 |
# 1. Register cones volume to first echo of qDESS sequence |
|
|
156 |
$ python -m dosma.cli --dicom research_data/patient01/cones --save research_data/patient01/data cones --fc interregister --target_path research_data/patient01/data/dess/echo1.nii.gz --target_mask research_data/patient01/data/fc/fc.nii.gz |
|
|
157 |
|
|
|
158 |
# 2. Calculate 3D T2-star map only for femoral cartilage region |
|
|
159 |
$ python -m dosma.cli --load research_data/patient01/data cones --fc t2_star --mask_path research_data/patient01/data/fc/fc.nii.gz |
|
|
160 |
|
|
|
161 |
# 3. Calculate/visualize T1-rho for femoral cartilage |
|
|
162 |
$ python -m dosma.cli --load research_data/patient01/data knee --fc --t2_star |
|
|
163 |
|
|
|
164 |
|
|
|
165 |
MAPSS |
|
|
166 |
##### |
|
|
167 |
Analyze patient02 femoral cartilage |T1rho| and |T2| properties using MAPSS sequence:: |
|
|
168 |
|
|
|
169 |
# 1. Fit T1-rho for whole volume |
|
|
170 |
$ python -m dosma.cli --dicom research_data/patient02/mapss --save research_data/patient02/data mapss --fc t1_rho |
|
|
171 |
|
|
|
172 |
# 2. Fit T2 for whole volume |
|
|
173 |
$ python -m dosma.cli --dicom research_data/patient02/mapss --save research_data/patient02/data mapss --fc t2 |
|
|
174 |
|
|
|
175 |
# 3. Manually segment femoral cartilage and store in appropriate folders. |
|
|
176 |
|
|
|
177 |
# 4. Calculate/visualize T1-rho and T2 for femoral cartilage |
|
|
178 |
$ python -m dosma.cli --load research_data/patient01/data knee --fc --t2_star |
|
|
179 |
|
|
|
180 |
|
|
|
181 |
.. Substitutions |
|
|
182 |
.. |T2| replace:: T\ :sub:`2` |
|
|
183 |
.. |T1| replace:: T\ :sub:`1` |
|
|
184 |
.. |T1rho| replace:: T\ :sub:`1`:math:`{\rho}` |
|
|
185 |
.. |T2star| replace:: T\ :sub:`2`:sup:`*` |