Skip to content

Commit 281b236

Browse files
committed
Merge remote-tracking branch 'upstream/master' into loadbidslayout
2 parents 2ba8dac + e31573b commit 281b236

30 files changed

+339
-123
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ jobs:
2626
runs-on: ${{ matrix.os }}
2727
strategy:
2828
matrix:
29-
os: ['ubuntu-18.04']
30-
python-version: [3.6, 3.7, 3.8, 3.9]
29+
os: ['ubuntu-latest']
30+
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]
3131
check: ['test']
3232
pip-flags: ['']
3333
depends: ['REQUIREMENTS']

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ Kshitij Chawla <[email protected]>
121121
Leonie Lampe <[email protected]>
122122
Lukas Snoek <[email protected]>
123123
124+
Maria de Fatima Dias <[email protected]> <[email protected]>
124125
Martin Perez-Guevara <[email protected]>
125126
126127

.zenodo.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@
263263
},
264264
{
265265
"affiliation": "CIBIT, UC",
266-
"name": "Machado, F\u00e1tima",
266+
"name": "Dias, Maria de Fatima",
267267
"orcid": "0000-0001-8878-1750"
268268
},
269269
{
@@ -439,7 +439,8 @@
439439
},
440440
{
441441
"affiliation": "Sagol School of Neuroscience, Tel Aviv University",
442-
"name": "Baratz, Zvi"
442+
"name": "Baratz, Zvi",
443+
"orcid": "0000-0001-7159-1387"
443444
},
444445
{
445446
"affiliation": "University of Iowa",

nipype/algorithms/confounds.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1435,7 +1435,7 @@ def compute_noise_components(
14351435
else:
14361436
u = np.full((M.shape[0], 1), np.nan, dtype=np.float32)
14371437

1438-
variance_explained = (s ** 2) / np.sum(s ** 2)
1438+
variance_explained = (s**2) / np.sum(s**2)
14391439
cumulative_variance_explained = np.cumsum(variance_explained)
14401440

14411441
num_components = int(components_criterion)

nipype/algorithms/icc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def ICC_rep_anova(Y):
116116
# Sum Square Error
117117
predicted_Y = dot(dot(dot(X, pinv(dot(X.T, X))), X.T), Y.flatten("F"))
118118
residuals = Y.flatten("F") - predicted_Y
119-
SSE = (residuals ** 2).sum()
119+
SSE = (residuals**2).sum()
120120

121121
residuals.shape = Y.shape
122122

nipype/algorithms/metrics.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ def _run_interface(self, runtime):
337337
if self.inputs.weighting != "none":
338338
weights = weights / np.array(volumes1)
339339
if self.inputs.weighting == "squared_vol":
340-
weights = weights ** 2
340+
weights = weights**2
341341
weights = weights / np.sum(weights)
342342

343343
both_data = np.zeros(data1.shape)
@@ -500,7 +500,7 @@ def _run_interface(self, runtime):
500500
volumes = np.sum((refdata + tstdata) > 0, axis=1).reshape((-1, ncomp))
501501
weights = 1.0 / volumes
502502
if self.inputs.weighting == "squared_vol":
503-
weights = weights ** 2
503+
weights = weights**2
504504

505505
weights = weights / np.sum(weights)
506506
dices = 2.0 * jaccards / (jaccards + 1.0)
@@ -591,7 +591,7 @@ def _run_interface(self, runtime):
591591

592592
# Scale the difference
593593
if self.inputs.metric == "sqeuclidean":
594-
errvector = diffvector ** 2
594+
errvector = diffvector**2
595595
if comps > 1:
596596
errvector = np.sum(errvector, axis=1)
597597
else:

nipype/algorithms/tests/test_ErrorMap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,4 @@ def test_errormap(tmpdir):
7575

7676
errmap.inputs.metric = "euclidean"
7777
result = errmap.run()
78-
assert result.outputs.distance == np.float32(1.25 * (2 ** 0.5))
78+
assert result.outputs.distance == np.float32(1.25 * (2**0.5))

nipype/info.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ def get_nipype_gitversion():
5757
"Programming Language :: Python :: 3.6",
5858
"Programming Language :: Python :: 3.7",
5959
"Programming Language :: Python :: 3.8",
60+
"Programming Language :: Python :: 3.9",
61+
"Programming Language :: Python :: 3.10",
6062
"Topic :: Scientific/Engineering",
6163
]
6264
PYTHON_REQUIRES = ">= 3.6"
@@ -169,7 +171,6 @@ def get_nipype_gitversion():
169171
"sphinx-argparse",
170172
"sphinx>=2.1.2",
171173
"sphinxcontrib-apidoc",
172-
"sphinxcontrib-napoleon",
173174
],
174175
"duecredit": ["duecredit"],
175176
"nipy": ["nitime", "nilearn", "dipy", "nipy", "matplotlib"],

