Skip to content

Added support for a list of 3d files for TSNR calculation. #360

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

Merged
merged 3 commits into from
Apr 16, 2012
Merged
Changes from 1 commit
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
17 changes: 9 additions & 8 deletions nipype/algorithms/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,8 @@ def _list_outputs(self):


class TSNRInputSpec(BaseInterfaceInputSpec):
in_file = File(exists=True, mandatory=True,
desc='realigned 4D file')
in_file = InputMultiPath(File(exists=True), mandatory=True,
desc='realigned 4D file or a list of 3D files')
regress_poly = traits.Int(min=1, desc='Remove polynomials')


Expand Down Expand Up @@ -476,17 +476,18 @@ class TSNR(BaseInterface):
output_spec = TSNROutputSpec

def _gen_output_file_name(self, out_ext=None):
_, base, _ = split_filename(self.inputs.in_file)
_, base, _ = split_filename(self.inputs.in_file[0])
if out_ext in ['mean', 'stddev']:
return os.path.abspath(base + "_tsnr_" + out_ext + ".nii.gz")
return os.path.abspath(base + "_tsnr_" + out_ext + ".nii")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use an input to determine compression? i'm really moving away from any uncompressed outputs. takes up too much space! so by default i would like to see things compressed. since this uses nibabel, perhaps allow any of the outputs that nibabel allows.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I understand your concerns, but to maximize out-of-the box compatibility I prefer to set default output type to uncompressed NIFTI. I did the same for AFNI in another PR.

elif out_ext in ['detrended']:
return os.path.abspath(base + "_" + out_ext + ".nii.gz")
return os.path.abspath(base + "_" + out_ext + ".nii")
else:
return os.path.abspath(base + "_tsnr.nii.gz")
return os.path.abspath(base + "_tsnr.nii")

def _run_interface(self, runtime):
img = nb.load(self.inputs.in_file)
data = img.get_data()
img = nb.load(self.inputs.in_file[0])
vollist = [nb.load(filename) for filename in self.inputs.in_file]
data = np.concatenate([vol.get_data().reshape(vol.get_shape()[:3] + (-1,)) for vol in vollist], axis=3)
if isdefined(self.inputs.regress_poly):
timepoints = img.get_shape()[-1]
X = np.ones((timepoints,1))
Expand Down