Skip to content

Commit 87cc1b5

Browse files
committed
STY: black [ignore-rev]
1 parent e5f8b87 commit 87cc1b5

File tree

15 files changed

+86
-95
lines changed

15 files changed

+86
-95
lines changed

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/interfaces/ants/registration.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,16 +1293,12 @@ def _format_arg(self, opt, spec, val):
12931293
do_center_of_mass_init,
12941294
)
12951295
elif opt == "interpolation":
1296-
if (
1297-
self.inputs.interpolation
1298-
in [
1299-
"BSpline",
1300-
"MultiLabel",
1301-
"Gaussian",
1302-
"GenericLabel",
1303-
]
1304-
and isdefined(self.inputs.interpolation_parameters)
1305-
):
1296+
if self.inputs.interpolation in [
1297+
"BSpline",
1298+
"MultiLabel",
1299+
"Gaussian",
1300+
"GenericLabel",
1301+
] and isdefined(self.inputs.interpolation_parameters):
13061302
return "--interpolation %s[ %s ]" % (
13071303
self.inputs.interpolation,
13081304
", ".join(
@@ -1595,14 +1591,17 @@ class MeasureImageSimilarity(ANTSCommand):
15951591
output_spec = MeasureImageSimilarityOutputSpec
15961592

15971593
def _metric_constructor(self):
1598-
retval = '--metric {metric}["{fixed_image}","{moving_image}",{metric_weight},' "{radius_or_number_of_bins},{sampling_strategy},{sampling_percentage}]".format(
1599-
metric=self.inputs.metric,
1600-
fixed_image=self.inputs.fixed_image,
1601-
moving_image=self.inputs.moving_image,
1602-
metric_weight=self.inputs.metric_weight,
1603-
radius_or_number_of_bins=self.inputs.radius_or_number_of_bins,
1604-
sampling_strategy=self.inputs.sampling_strategy,
1605-
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+
)
16061605
)
16071606
return retval
16081607

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/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):

nipype/interfaces/cmtk/parcellation.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,16 @@ def create_annot_label(subject_id, subjects_dir, fs_dir, parcellation_name):
303303
op.join(output_dir, "regenerated_lh_60", "lh.corpuscallosum.label"), lhco
304304
)
305305

