Skip to content

Commit 5621c7e

Browse files
authored
Updated code to new BIDS-compliant dataset (#56)
* Updated code to new BIDS-compliant dataset Fixes #55 * Removed debugging mode with set -x
1 parent 90d8378 commit 5621c7e

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

process_data.sh

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ segment_if_does_not_exist(){
4343
local contrast="$2"
4444
# Update global variable with segmentation file name
4545
FILESEG="${file}_seg"
46-
FILESEGMANUAL="${PATH_DATA}/${SUBJECT}/${FILESEG}_manual${ext}"
47-
echo
46+
FILESEGMANUAL="${PATH_DATA}/derivatives/labels/${SUBJECT}/anat/${FILESEG}-manual${ext}"
4847
echo "Looking for manual segmentation: $FILESEGMANUAL"
4948
if [[ -e $FILESEGMANUAL ]]; then
5049
echo "Found! Using manual segmentation."
@@ -64,7 +63,7 @@ segment_gm_if_does_not_exist(){
6463
local contrast="$2"
6564
# Update global variable with segmentation file name
6665
FILESEG="${file}_gmseg"
67-
FILESEGMANUAL="${PATH_DATA}/${SUBJECT}/${FILESEG}_manual${ext}"
66+
FILESEGMANUAL="${PATH_DATA}/derivatives/labels/${SUBJECT}/anat/${FILESEG}-manual${ext}"
6867
echo "Looking for manual segmentation: $FILESEGMANUAL"
6968
if [[ -e $FILESEGMANUAL ]]; then
7069
echo "Found! Using manual segmentation."
@@ -88,9 +87,9 @@ cd $PATH_DATA_PROCESSED
8887
# Copy source images
8988
rsync -avzh $PATH_DATA/$SUBJECT .
9089
# Go to folder
91-
cd ${SUBJECT}
92-
file_1="data1"
93-
file_2="data2"
90+
cd ${SUBJECT}/anat
91+
file_1="${SUBJECT}_run-1_T2starw"
92+
file_2="${SUBJECT}_run-2_T2starw"
9493
ext=".nii.gz"
9594
# Segment spinal cord
9695
segment_if_does_not_exist $file_1 "t2s"
@@ -118,8 +117,8 @@ sct_register_multimodal -i ${file_2}${ext} -d ${file_1}${ext} -dseg ${file_1_seg
118117
file_2=${file_2}_reg
119118
# Compute SNR using both methods
120119
sct_image -i ${file_1}${ext} ${file_2}${ext} -concat t -o data_concat.nii.gz
121-
sct_compute_snr -i data_concat.nii.gz -method diff -m data1_crop_wmseg_erode.nii.gz -o snr_diff.txt
122-
sct_compute_snr -i data_concat.nii.gz -method mult -m data1_crop_wmseg_erode.nii.gz -o snr_mult.txt
120+
sct_compute_snr -i data_concat.nii.gz -method diff -m ${file_1}_wmseg_erode.nii.gz -o snr_diff.txt
121+
sct_compute_snr -i data_concat.nii.gz -method mult -m ${file_1}_wmseg_erode.nii.gz -o snr_mult.txt
123122
# Compute average value in WM and GM on a slice-by-slice basis
124123
sct_extract_metric -i ${file_1}${ext} -f ${file_1}_wmseg${ext} -method bin -o signal_wm.csv
125124
sct_extract_metric -i ${file_2}${ext} -f ${file_1}_wmseg${ext} -method bin -o signal_wm.csv -append 1
@@ -138,9 +137,6 @@ echo "${SUBJECT},`cat snr_diff.txt`,`cat snr_mult.txt`,`cat contrast.txt`" >> ${
138137
# Verify presence of output files and write log file if error
139138
# ------------------------------------------------------------------------------
140139
FILES_TO_CHECK=(
141-
"data1_seg_manual${ext}"
142-
"data1_gmseg_manual${ext}"
143-
"data1_crop_wmseg_erode${ext}"
144140
"signal_wm.csv"
145141
"signal_gm.csv"
146142
"snr_diff.txt"

0 commit comments

Comments
 (0)