Skip to content

ENH: ROBEX interface #3443

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 11 commits into from
Apr 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ Kshitij Chawla <[email protected]>
Leonie Lampe <[email protected]>
Lukas Snoek <[email protected]>
Marcel Falkiewicz <[email protected]> <[email protected]>
Maria de Fatima Dias <[email protected]> <[email protected]>
Martin Perez-Guevara <[email protected]>
Mathias Goncalves <[email protected]> <[email protected]>
Mathias Goncalves <[email protected]> <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@
},
{
"affiliation": "CIBIT, UC",
"name": "Machado, F\u00e1tima",
"name": "Dias, Maria de Fatima",
"orcid": "0000-0001-8878-1750"
},
{
Expand Down
Empty file.
69 changes: 69 additions & 0 deletions nipype/interfaces/robex/preprocess.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import os
from pathlib import Path

from nipype.interfaces.base import (
TraitedSpec,
CommandLineInputSpec,
CommandLine,
File,
traits,
isdefined,
)
from nipype.utils.filemanip import split_filename


class RobexInputSpec(CommandLineInputSpec):
in_file = File(
desc="Input volume", exists=True, mandatory=True, position=0, argstr="%s"
)
out_file = File(
desc="Output volume",
position=1,
argstr="%s",
hash_files=False,
name_template='%s_brain',
name_source=["in_file"],
keep_extension=True,
)
out_mask = File(
desc="Output mask",
position=2,
argstr="%s",
hash_files=False,
name_template='%s_brainmask',
name_source=["in_file"],
keep_extension=True,
)
seed = traits.Int(desc="Seed for random number generator", position=3, argstr="%i")


class RobexOutputSpec(TraitedSpec):
out_file = File(desc="Output volume")
out_mask = File(desc="Output mask")


class RobexSegment(CommandLine):
"""

ROBEX is an automatic whole-brain extraction tool for T1-weighted MRI data (commonly known as skull stripping).
ROBEX aims for robust skull-stripping across datasets with no parameter settings. It fits a triangular mesh,
constrained by a shape model, to the probabilistic output of a supervised brain boundary classifier.
Because the shape model cannot perfectly accommodate unseen cases, a small free deformation is subsequently allowed.
The deformation is optimized using graph cuts.
The method ROBEX is based on was published in IEEE Transactions on Medical Imaging;
please visit the website http://www.jeiglesias.com to download the paper.

Examples
--------
>>> from nipype.interfaces.robex.preprocess import RobexSegment
>>> robex = RobexSegment()
>>> robex.inputs.in_file = 'structural.nii'
>>> robex.cmdline
'runROBEX.sh structural.nii structural_brain.nii structural_brainmask.nii'
>>> robex.run() # doctest: +SKIP

"""

input_spec = RobexInputSpec
output_spec = RobexOutputSpec
_cmd = 'runROBEX.sh'
Empty file.
63 changes: 63 additions & 0 deletions nipype/interfaces/robex/tests/test_auto_RobexSegment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
from ..preprocess import RobexSegment


def test_RobexSegment_inputs():
input_map = dict(
args=dict(
argstr="%s",
),
environ=dict(
nohash=True,
usedefault=True,
),
in_file=dict(
argstr="%s",
extensions=None,
mandatory=True,
position=0,
),
out_file=dict(
argstr="%s",
extensions=None,
hash_files=False,
keep_extension=True,
name_source=["in_file"],
name_template="%s_brain",
position=1,
),
out_mask=dict(
argstr="%s",
extensions=None,
hash_files=False,
keep_extension=True,
name_source=["in_file"],
name_template="%s_brainmask",
position=2,
),
seed=dict(
argstr="%i",
position=3,
),
)
inputs = RobexSegment.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_RobexSegment_outputs():
output_map = dict(
out_file=dict(
extensions=None,
),
out_mask=dict(
extensions=None,
),
)
outputs = RobexSegment.output_spec()

for key, metadata in list(output_map.items()):
for metakey, value in list(metadata.items()):
assert getattr(outputs.traits()[key], metakey) == value