Skip to content

Commit 6787d06

Browse files
committed
Switch to sct_deepseg_sc for DWI mean data
1 parent 7da0705 commit 6787d06

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

02_processing_scripts/02_process_data.sh

+31-2
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,33 @@ segment_sc_CA_if_does_not_exist(){
175175
fi
176176
}
177177

178+
# Check if manual segmentation already exists (under /derivatives/labels/). If it does, copy it locally. If
179+
# it does not, perform segmentation using sct_deepseg_sc.
180+
segment_sc_if_does_not_exist(){
181+
local file="$1"
182+
local contrast="$2"
183+
# Find contrast
184+
if [[ $contrast == "dwi" ]]; then
185+
folder_contrast="dwi"
186+
else
187+
folder_contrast="anat"
188+
fi
189+
# Update global variable with segmentation file name
190+
FILESEG="${file}_seg"
191+
FILESEGMANUAL="${PATH_DATA}/derivatives/labels/${SUBJECT}/${folder_contrast}/${FILESEG}.nii.gz"
192+
echo
193+
echo "Looking for manual segmentation: $FILESEGMANUAL"
194+
if [[ -e $FILESEGMANUAL ]]; then
195+
echo "✅ Found! Using manual segmentation."
196+
rsync -avzh $FILESEGMANUAL ${FILESEG}.nii.gz
197+
sct_qc -i ${file}.nii.gz -s ${FILESEG}.nii.gz -p sct_deepseg_sc -qc ${PATH_QC} -qc-subject ${file}
198+
else
199+
echo "❌ Not found. Proceeding with automatic segmentation."
200+
# Segment spinal cord
201+
sct_deepseg_sc -i ${file}.nii.gz -c ${contrast} -qc ${PATH_QC} -qc-subject ${file}
202+
fi
203+
}
204+
178205
# Check if manual segmentation already exists. If it does, copy it locally. If
179206
# it does not, perform seg.
180207
segment_gm_if_does_not_exist(){
@@ -344,8 +371,10 @@ sct_dmri_moco -i ${file_dwi}.nii.gz -bvec ${file_bvec} -x spline -param metric=C
344371
file_dwi=${file_dwi}_moco
345372
file_dwi_mean=${file_dwi}_dwi_mean
346373

347-
# Segment spinal cord (only if it does not exist) using the contrast-agnostic model (part of SCT v6.2)
348-
segment_sc_CA_if_does_not_exist ${file_dwi_mean} "dwi"
374+
# Segment spinal cord (only if it does not exist) using sct_deepseg_sc
375+
# Note: sct_deepseg_sc seems to work better for DWI than the contrast-agnostic model; details:
376+
# https://github.com/valosekj/dcm-brno/issues/19
377+
segment_sc_if_does_not_exist ${file_dwi_mean} "dwi"
349378
file_dwi_seg=$FILESEG
350379

351380
# Register template->dwi (using T2w-to-template as initial transformation)

0 commit comments

Comments
 (0)