8000 [ENH]: Add functions to mrtrix3 interface by lbutry · Pull Request #3613 · nipy/nipype · GitHub
[go: up one dir, main page]

Skip to content

[ENH]: Add functions to mrtrix3 interface #3613

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 19 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
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
Next Next commit
added node maskfilter
  • Loading branch information
Lionel Butry committed Oct 17, 2023
commit 984b7e8c34c33aed7d2272f476f03d9f3dc8b90e
1 change: 1 addition & 0 deletions nipype/interfaces/mrtrix3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@
SHConv,
TensorMetrics,
TransformFSLConvert,
MaskFilter,
)
61 changes: 61 additions & 0 deletions nipype/interfaces/mrtrix3/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1186,3 +1186,64 @@ def _list_outputs(self):
outputs = self.output_spec().get()
outputs["out_file"] = op.abspath(self.inputs.out_file)
return outputs

class MaskFilterInputSpec(CommandLineInputSpec):
in_file = File(
exists=True,
mandatory=True,
argstr="%s",
position=-3,
desc="Input mask",
)
filter = traits.Str(
mandatory=True,
argstr="%s",
position=-2,
desc="Filter to perform (e.g. dilate, erode)"
)
out_file = File(
name_source=["input_image"],
mandatory=True,
argstr="%s",
position=-1
desc="Output mask"
)
npass = traits.Int(
argstr="-npass %d",
position=1,
desc="Number of passes"
)

class MaskFilterOutputSpec(TraitedSpec):
out_file = File(exists=True, desc="the filtered output mask")

class MaskFilter(CommandLine):
"""
Perform filtering operations on 3D / 4D mask images.
Only supports dilate / erode filters at the moment.


Example
-------

>>> import nipype.interfaces.mrtrix3 as mrt
>>> mf = mrt.MaskFilter()
>>> mf.inputs.in_file = 'mask.mif'
>>> mf.inputs.filter = 'dilate'
>>> mf.inputs.npass = 2
>>> mf.out_file = 'mask_filtered.mif'
>>> mf.cmdline
'maskfilter -npass 2 mask.mif dilate mask_filtered.mif'
>>> mf.run()
"""

_cmd = "maskfilter"
input_spec = MaskFilterInputSpec
output_spec = MaskFilterOutputSpec

def _list_outputs(self):
outputs = self.output_spec().get()
outputs = self.output_spec().get()
inputs = self.input_spec().get()
outputs["output_image"] = self._gen_filename(inputs["input_image"], suffix="_filtered")
return outputs
0