-
Couldn't load subscription status.
- 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 8 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,46 @@ | ||
| # 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_file1=dict(argstr='--combinesurfs %s', | ||
| mandatory=True, | ||
| position=1, | ||
| ), | ||
| in_file2=dict(argstr='%s', | ||
| mandatory=True, | ||
| position=2, | ||
| ), | ||
| 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,63 @@ 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_file1 = File(exists=True, mandatory=True, position=1, | ||
| argstr='--combinesurfs %s', | ||
| desc='File to be combined with in_file2') | ||
| in_file2 = File(exists=True, mandatory=True, position=2, | ||
| argstr='%s', | ||
| desc='File to be combined with in_file1') | ||
| out_file = File(argstr='%s', position=-1, genfile=True, | ||
| mandatory=True, | ||
| desc='Output filename. Combined surfaces from in_file1 and ' | ||
| 'in_file2.') | ||
| | ||
| | ||
| 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_file1 and in_file2.') | ||
| | ||
| | ||
| 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>`_ | ||
| | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe 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): | ||
| Example | ||
| ------- | ||
| | ||
| >>> import nipype.interfaces.freesurfer as fs | ||
| >>> mris = fs.MRIsCombine() | ||
| >>> mris.inputs.in_file1 = 'lh.pial' | ||
| >>> mris.inputs.in_file2 = 'rh.pial' | ||
| >>> mris.inputs.out_file = 'out.stl' | ||
| >>> mris.cmdline # doctest: +ALLOW_UNICODE | ||
| 'mris_convert --combinesurfs lh.pial rh.pial out.stl' | ||
| >>> mris.run() # doctest: +SKIP | ||
| """ | ||
| _cmd = 'mris_convert' | ||
| input_spec = MRIsCombineInputSpec | ||
| output_spec = MRIsCombineOutputSpec | ||
| | ||
| def _list_outputs(self): | ||
| 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.
Do you specifically want
in_file1andin_file2ports? This could be made a list like so:(I think. I'd check this syntax.)
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.
I didn't realize
traits.Listallowed formaxlenandminlen. I definitely prefer it your way. Just tested it and it works, so I'll commit it in a second.