Skip to content

Instantly share code, notes, and snippets.

@tashrifbillah
Last active May 15, 2020 16:31
Show Gist options
  • Save tashrifbillah/85631b3329f1cdd320dc9b327f095097 to your computer and use it in GitHub Desktop.
Save tashrifbillah/85631b3329f1cdd320dc9b327f095097 to your computer and use it in GitHub Desktop.
Fix bounding box of labelmap after Slicer ruined it
# 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
@tashrifbillah
Copy link
Author

tashrifbillah commented May 15, 2020

Since the bounding box issue is coming up repetitively, I am archiving a script for fixing it.
cc @eknyazhe @sbouix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment