Last active
May 15, 2020 16:31
-
-
Save tashrifbillah/85631b3329f1cdd320dc9b327f095097 to your computer and use it in GitHub Desktop.
Fix bounding box of labelmap after Slicer ruined it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# copy this script in the following directory and run from there | |
# cd DIAGNOSE_CTE_U01/derivatives/pnlpipe | |
# run as sh fix_bbox.sh | |
for c in $(cat incongruous_cases.txt) | |
do | |
mask_name=sub-${c}/ses-01/dwi/sub-${c}_ses-01_desc-dwiXcCNNQc_mask.nii.gz | |
bse_name=sub-${c}/ses-01/dwi/sub-${c}_ses-01_desc-dwiXc_bse.nii.gz | |
echo $c | |
# back up the original mask | |
cp $mask_name ${mask_name}.bak | |
# modify the bounding box | |
antsApplyTransforms -d 3 -i $mask_name -o $mask_name -t identity -r $bse_name | |
# the above step sets datatype to float64, bring it back to short/char | |
fslmaths $mask_name -mul 1 $mask_name -odt char | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Since the bounding box issue is coming up repetitively, I am archiving a script for fixing it.
cc @eknyazhe @sbouix