HCPpipelines
HCPpipelines copied to clipboard
fMRIVolume OneStepResampling.sh is breaking the TR if input data is not in seconds
When data is passed to OneStepResampling.sh that has TR in ms it is breaking the files afterwards because the time_units are not being accounted for.
You're saving the TR, then re-setting in later with fslmerge, but fslmerge requires TR in seconds.
We found that our files after this step had TR set to 1000.00 seconds, instead of 1 sc, or 1000.00 ms
I added some code to account for different units and adjust before it got to the fslmerge step
##Save TR for later
TR_vol=`${FSLDIR}/bin/fslval ${InputfMRI} pixdim4 | cut -d " " -f 1`
TR_units=`${FSLDIR}/bin/fslval ${InputfMRI} time_units | cut -d " " -f 1`
NumFrames=`${FSLDIR}/bin/fslval ${InputfMRI} dim4`
##added to account for time units
if [ ${TR_units} = "s" ] ; then
# this is fine
continue
elif [ ${TR_units} = "ms" ] ; then
TR_vol=$( perl -e "print $TR_vol / 1000.0");
elif [ ${TR_units} = "us" ] ; then
TR_vol=$( perl -e "print $TR_vol / 1000000.0");
fi
##Merge together results and restore the TR (saved beforehand)
${FSLDIR}/bin/fslmerge -tr ${OutputfMRI} $FrameMergeSTRING $TR_vol
${FSLDIR}/bin/fslmerge -tr ${OutputfMRI}_mask $FrameMergeSTRINGII $TR_vol
I assume we would use bc instead of adding a perl dependency, but this does seem worth fixing.
I assume we would use bc instead of adding a perl dependency, but this does seem worth fixing.
Good point .. i changed mine to
118 if [ ${TR_units} = "s" ] ; then
119 # this is fine
120 continue
121 elif [ ${TR_units} = "ms" ] ; then
122 TR_vol=$( echo "scale=4;${TR_vol} / 1000.0" | bc -l );
123 elif [ ${TR_units} = "us" ] ; then
124 TR_vol=$( echo "scale=4;${TR_vol} / 1000000.0" | bc -l );
125 fi
@cmpetty Would you be willing to create a PR for this, including finding other instances in the code base where we set the TR as part of fslmerge? Thanks.
@cmpetty Would you be willing to create a PR for this, including finding other instances in the code base where we set the TR as part of
fslmerge? Thanks.
Sure. i found a couple other places ( hcp_fix_* , mcflirt_acc.sh , OneStepResampling.sh )