nipype/interfaces/ants/registration.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ class RegistrationInputSpec(ANTSCommandInputSpec):
418418
"BSpline",
419419
"MultiLabel",
420420
"Gaussian",
421+
"GenericLabel",
421422
argstr="%s",
422423
usedefault=True,
423424
)
@@ -426,6 +427,7 @@ class RegistrationInputSpec(ANTSCommandInputSpec):
426427
traits.Tuple(
427428
traits.Float(), traits.Float() # Gaussian/MultiLabel (sigma, alpha)
428429
),
430+
traits.Tuple(traits.Str()), # GenericLabel (interpolator)
429431
)
430432

431433
write_composite_transform = traits.Bool(
@@ -1291,15 +1293,12 @@ def _format_arg(self, opt, spec, val):
12911293
do_center_of_mass_init,
12921294
)
12931295
elif opt == "interpolation":
1294-
if (
1295-
self.inputs.interpolation
1296-
in [
1297-
"BSpline",
1298-
"MultiLabel",
1299-
"Gaussian",
1300-
]
1301-
and isdefined(self.inputs.interpolation_parameters)
1302-
):
1296+
if self.inputs.interpolation in [
1297+
"BSpline",
1298+
"MultiLabel",
1299+
"Gaussian",
1300+
"GenericLabel",
1301+
] and isdefined(self.inputs.interpolation_parameters):
13031302
return "--interpolation %s[ %s ]" % (
13041303
self.inputs.interpolation,
13051304
", ".join(
@@ -1592,14 +1591,17 @@ class MeasureImageSimilarity(ANTSCommand):
15921591
output_spec = MeasureImageSimilarityOutputSpec
15931592

15941593
def _metric_constructor(self):
1595-
retval = '--metric {metric}["{fixed_image}","{moving_image}",{metric_weight},' "{radius_or_number_of_bins},{sampling_strategy},{sampling_percentage}]".format(
1596-
metric=self.inputs.metric,
1597-
fixed_image=self.inputs.fixed_image,
1598-
moving_image=self.inputs.moving_image,
1599-
metric_weight=self.inputs.metric_weight,
1600-
radius_or_number_of_bins=self.inputs.radius_or_number_of_bins,
1601-
sampling_strategy=self.inputs.sampling_strategy,
1602-
sampling_percentage=self.inputs.sampling_percentage,
1594+
retval = (
1595+
'--metric {metric}["{fixed_image}","{moving_image}",{metric_weight},'
1596+
"{radius_or_number_of_bins},{sampling_strategy},{sampling_percentage}]".format(
1597+
metric=self.inputs.metric,
1598+
fixed_image=self.inputs.fixed_image,
1599+
moving_image=self.inputs.moving_image,
1600+
metric_weight=self.inputs.metric_weight,
1601+
radius_or_number_of_bins=self.inputs.radius_or_number_of_bins,
1602+
sampling_strategy=self.inputs.sampling_strategy,
1603+
sampling_percentage=self.inputs.sampling_percentage,
1604+
)
16031605
)
16041606
return retval
16051607

nipype/interfaces/ants/resampling.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -504,15 +504,11 @@ def _format_arg(self, opt, spec, val):
504504
elif opt == "transforms":
505505
return self._get_transform_filenames()
506506
elif opt == "interpolation":
507-
if (
508-
self.inputs.interpolation
509-
in [
510-
"BSpline",
511-
"MultiLabel",
512-
"Gaussian",
513-
]
514-
and isdefined(self.inputs.interpolation_parameters)
515-
):
507+
if self.inputs.interpolation in [
508+
"BSpline",
509+
"MultiLabel",
510+
"Gaussian",
511+
] and isdefined(self.inputs.interpolation_parameters):
516512
return "--interpolation %s[ %s ]" % (
517513
self.inputs.interpolation,
518514
", ".join(

nipype/interfaces/ants/tests/test_auto_ImageMath.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ def test_ImageMath_inputs():
66
input_map = dict(
77
args=dict(
88
argstr="%s",
9+
position=-1,
910
),
1011
copy_header=dict(
1112
usedefault=True,
@@ -27,11 +28,11 @@ def test_ImageMath_inputs():
2728
argstr="%s",
2829
extensions=None,
2930
mandatory=True,
30-
position=-2,
31+
position=-3,
3132
),
3233
op2=dict(
3334
argstr="%s",
34-
position=-1,
35+
position=-2,
3536
),
3637
operation=dict(
3738
argstr="%s",

nipype/interfaces/ants/utils.py

Lines changed: 74 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class ImageMathInputSpec(ANTSCommandInputSpec):
1919
keep_extension=True,
2020
)
2121
operation = traits.Enum(
22+
# Mathematical Operations
2223
"m",
2324
"vm",
2425
"+",
@@ -37,6 +38,7 @@ class ImageMathInputSpec(ANTSCommandInputSpec):
3738
"vtotal",
3839
"Decision",
3940
"Neg",
41+
# Spatial Filtering Operations
4042
"Project",
4143
"G",
4244
"MD",
@@ -47,22 +49,72 @@ class ImageMathInputSpec(ANTSCommandInputSpec):
4749
"GE",
4850
"GO",
4951
"GC",
50-
"TruncateImageIntensity",
51-
"Laplacian",
52-
"GetLargestComponent",
52+
"ExtractContours",
53+
# Transform Image Operations
54+
"Translate",
55+
# Tensor Operations
56+
"4DTensorTo3DTensor",
57+
"ExtractVectorComponent",
58+
"TensorColor",
59+
"TensorFA",
60+
"TensorFADenominator",
61+
"TensorFANumerator",
62+
"TensorMeanDiffusion",
63+
"TensorRadialDiffusion",
64+
"TensorAxialDiffusion",
65+
"TensorEigenvalue",
66+
"TensorToVector",
67+
"TensorToVectorComponent",
68+
"TensorMask",
69+
# Unclassified Operators
70+
"Byte",
71+
"CorruptImage",
72+
"D",
73+
"MaurerDistance",
74+
"ExtractSlice",
5375
"FillHoles",
76+
"Convolve",
77+
"Finite",
78+
"FlattenImage",
79+
"GetLargestComponent",
80+
"Grad",
81+
"RescaleImage",
82+
"WindowImage",
83+
"NeighborhoodStats",
84+
"ReplicateDisplacement",
85+
"ReplicateImage",
86+
"LabelStats",
87+
"Laplacian",
88+
"Canny",
89+
"Lipschitz",
90+
"MTR",
91+
"Normalize",
5492
"PadImage",
93+
"SigmoidImage",
94+
"Sharpen",
95+
"UnsharpMask",
96+
"PValueImage",
97+
"ReplaceVoxelValue",
98+
"SetTimeSpacing",
99+
"SetTimeSpacingWarp",
100+
"stack",
101+
"ThresholdAtMean",
102+
"TriPlanarView",
103+
"TruncateImageIntensity",
55104
mandatory=True,
56105
position=3,
57106
argstr="%s",
58107
desc="mathematical operations",
59108
)
60109
op1 = File(
61-
exists=True, mandatory=True, position=-2, argstr="%s", desc="first operator"
110+
exists=True, mandatory=True, position=-3, argstr="%s", desc="first operator"
62111
)
63112
op2 = traits.Either(
64-
File(exists=True), Str, position=-1, argstr="%s", desc="second operator"
113+
File(exists=True), Str, position=-2, argstr="%s", desc="second operator"
65114
)
115+
116+
args = Str(position=-1, argstr="%s", desc="Additional parameters to the command")
117+
66118
copy_header = traits.Bool(
67119
True,
68120
usedefault=True,
@@ -106,7 +158,7 @@ class ImageMath(ANTSCommand, CopyHeaderInterface):
106158
107159
By default, Nipype copies headers from the first input image (``op1``)
108160
to the output image.
109-
For the ``PadImage`` operation, the header cannot be copied from inputs to
161+
For some operations, as the ``PadImage`` operation, the header cannot be copied from inputs to
110162
outputs, and so ``copy_header`` option is automatically set to ``False``.
111163
112164
>>> pad = ImageMath(
@@ -135,22 +187,34 @@ class ImageMath(ANTSCommand, CopyHeaderInterface):
135187
input_spec = ImageMathInputSpec
136188
output_spec = ImageMathOuputSpec
137189
_copy_header_map = {"output_image": "op1"}
190+
_no_copy_header_operation = (
191+
"PadImage",
192+
"LabelStats",
193+
"SetTimeSpacing",
194+
"SetTimeSpacingWarp",
195+
"TriPlanarView",
196+
)
138197

139198
def __init__(self, **inputs):
140199
super(ImageMath, self).__init__(**inputs)
141-
if self.inputs.operation in ("PadImage",):
200+
if self.inputs.operation in self._no_copy_header_operation:
142201
self.inputs.copy_header = False
143202

144203
self.inputs.on_trait_change(self._operation_update, "operation")
145204
self.inputs.on_trait_change(self._copyheader_update, "copy_header")
146205

147206
def _operation_update(self):
148-
if self.inputs.operation in ("PadImage",):
207+
if self.inputs.operation in self._no_copy_header_operation:
149208
self.inputs.copy_header = False
150209

151210
def _copyheader_update(self):
152-
if self.inputs.copy_header and self.inputs.operation in ("PadImage",):
153-
warn("copy_header cannot be updated to True with PadImage as operation.")
211+
if (
212+
self.inputs.copy_header
213+
and self.inputs.operation in self._no_copy_header_operation
214+
):
215+
warn(
216+
f"copy_header cannot be updated to True with {self.inputs.operation} as operation."
217+
)
154218
self.inputs.copy_header = False
155219

156220

nipype/interfaces/brainsuite/brainsuite.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,15 @@ def _format_arg(self, name, spec, value):
260260
% {"low": "--low", "medium": "--medium", "high": "--high"}[value]
261261
)
262262
if name == "intermediate_file_type":
263-
return spec.argstr % {
264-
"analyze": "--analyze",
265-
"nifti": "--nifti",
266-
"gzippedAnalyze": "--analyzegz",
267-
"gzippedNifti": "--niftigz",
268-
}[value]
263+
return (
264+
spec.argstr
265+
% {
266+
"analyze": "--analyze",
267+
"nifti": "--nifti",
268+
"gzippedAnalyze": "--analyzegz",
269+
"gzippedNifti": "--niftigz",
270+
}[value]
271+
)
269272

270273
return super(Bfc, self)._format_arg(name, spec, value)
271274

@@ -772,11 +775,14 @@ def _format_arg(self, name, spec, value):
772775
return "" # blank argstr
773776
if name == "specialTessellation":
774777
threshold = self.inputs.tessellationThreshold
775-
return spec.argstr % {
776-
"greater_than": "".join(("-gt %f" % threshold)),
777-
"less_than": "".join(("-lt %f" % threshold)),
778-
"equal_to": "".join(("-eq %f" % threshold)),
779-
}[value]
778+
return (
779+
spec.argstr
780+
% {
781+
"greater_than": "".join(("-gt %f" % threshold)),
782+
"less_than": "".join(("-lt %f" % threshold)),
783+
"equal_to": "".join(("-eq %f" % threshold)),
784+
}[value]
785+
)
780786
return super(Dfs, self)._format_arg(name, spec, value)
781787

782788
def _gen_filename(self, name):

0 commit comments

Comments
 (0)