-
Notifications
You must be signed in to change notification settings - Fork 536
[ENH] Add MRIsCombine to FreeSurfer utils. #1948
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
Changes from 10 commits
39348e8
50f47c2
7f38790
e2b23d2
8fe4cf5
2914140
01cea35
36fd9c1
e9a5bb8
a7bafda
6c0071c
9ca230f
5f4d402
0a72b4e
7c3125d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT | ||
| from __future__ import unicode_literals | ||
| from ..utils import MRIsCombine | ||
|
|
||
|
|
||
| def test_MRIsCombine_inputs(): | ||
| input_map = dict(args=dict(argstr='%s', | ||
| ), | ||
| environ=dict(nohash=True, | ||
| usedefault=True, | ||
| ), | ||
| ignore_exception=dict(nohash=True, | ||
| usedefault=True, | ||
| ), | ||
| in_files=dict(argstr='--combinesurfs %s', | ||
| mandatory=True, | ||
| position=1, | ||
| ), | ||
| out_file=dict(argstr='%s', | ||
| genfile=True, | ||
| mandatory=True, | ||
| position=-1, | ||
| ), | ||
| subjects_dir=dict(), | ||
| terminal_output=dict(nohash=True, | ||
| ), | ||
| ) | ||
| inputs = MRIsCombine.input_spec() | ||
|
|
||
| for key, metadata in list(input_map.items()): | ||
| for metakey, value in list(metadata.items()): | ||
| assert getattr(inputs.traits()[key], metakey) == value | ||
|
|
||
|
|
||
| def test_MRIsCombine_outputs(): | ||
| output_map = dict(out_file=dict(), | ||
| ) | ||
| outputs = MRIsCombine.output_spec() | ||
|
|
||
| for key, metadata in list(output_map.items()): | ||
| for metakey, value in list(metadata.items()): | ||
| assert getattr(outputs.traits()[key], metakey) == value |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -954,6 +954,64 @@ def _gen_outfilename(self): | |
| return name + ext + "_converted." + self.inputs.out_datatype | ||
|
|
||
|
|
||
| class MRIsCombineInputSpec(FSTraitedSpec): | ||
| """ | ||
| Uses Freesurfer's mris_convert to combine two surface files into one. | ||
| """ | ||
| in_files = traits.List(File(Exists=True), maxlen=2, minlen=2, | ||
| mandatory=True, position=1, argstr='--combinesurfs %s', | ||
| desc='Two surfaces to be combined.') | ||
| out_file = File(argstr='%s', position=-1, genfile=True, | ||
| mandatory=True, | ||
| desc='Output filename. Combined surfaces from in_files.') | ||
|
|
||
|
|
||
| class MRIsCombineOutputSpec(TraitedSpec): | ||
| """ | ||
| Uses Freesurfer's mris_convert to combine two surface files into one. | ||
| """ | ||
| out_file = File(exists=True, desc='Output filename. Combined surfaces from ' | ||
| 'in_files.') | ||
|
|
||
|
|
||
| class MRIsCombine(FSCommand): | ||
| """ | ||
| Uses Freesurfer's mris_convert to combine two surface files into one. | ||
|
|
||
| For complete details, see the `mris_convert Documentation. | ||
| <https://surfer.nmr.mgh.harvard.edu/fswiki/mris_convert>`_ | ||
|
|
||
| Example | ||
| ------- | ||
|
|
||
| >>> import nipype.interfaces.freesurfer as fs | ||
| >>> mris = fs.MRIsCombine() | ||
| >>> mris.inputs.in_files = ['lh.pial', 'rh.pial'] | ||
| >>> mris.inputs.out_file = 'bh.pial' | ||
| >>> mris.cmdline # doctest: +ALLOW_UNICODE | ||
| 'mris_convert --combinesurfs lh.pial rh.pial bh.pial' | ||
| >>> mris.run() # doctest: +SKIP | ||
| """ | ||
| _cmd = 'mris_convert' | ||
| input_spec = MRIsCombineInputSpec | ||
| output_spec = MRIsCombineOutputSpec | ||
|
|
||
| def _list_outputs(self): | ||
| """ | ||
| If the output file is not specified starting with 'lh.' or 'rh.', | ||
| FreeSurfer prepends 'lh.' to the filename. It never adds 'rh.', even if | ||
| both input files are from the right hemisphere. Output out_file must be | ||
| adjusted to accommodate this. | ||
| """ | ||
| outputs = self.output_spec().get() | ||
| if any(self.inputs.out_file.startswith(pre) for pre in ['lh.', 'rh.']): | ||
| outputs['out_file'] = self.inputs.out_file | ||
| else: | ||
| outputs['out_file'] = 'lh.' + self.inputs.out_file | ||
|
||
|
|
||
| return outputs | ||
|
|
||
|
|
||
| class MRITessellateInputSpec(FSTraitedSpec): | ||
| """ | ||
| Uses Freesurfer's mri_tessellate to create surfaces by tessellating a given input volume | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here might be a good place to add a comment about outputs (so it shows up in the docs):