Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions flipGradVectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def flip_file(infile, outfile, axis='1', dryrun=False):
if infile.endswith('.nrrd') or infile.endswith('.nhdr'):
header, data = nrrd.NrrdReader().load(infile)
dvecs = header._data['DWMRI_gradient']
dvecs = np.asarray(dvecs)
else:
dvecs = np.loadtxt(infile)

Expand Down
29 changes: 17 additions & 12 deletions motion_correction/motion_correction.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -l
#!/bin/bash -l
# Script to perform general inter-slice motion correction
# Written: David Rotenberg
# Modified: David Qixiang Chen
Expand All @@ -7,12 +7,12 @@ usage()
{
cat<<EOF
usage: $0 options arg

OPTIONS:
-a Affix to append to images and transforms. Default is "_nobet"
-v Vector calculations only.
-v Vector calculations only.
-o Output file name, without extension. Default is DWI_CORRECTED

ARG
Name of reference file without extension.
EOF
Expand Down Expand Up @@ -53,7 +53,7 @@ done

if [ -n "${!OPTIND}" ]
then scan="${!OPTIND}"
else
else
usage
exit
fi
Expand Down Expand Up @@ -83,10 +83,10 @@ do
if ! $MOTION_COR_ONLY; then
flirt -in ""$volname".nii.gz" -ref vol0000.nii.gz -nosearch -noresampblur -omat "$volname"_trans"$affix".xfm -interp spline -out "$volname"_reg"$affix".nii.gz -paddingsize 1
else
echo "Apply transform: $volname"
echo "Apply transform: $volname"
flirt -interp spline -in "$volname" -ref vol0000.nii.gz -out "$volname"_reg"$affix".nii.gz -applyxfm -init "$volname"_trans"$affix".xfm -paddingsize 1
fi
#echo "Apply transform: $volname"
#echo "Apply transform: $volname"
#resample on the original
#flirt -interp spline -in "$volname" -ref vol0000.nii.gz -out "$volname"_reg.nii.gz -applyxfm -init "$volname"_trans.xfm -paddingsize 1
done
Expand All @@ -95,7 +95,7 @@ echo "fslmerge"

fslmerge -t "$mcored_file".nii.gz *reg"$affix".nii.gz

rm vol*nii*
rm vol*nii*


echo "Calculating transforms"
Expand All @@ -110,12 +110,17 @@ echo "Convert to nrrd"

# Conversion to NRRD

DWIConvert --inputBVectors $scan.bvec --inputBValues $scan.bval --inputVolume $mcored_file.nii.gz --outputVolume tmp.nrrd --conversionMode FSLToNrrd
slicerDWIConvert.sh --inputBVectors $scan.bvec --inputBValues $scan.bval --inputVolume $mcored_file.nii.gz --outputVolume tmp.nrrd --conversionMode FSLToNrrd
unu save -i tmp.nrrd -o $dwi_out -f nrrd
rm tmp.nrrd

cat $dwi_out | head -19 > tmp.nhdr
cat newdirs.nhdr >> tmp.nhdr
mv tmp.nhdr $dwi_out
cat $dwi_out | head -25 > tmp.nhdr
cat tmp.nhdr | egrep -v '^*#' > tmp2.nhdr
cat tmp2.nhdr | head -17 > tmp3.nhdr


#cat $dwi_out | head -19 > tmp.nhdr
cat newdirs.nhdr >> tmp3.nhdr
cat tmp3.nhdr > $dwi_out

rm tmp*.nhdr
Empty file modified slicerDWIConvert.sh
100644 → 100755
Empty file.