-
Notifications
You must be signed in to change notification settings - Fork 1
/
wmCorrection.sh
executable file
·40 lines (27 loc) · 1.7 KB
/
wmCorrection.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
# WM Correction
function wmCorrection {
LOWER=$(echo "${WM_Mean} - ${VoxelRange}" | bc -l);
UPPER=$(echo "${WM_Mean} + ${VoxelRange}" | bc -l);
# multiply Lesion mask by normalized T1 intensity
if $(fslmaths $SUBJECTOPDIR/Intermediate_Files/${SUBJ}_${ANATOMICAL_ID}_int_scaled -mul $SUBJECTOPDIR/Intermediate_Files/${SUBJ}_LesionMask${counter}_bin $SUBJECTOPDIR/Intermediate_Files/${SUBJ}_Lesion${counter}_NormRange) ; then
# remove WM values from Lesion mask
# get rid of anything above lower bound
fslmaths $SUBJECTOPDIR/Intermediate_Files/${SUBJ}_Lesion${counter}_NormRange -uthr $LOWER $SUBJECTOPDIR/Intermediate_Files/${SUBJ}_WMAdjusted_Lesion${counter}_lower;
# get rid of anything below upper bound
fslmaths $SUBJECTOPDIR/Intermediate_Files/${SUBJ}_Lesion${counter}_NormRange -thr $UPPER $SUBJECTOPDIR/Intermediate_Files/${SUBJ}_WMAdjusted_Lesion${counter}_upper;
# sum two together
fslmaths $SUBJECTOPDIR/Intermediate_Files/${SUBJ}_WMAdjusted_Lesion${counter}_upper -add $SUBJECTOPDIR/Intermediate_Files/${SUBJ}_WMAdjusted_Lesion${counter}_lower $SUBJECTOPDIR/Intermediate_Files/${SUBJ}_WMAdjusted_Lesion${counter};
# re-binarize Lesion mask
fslmaths $SUBJECTOPDIR/Intermediate_Files/${SUBJ}_WMAdjusted_Lesion${counter} -bin $SUBJECTOPDIR/${SUBJ}_WMAdjusted_Lesion${counter}_bin;
CorrLesionVol=$(fslstats $SUBJECTOPDIR/${SUBJ}_WMAdjusted_Lesion${counter}_bin -V | awk '{print $2;}');
else
echo "
Check Image Orientations for T1 and Lesion Mask. Skipping Subject: ${SUBJ}.";
printf "${SUBJ} Skipped" >> "$WORKINGDIR"/lesion_data.csv;
printf '\n' >> "$WORKINGDIR"/lesion_data.csv;
cd "$INPUTDIR" || exit;
return;
fi
echo ${CorrLesionVol};
}