Skip to content

Commit

Permalink
batch_single_subject.sh: Reorder to match SCT course
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuacwnewton authored Oct 30, 2023
1 parent c60874b commit ca3abe9
Showing 1 changed file with 43 additions and 43 deletions.
86 changes: 43 additions & 43 deletions single_subject/batch_single_subject.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,31 +85,13 @@ sct_qc -i t2.nii.gz -s t2_labels_vert.nii.gz -p sct_label_utils -qc ~/qc_singleS



# Registering T2 data to the PAM50 template
# ======================================================================================================================

# Register t2->template.
sct_register_to_template -i t2.nii.gz -s t2_seg.nii.gz -l t2_labels_vert.nii.gz -c t2 -qc ~/qc_singleSubj
# Note: By default the PAM50 template is selected. You can also select your own template using flag -t.

# Warp template objects (T2, cord segmentation, vertebral levels, etc.). Here we use -a 0 because we don’t need the
# white matter atlas at this point.
sct_warp_template -d t2.nii.gz -w warp_template2anat.nii.gz -a 0 -qc ~/qc_singleSubj
# Note: A folder label/template/ is created, which contains template objects in the space of the subject. The file
# info_label.txt lists all template files.

# Check results using Fsleyes.
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 &



# Computing shape metrics
# ======================================================================================================================

# Compute cross-sectional area (CSA) of spinal cord and average it across levels C3 and C4
sct_process_segmentation -i t2_seg.nii.gz -vert 3:4 -vertfile ./label/template/PAM50_levels.nii.gz -o csa_c3c4.csv
sct_process_segmentation -i t2_seg.nii.gz -vert 3:4 -vertfile t2_seg_labeled.nii.gz -o csa_c3c4.csv
# Aggregate CSA value per level
sct_process_segmentation -i t2_seg.nii.gz -vert 3:4 -vertfile ./label/template/PAM50_levels.nii.gz -perlevel 1 -o csa_perlevel.csv
sct_process_segmentation -i t2_seg.nii.gz -vert 3:4 -vertfile t2_seg_labeled.nii.gz -perlevel 1 -o csa_perlevel.csv
# Aggregate CSA value per slices
sct_process_segmentation -i t2_seg.nii.gz -z 30:35 -perslice 1 -o csa_perslice.csv

Expand All @@ -123,7 +105,6 @@ sct_process_segmentation -i t2_seg.nii.gz -pmj t2_pmj.nii.gz -pmj-distance 64 -p




# Computing normalized shape metrics for compressed data
# ======================================================================================================================
cd ../t2_compression
Expand All @@ -146,32 +127,21 @@ sct_compute_compression -i t2_compressed_seg.nii.gz -vertfile t2_compressed_seg_



# Registering lumbar data to the PAM50 template
# Registering T2 data to the PAM50 template
# ======================================================================================================================
cd ../t2_lumbar

# Crop full-body image to isolate the lumbar region (lowest 200 axial slices)
sct_crop_image -i t2.nii.gz -zmax 200

# Use lumbar-specific `sct_deepseg` model to segment the spinal cord
sct_deepseg -i t2_crop.nii.gz -task seg_lumbar_sc_t2w

# Register t2->template.
sct_register_to_template -i t2.nii.gz -s t2_seg.nii.gz -l t2_labels_vert.nii.gz -c t2 -qc ~/qc_singleSubj
# Note: By default the PAM50 template is selected. You can also select your own template using flag -t.

# Generate labels for the 2 spinal cord landmarks: cauda equinea ('99') and T9-T10 disc ('17')
# Note: Normally this would be done manually using fsleyes' "Edit mode -> Create mask" functionality. (Uncomment below)
#
# fsleyes t2.nii.gz &
#
# However, since this is an automated script with example data, we will place the labels at known locations for the
# sake of reproducing the results in the tutorial.
sct_label_utils -i t2.nii.gz -create 22,77,187,17:27,79,80,60 -o t2_crop_labels.nii.gz
# Warp template objects (T2, cord segmentation, vertebral levels, etc.). Here we use -a 0 because we don’t need the
# white matter atlas at this point.
sct_warp_template -d t2.nii.gz -w warp_template2anat.nii.gz -a 0 -qc ~/qc_singleSubj
# Note: A folder label/template/ is created, which contains template objects in the space of the subject. The file
# info_label.txt lists all template files.

# Register the image to the template using segmentation and labels
sct_register_to_template -i t2_crop.nii.gz \
-s t2_crop_seg.nii.gz \
-ldisc t2_crop_label.nii.gz \
-c t2 -qc qc \
-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
# Check results using Fsleyes.
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 &



Expand Down Expand Up @@ -243,6 +213,33 @@ sct_register_multimodal -i t1_crop.nii.gz -d ../t2/t2_crop.nii.gz -param step=1,



# Registering lumbar data to the PAM50 template
# ======================================================================================================================
cd ../t2_lumbar

# Crop full-body image to isolate the lumbar region (lowest 200 axial slices)
sct_crop_image -i t2.nii.gz -zmax 200
# Use lumbar-specific `sct_deepseg` model to segment the spinal cord
sct_deepseg -i t2_crop.nii.gz -task seg_lumbar_sc_t2w

# Generate labels for the 2 spinal cord landmarks: cauda equinea ('99') and T9-T10 disc ('17')
# Note: Normally this would be done manually using fsleyes' "Edit mode -> Create mask" functionality. (Uncomment below)
#
# fsleyes t2.nii.gz &
#
# However, since this is an automated script with example data, we will place the labels at known locations for the
# sake of reproducing the results in the tutorial.
sct_label_utils -i t2.nii.gz -create 22,77,187,17:27,79,80,60 -o t2_crop_labels.nii.gz

# Register the image to the template using segmentation and labels
sct_register_to_template -i t2_crop.nii.gz \
-s t2_crop_seg.nii.gz \
-ldisc t2_crop_label.nii.gz \
-c t2 -qc qc \
-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



# Gray/white matter: Segmentation
# ======================================================================================================================

Expand Down Expand Up @@ -293,6 +290,8 @@ sct_warp_template -d mt1.nii.gz -w warp_template2mt.nii.gz -qc ~/qc_singleSubj
# Check results
fsleyes 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 &



# Atlas-based analysis (Extracting metrics (MTR) in gray/white matter tracts)
# ======================================================================================================================

Expand All @@ -307,6 +306,7 @@ sct_extract_metric -i mtr.nii.gz -f label/atlas -method map -l 4,5 -z 5:15 -o mt
sct_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



# Diffusion-weighted MRI
# ======================================================================================================================

Expand Down

0 comments on commit ca3abe9

Please sign in to comment.