Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fMRIVolume OneStepResampling.sh is breaking the TR if input data is not in seconds #124

Open
cmpetty opened this issue Jul 10, 2019 · 4 comments
Assignees

Comments

@cmpetty
Copy link

cmpetty commented Jul 10, 2019

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
@glasserm
Copy link
Contributor

I assume we would use bc instead of adding a perl dependency, but this does seem worth fixing.

@cmpetty
Copy link
Author

cmpetty commented Jul 12, 2019

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

@mharms
Copy link
Contributor

mharms commented Jul 12, 2019

@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
Copy link
Author

cmpetty commented Jul 12, 2019

@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 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants