Skip to content

Commit 815b944

Browse files
committed
ENH: CiftiDilate interface
1 parent 3572d71 commit 815b944

File tree

1 file changed

+133
-0
lines changed

1 file changed

+133
-0
lines changed

nibabies/interfaces/workbench.py

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
from nipype.interfaces.base import CommandLineInputSpec, File, traits, TraitedSpec
2+
from nipype.interfaces.workbench.base import WBCommand
3+
4+
5+
class CiftiDilateInputSpec(CommandLineInputSpec):
6+
in_file = File(
7+
exists=True,
8+
mandatory=True,
9+
argstr="%s",
10+
position=0,
11+
desc="The input CIFTI file",
12+
)
13+
direction = traits.Enum(
14+
"ROW",
15+
"COLUMN",
16+
mandatory=True,
17+
position=1,
18+
desc="Which dimension to dilate along, ROW or COLUMN",
19+
)
20+
surface_distance = traits.Int(
21+
mandatory=True,
22+
position=2,
23+
desc="The distance to dilate on surfaces, in mm",
24+
)
25+
volume_distance = traits.Int(
26+
mandatory=True,
27+
position=3,
28+
desc="The distance to dilate in the volume, in mm",
29+
)
30+
out_file = File(
31+
name_source=["in_file"],
32+
name_template="dilated_%s.nii",
33+
keep_extension=True,
34+
argstr="%s",
35+
position=4,
36+
desc="The dilated CIFTI file",
37+
)
38+
left_surface = File(
39+
exists=True,
40+
mandatory=True,
41+
position=5,
42+
argstr="-left-surface %s",
43+
desc="Specify the left surface to use",
44+
)
45+
left_corrected_areas = File(
46+
exists=True,
47+
position=6,
48+
requires=["left_surface"],
49+
argstr="-left-corrected-areas %s",
50+
desc="vertex areas (as a metric) to use instead of computing them from the left surface.",
51+
)
52+
right_surface = File(
53+
exists=True,
54+
mandatory=True,
55+
position=7,
56+
argstr="-right-surface %s",
57+
desc="Specify the right surface to use",
58+
)
59+
right_corrected_areas = File(
60+
exists=True,
61+
position=8,
62+
requires=["right_surface"],
63+
argstr="-right-corrected-areas %s",
64+
desc="vertex areas (as a metric) to use instead of computing them from the right surface",
65+
)
66+
cerebellum_surface = File(
67+
exists=True,
68+
position=9,
69+
argstr="-cerebellum-surface %s",
70+
desc="specify the cerebellum surface to use",
71+
)
72+
cerebellum_corrected_areas = File(
73+
exists=True,
74+
position=10,
75+
requires=["cerebellum_surf"],
76+
argstr="-cerebellum-corrected-areas %s",
77+
desc="vertex areas (as a metric) to use instead of computing them from the cerebellum "
78+
"surface",
79+
)
80+
bad_brainordinate_roi = File(
81+
exists=True,
82+
position=11,
83+
argstr="-bad-brainordinate-roi %s",
84+
desc="CIFTI dscalar or dtseries file, positive values denote brainordinates to have their "
85+
"values replaced",
86+
)
87+
nearest = traits.Bool(
88+
position=12,
89+
argstr="-nearest",
90+
desc="Use nearest good value instead of a weighted average",
91+
)
92+
merged_volume = traits.Bool(
93+
position=13,
94+
argstr="-merged-volume",
95+
desc="treat volume components as if they were a single component",
96+
)
97+
legacy_mode = traits.Bool(
98+
position=14,
99+
argstr="-legacy-mode",
100+
desc="Use the math from v1.3.2 and earlier for weighted dilation",
101+
)
102+
103+
104+
class CiftiDilateOutputSpec(TraitedSpec):
105+
out_file = File(exists=True, desc="Dilated CIFTI file")
106+
107+
108+
class CiftiDilate(WBCommand):
109+
"""
110+
Dilate a CIFTI file.
111+
112+
For all data values designated as bad, if they neighbor a good value or
113+
are within the specified distance of a good value in the same kind of
114+
model, replace the value with a distance weighted average of nearby good
115+
values, otherwise set the value to zero. If -nearest is specified, it
116+
will use the value from the closest good value within range instead of a
117+
weighted average. When the input file contains label data, nearest
118+
dilation is used on the surface, and weighted popularity is used in the
119+
volume.
120+
121+
The -*-corrected-areas options are intended for dilating on group average
122+
surfaces, but it is only an approximate correction for the reduction of
123+
structure in a group average surface.
124+
125+
If -bad-brainordinate-roi is specified, all values, including those with
126+
value zero, are good, except for locations with a positive value in the
127+
ROI. If it is not specified, only values equal to zero are bad.
128+
129+
"""
130+
131+
input_spec = CiftiDilateInputSpec
132+
output_spec = CiftiDilateOutputSpec
133+
_cmd = "wb_command -cifti-dilate"

0 commit comments

Comments
 (0)