306-
mri_cmd = """mri_label2vol --label "%s" --label "%s" --label "%s" --label "%s" --temp "%s" --o "%s" --identity """ % (
307-
rhun,
308-
lhun,
309-
rhco,
310-
lhco,
311-
op.join(op.join(subjects_dir, subject_id), "mri", "orig.mgz"),
312-
op.join(fs_label_dir, "cc_unknown.nii.gz"),
306+
mri_cmd = (
307+
"""mri_label2vol --label "%s" --label "%s" --label "%s" --label "%s" --temp "%s" --o "%s" --identity """
308+
% (
309+
rhun,
310+
lhun,
311+
rhco,
312+
lhco,
313+
op.join(op.join(subjects_dir, subject_id), "mri", "orig.mgz"),
314+
op.join(fs_label_dir, "cc_unknown.nii.gz"),
315+
)
313316
)
314317
runCmd(mri_cmd, log)
315318
runCmd("mris_volmask %s" % subject_id, log)

nipype/interfaces/freesurfer/preprocess.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,16 +1883,12 @@ def _list_outputs(self):
18831883
return outputs
18841884

18851885
def _format_arg(self, name, spec, value):
1886-
if (
1887-
name
1888-
in (
1889-
"registered_file",
1890-
"out_fsl_file",
1891-
"out_lta_file",
1892-
"init_cost_file",
1893-
)
1894-
and isinstance(value, bool)
1895-
):
1886+
if name in (
1887+
"registered_file",
1888+
"out_fsl_file",
1889+
"out_lta_file",
1890+
"init_cost_file",
1891+
) and isinstance(value, bool):
18961892
value = self._list_outputs()[name]
18971893
return super(BBRegister, self)._format_arg(name, spec, value)
18981894

nipype/interfaces/fsl/base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class Info(PackageInfo):
5151
>>> Info.version() # doctest: +SKIP
5252
>>> Info.output_type() # doctest: +SKIP
5353
54-
5554
"""
5655

5756
ftypes = {

nipype/interfaces/niftyseg/label_fusion.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -168,19 +168,15 @@ class LabelFusion(NiftySegCommand):
168168
def _format_arg(self, opt, spec, val):
169169
"""Convert input to appropriate format for seg_maths."""
170170
# Remove options if not STAPLE or STEPS as fusion type:
171-
if (
172-
opt
173-
in [
174-
"proportion",
175-
"prob_update_flag",
176-
"set_pq",
177-
"mrf_value",
178-
"max_iter",
179-
"unc_thresh",
180-
"conv",
181-
]
182-
and self.inputs.classifier_type not in ["STAPLE", "STEPS"]
183-
):
171+
if opt in [
172+
"proportion",
173+
"prob_update_flag",
174+
"set_pq",
175+
"mrf_value",
176+
"max_iter",
177+
"unc_thresh",
178+
"conv",
179+
] and self.inputs.classifier_type not in ["STAPLE", "STEPS"]:
184180
return ""
185181

186182
if opt == "sm_ranking":

nipype/interfaces/slicer/generate_classes.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -367,18 +367,14 @@ def generate_class(
367367
param.getElementsByTagName("channel")[0].firstChild.nodeValue
368368
== "input"
369369
):
370-
if (
371-
param.nodeName
372-
in [
373-
"file",
374-
"directory",
375-
"image",
376-
"geometry",
377-
"transform",
378-
"table",
379-
]
380-
and type not in ["InputMultiPath", "traits.List"]
381-
):
370+
if param.nodeName in [
371+
"file",
372+
"directory",
373+
"image",
374+
"geometry",
375+
"transform",
376+
"table",
377+
] and type not in ["InputMultiPath", "traits.List"]:
382378
traitsParams["exists"] = True
383379
inputTraits.append(
384380
"%s = %s(%s%s)"

nipype/pipeline/engine/tests/test_join.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ def test_name_prefix_join(tmpdir):
623623
tmpdir.chdir()
624624

625625
def sq(x):
626-
return x ** 2
626+
return x**2
627627

628628
wf = pe.Workflow("wf", base_dir=tmpdir.strpath)
629629
square = pe.Node(Function(function=sq), name="square")
@@ -642,7 +642,7 @@ def test_join_nestediters(tmpdir):
642642
tmpdir.chdir()
643643

644644
def exponent(x, p):
645-
return x ** p
645+
return x**p
646646

647647
wf = pe.Workflow("wf", base_dir=tmpdir.strpath)
648648

nipype/utils/profiler.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
resource_monitor = config.resource_monitor
2222

2323
# Init variables
24-
_MB = 1024.0 ** 2
24+
_MB = 1024.0**2
2525

2626

2727
class ResourceMonitorMock:
@@ -207,10 +207,10 @@ def get_system_total_memory_gb():
207207
meminfo_lines = f_in.readlines()
208208
mem_total_line = [line for line in meminfo_lines if "MemTotal" in line][0]
209209
mem_total = float(mem_total_line.split()[1])
210-
memory_gb = mem_total / (1024.0 ** 2)
210+
memory_gb = mem_total / (1024.0**2)
211211
elif "darwin" in sys.platform:
212212
mem_str = os.popen("sysctl hw.memsize").read().strip().split(" ")[-1]
213-
memory_gb = float(mem_str) / (1024.0 ** 3)
213+
memory_gb = float(mem_str) / (1024.0**3)
214214
else:
215215
err_msg = "System platform: %s is not supported"
216216
raise Exception(err_msg)
@@ -387,7 +387,7 @@ def _use_resources(n_procs, mem_gb):
387387
# Getsize of one character string
388388
BSIZE = sys.getsizeof(" ") - sys.getsizeof(" ")
389389
BOFFSET = sys.getsizeof("")
390-
_GB = 1024.0 ** 3
390+
_GB = 1024.0**3
391391

392392
def _use_gb_ram(mem_gb):
393393
"""A test function to consume mem_gb GB of RAM"""

nipype/utils/tests/test_functions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55

66
def _func1(x):
7-
return x ** 3
7+
return x**3
88

99

1010
def test_func_to_str():
1111
def func1(x):
12-
return x ** 2
12+
return x**2
1313

1414
# Should be ok with both functions!
1515
for f in _func1, func1:

0 commit comments

Comments
 (0)