@@ -85,31 +85,13 @@ sct_qc -i t2.nii.gz -s t2_labels_vert.nii.gz -p sct_label_utils -qc ~/qc_singleS
8585
8686
8787
88- # Registering T2 data to the PAM50 template
89- # ======================================================================================================================
90-
91- # Register t2->template.
92- sct_register_to_template -i t2.nii.gz -s t2_seg.nii.gz -l t2_labels_vert.nii.gz -c t2 -qc ~ /qc_singleSubj
93- # Note: By default the PAM50 template is selected. You can also select your own template using flag -t.
94-
95- # Warp template objects (T2, cord segmentation, vertebral levels, etc.). Here we use -a 0 because we don’t need the
96- # white matter atlas at this point.
97- sct_warp_template -d t2.nii.gz -w warp_template2anat.nii.gz -a 0 -qc ~ /qc_singleSubj
98- # Note: A folder label/template/ is created, which contains template objects in the space of the subject. The file
99- # info_label.txt lists all template files.
100-
101- # Check results using Fsleyes.
102- fsleyes t2.nii.gz -cm greyscale -a 100.0 label/template/PAM50_t2.nii.gz -cm greyscale -dr 0 4000 -a 100.0 label/template/PAM50_gm.nii.gz -cm red-yellow -dr 0.4 1 -a 50.0 label/template/PAM50_wm.nii.gz -cm blue-lightblue -dr 0.4 1 -a 50.0 &
103-
104-
105-
10688# Computing shape metrics
10789# ======================================================================================================================
10890
10991# Compute cross-sectional area (CSA) of spinal cord and average it across levels C3 and C4
110- sct_process_segmentation -i t2_seg.nii.gz -vert 3:4 -vertfile ./label/template/PAM50_levels .nii.gz -o csa_c3c4.csv
92+ sct_process_segmentation -i t2_seg.nii.gz -vert 3:4 -vertfile t2_seg_labeled .nii.gz -o csa_c3c4.csv
11193# Aggregate CSA value per level
112- sct_process_segmentation -i t2_seg.nii.gz -vert 3:4 -vertfile ./label/template/PAM50_levels .nii.gz -perlevel 1 -o csa_perlevel.csv
94+ sct_process_segmentation -i t2_seg.nii.gz -vert 3:4 -vertfile t2_seg_labeled .nii.gz -perlevel 1 -o csa_perlevel.csv
11395# Aggregate CSA value per slices
11496sct_process_segmentation -i t2_seg.nii.gz -z 30:35 -perslice 1 -o csa_perslice.csv
11597
@@ -123,7 +105,6 @@ sct_process_segmentation -i t2_seg.nii.gz -pmj t2_pmj.nii.gz -pmj-distance 64 -p
123105
124106
125107
126-
127108# Computing normalized shape metrics for compressed data
128109# ======================================================================================================================
129110cd ../t2_compression
@@ -146,32 +127,21 @@ sct_compute_compression -i t2_compressed_seg.nii.gz -vertfile t2_compressed_seg_
146127
147128
148129
149- # Registering lumbar data to the PAM50 template
130+ # Registering T2 data to the PAM50 template
150131# ======================================================================================================================
151- cd ../t2_lumbar
152-
153- # Crop full-body image to isolate the lumbar region (lowest 200 axial slices)
154- sct_crop_image -i t2.nii.gz -zmax 200
155-
156- # Use lumbar-specific `sct_deepseg` model to segment the spinal cord
157- sct_deepseg -i t2_crop.nii.gz -task seg_lumbar_sc_t2w
158-
132+ cd ../t2
133+ # Register t2->template.
134+ sct_register_to_template -i t2.nii.gz -s t2_seg.nii.gz -l t2_labels_vert.nii.gz -c t2 -qc ~ /qc_singleSubj
135+ # Note: By default the PAM50 template is selected. You can also select your own template using flag -t.
159136
160- # Generate labels for the 2 spinal cord landmarks: cauda equinea ('99') and T9-T10 disc ('17')
161- # Note: Normally this would be done manually using fsleyes' "Edit mode -> Create mask" functionality. (Uncomment below)
162- #
163- # fsleyes t2.nii.gz &
164- #
165- # However, since this is an automated script with example data, we will place the labels at known locations for the
166- # sake of reproducing the results in the tutorial.
167- sct_label_utils -i t2.nii.gz -create 22,77,187,17:27,79,80,60 -o t2_crop_labels.nii.gz
137+ # Warp template objects (T2, cord segmentation, vertebral levels, etc.). Here we use -a 0 because we don’t need the
138+ # white matter atlas at this point.
139+ sct_warp_template -d t2.nii.gz -w warp_template2anat.nii.gz -a 0 -qc ~ /qc_singleSubj
140+ # Note: A folder label/template/ is created, which contains template objects in the space of the subject. The file
141+ # info_label.txt lists all template files.
168142
169- # Register the image to the template using segmentation and labels
170- sct_register_to_template -i t2_crop.nii.gz \
171- -s t2_crop_seg.nii.gz \
172- -ldisc t2_crop_label.nii.gz \
173- -c t2 -qc qc \
174- -param step=1,type=seg,algo=centermassrot:step=2,type=seg,algo=bsplinesyn,metric=MeanSquares,iter=3,slicewise=0:step=3,type=im,algo=syn,metric=CC,iter=3,slicewise=0
143+ # Check results using Fsleyes.
144+ fsleyes t2.nii.gz -cm greyscale -a 100.0 label/template/PAM50_t2.nii.gz -cm greyscale -dr 0 4000 -a 100.0 label/template/PAM50_gm.nii.gz -cm red-yellow -dr 0.4 1 -a 50.0 label/template/PAM50_wm.nii.gz -cm blue-lightblue -dr 0.4 1 -a 50.0 &
175145
176146
177147
@@ -243,6 +213,33 @@ sct_register_multimodal -i t1_crop.nii.gz -d ../t2/t2_crop.nii.gz -param step=1,
243213
244214
245215
216+ # Registering lumbar data to the PAM50 template
217+ # ======================================================================================================================
218+ cd ../t2_lumbar
219+
220+ # Crop full-body image to isolate the lumbar region (lowest 200 axial slices)
221+ sct_crop_image -i t2.nii.gz -zmax 200 -o t2_lumbar.nii.gz
222+ # Use lumbar-specific `sct_deepseg` model to segment the spinal cord
223+ sct_deepseg -i t2_lumbar.nii.gz -task seg_lumbar_sc_t2w
224+
225+ # Generate labels for the 2 spinal cord landmarks: cauda equinea ('99') and T9-T10 disc ('17')
226+ # Note: Normally this would be done manually using fsleyes' "Edit mode -> Create mask" functionality. (Uncomment below)
227+ #
228+ # fsleyes t2.nii.gz &
229+ #
230+ # However, since this is an automated script with example data, we will place the labels at known locations for the
231+ # sake of reproducing the results in the tutorial.
232+ sct_label_utils -i t2.nii.gz -create 22,77,187,17:27,79,80,60 -o t2_lumbar_labels.nii.gz
233+
234+ # Register the image to the template using segmentation and labels
235+ sct_register_to_template -i t2_lumbar.nii.gz \
236+ -s t2_lumbar_seg.nii.gz \
237+ -ldisc t2_lumbar_labels.nii.gz \
238+ -c t2 -qc qc \
239+ -param step=1,type=seg,algo=centermassrot:step=2,type=seg,algo=bsplinesyn,metric=MeanSquares,iter=3,slicewise=0:step=3,type=im,algo=syn,metric=CC,iter=3,slicewise=0
240+
241+
242+
246243# Gray/white matter: Segmentation
247244# ======================================================================================================================
248245
@@ -293,6 +290,8 @@ sct_warp_template -d mt1.nii.gz -w warp_template2mt.nii.gz -qc ~/qc_singleSubj
293290# Check results
294291fsleyes mt1.nii.gz -cm greyscale -a 100.0 label/template/PAM50_t2.nii.gz -cm greyscale -dr 0 4000 -a 100.0 label/template/PAM50_gm.nii.gz -cm red-yellow -dr 0.4 1 -a 100.0 label/template/PAM50_wm.nii.gz -cm blue-lightblue -dr 0.4 1 -a 100.0 &
295292
293+
294+
296295# Atlas-based analysis (Extracting metrics (MTR) in gray/white matter tracts)
297296# ======================================================================================================================
298297
@@ -307,6 +306,7 @@ sct_extract_metric -i mtr.nii.gz -f label/atlas -method map -l 4,5 -z 5:15 -o mt
307306sct_extract_metric -i mtr.nii.gz -f label/atlas -method map -l 53 -vert 2:4 -vertfile label/template/PAM50_levels.nii.gz -o mtr_in_dc.csv
308307
309308
309+
310310# Diffusion-weighted MRI
311311# ======================================================================================================================
312312
0 commit comments