Skip to content

LINT: Black edits #1

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 1 commit into from
Mar 24, 2023
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
17 changes: 11 additions & 6 deletions doc/devel/matlab_example1.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from nipype.interfaces.matlab import MatlabCommand
from nipype.interfaces.base import TraitedSpec, \
BaseInterface, BaseInterfaceInputSpec, File
from nipype.interfaces.base import (
TraitedSpec,
BaseInterface,
BaseInterfaceInputSpec,
File,
)
import os
from string import Template

Expand All @@ -19,14 +23,15 @@ class ConmapTxt2Mat(BaseInterface):
output_spec = ConmapTxt2MatOutputSpec

def _run_interface(self, runtime):
d = dict(in_file=self.inputs.in_file,
out_file=self.inputs.out_file)
d = dict(in_file=self.inputs.in_file, out_file=self.inputs.out_file)
# This is your MATLAB code template
script = Template("""in_file = '$in_file';
script = Template(
"""in_file = '$in_file';
out_file = '$out_file';
ConmapTxt2Mat(in_file, out_file);
exit;
""").substitute(d)
"""
).substitute(d)

# mfile = True will create an .m file with your script and executed.
# Alternatively
Expand Down
8 changes: 5 additions & 3 deletions doc/devel/matlab_example2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@


class HelloWorldInputSpec(MatlabInputSpec):
name = traits.Str(mandatory=True,
desc='Name of person to say hello to')
name = traits.Str(mandatory=True, desc='Name of person to say hello to')


class HelloWorldOutputSpec(TraitedSpec):
Expand All @@ -29,6 +28,7 @@ class HelloWorld(MatlabCommand):
>>> out = hello.run()
>>> print out.outputs.matlab_output
"""

input_spec = HelloWorldInputSpec
output_spec = HelloWorldOutputSpec

Expand All @@ -37,7 +37,9 @@ def _my_script(self):
script = """
disp('Hello %s Python')
two = 1 + 1
""" % (self.inputs.name)
""" % (
self.inputs.name
)
return script

def run(self, **inputs):
Expand Down
1 change: 0 additions & 1 deletion nipype/algorithms/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,6 @@ class CalculateNormalizedMoments(BaseInterface):
output_spec = CalculateNormalizedMomentsOutputSpec

def _run_interface(self, runtime):

self._moments = calc_moments(self.inputs.timeseries_file, self.inputs.moment)
return runtime

Expand Down
1 change: 0 additions & 1 deletion nipype/algorithms/tests/test_ErrorMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


def test_errormap(tmpdir):

# Single-Spectual
# Make two fake 2*2*2 voxel volumes
# John von Neumann's birthday
Expand Down
2 changes: 0 additions & 2 deletions nipype/algorithms/tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@


def test_CreateNifti(create_analyze_pair_file_in_directory):

filelist, outdir = create_analyze_pair_file_in_directory

create_nifti = misc.CreateNifti()
Expand All @@ -35,7 +34,6 @@ def test_CreateNifti(create_analyze_pair_file_in_directory):


def test_CalculateMedian(create_analyze_pair_file_in_directory):

mean = misc.CalculateMedian()

with pytest.raises(TypeError):
Expand Down
1 change: 0 additions & 1 deletion nipype/algorithms/tests/test_normalize_tpms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@


def test_normalize_tpms(tmpdir):

in_mask = example_data("tpms_msk.nii.gz")
mskdata = np.asanyarray(nb.load(in_mask).dataobj)
mskdata[mskdata > 0.0] = 1.0
Expand Down
1 change: 0 additions & 1 deletion nipype/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def _docdir(request):
# Trigger ONLY for the doctests.
doctest_plugin = request.config.pluginmanager.getplugin("doctest")
if isinstance(request.node, doctest_plugin.DoctestItem):

# Get the fixture dynamically by its name.
tmpdir = pp.local(data_dir)

Expand Down
4 changes: 3 additions & 1 deletion nipype/external/cloghandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ def __init__(
)
try:
BaseRotatingHandler.__init__(self, filename, mode, encoding)
except TypeError: # Due to a different logging release without encoding support (Python 2.4.1 and earlier?)
except (
TypeError
): # Due to a different logging release without encoding support (Python 2.4.1 and earlier?)
BaseRotatingHandler.__init__(self, filename, mode)
self.encoding = encoding

Expand Down
2 changes: 0 additions & 2 deletions nipype/interfaces/afni/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,6 @@ class ClipLevel(AFNICommandBase):
output_spec = ClipLevelOutputSpec

def aggregate_outputs(self, runtime=None, needed_outputs=None):

outputs = self._outputs()

outfile = os.path.join(os.getcwd(), "stat_result.json")
Expand Down Expand Up @@ -2295,7 +2294,6 @@ class Seg(AFNICommandBase):
output_spec = AFNICommandOutputSpec

def aggregate_outputs(self, runtime=None, needed_outputs=None):

import glob

outputs = self._outputs()
Expand Down
2 changes: 0 additions & 2 deletions nipype/interfaces/afni/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ class BrickStat(AFNICommandBase):
output_spec = BrickStatOutputSpec

def aggregate_outputs(self, runtime=None, needed_outputs=None):

outputs = self._outputs()

outfile = os.path.join(os.getcwd(), "stat_result.json")
Expand Down Expand Up @@ -2595,7 +2594,6 @@ def _format_arg(self, name, spec, value):


class ResampleInputSpec(AFNICommandInputSpec):

in_file = File(
desc="input file to 3dresample",
argstr="-inset %s",
Expand Down
1 change: 0 additions & 1 deletion nipype/interfaces/base/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ def run(self, cwd=None, ignore_exception=None, **inputs):
self._check_version_requirements(self.inputs)

with rtc(self, cwd=cwd, redirect_x=self._redirect_x) as runtime:

# Grab inputs now, as they should not change during execution
inputs = self.inputs.get_traitsfree()
outputs = None
Expand Down
1 change: 0 additions & 1 deletion nipype/interfaces/base/traits_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,6 @@ class MultiObject(traits.List):
"""Abstract class - shared functionality of input and output MultiObject"""

def validate(self, objekt, name, value):

# want to treat range and other sequences (except str) as list
if not isinstance(value, (str, bytes)) and isinstance(value, Sequence):
value = list(value)
Expand Down
1 change: 0 additions & 1 deletion nipype/interfaces/brainsuite/brainsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@


class BseInputSpec(CommandLineInputSpec):

inputMRIFile = File(mandatory=True, argstr="-i %s", desc="input MRI volume")
outputMRIVolume = File(
desc="output brain-masked MRI volume. If unspecified, output file name will be auto generated.",
Expand Down
3 changes: 0 additions & 3 deletions nipype/interfaces/cat12/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,6 @@ def _list_outputs(self):
]

for tidx, tissue in enumerate(["gm", "wm", "csf"]):

for image, prefix in [("modulated", "mw"), ("dartel", "r"), ("native", "")]:
outtype = f"{tissue}_output_{image}"
if isdefined(getattr(self.inputs, outtype)) and getattr(
Expand Down Expand Up @@ -594,7 +593,6 @@ def _list_outputs(self):


class CAT12SANLMDenoisingInputSpec(SPMCommandInputSpec):

in_files = InputMultiPath(
ImageFileSPM(exists=True),
field="data",
Expand Down Expand Up @@ -679,7 +677,6 @@ class CAT12SANLMDenoisingInputSpec(SPMCommandInputSpec):


class CAT12SANLMDenoisingOutputSpec(TraitedSpec):

out_file = File(desc="out file")


Expand Down
1 change: 0 additions & 1 deletion nipype/interfaces/cmtk/cmtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ def cmat(

dis = 0
for i in range(endpoints.shape[0]):

# ROI start => ROI end
try:
startROI = int(
Expand Down
1 change: 0 additions & 1 deletion nipype/interfaces/freesurfer/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ class GLMFitInputSpec(FSTraitedSpec):


class GLMFitOutputSpec(TraitedSpec):

glm_dir = Directory(exists=True, desc="output directory")
beta_file = File(exists=True, desc="map of regression coefficients")
error_file = File(desc="map of residual error")
Expand Down
3 changes: 0 additions & 3 deletions nipype/interfaces/freesurfer/petsurfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@


class GTMSegInputSpec(FSTraitedSpec):

subject_id = traits.String(argstr="--s %s", desc="subject id", mandatory=True)

xcerseg = traits.Bool(
Expand Down Expand Up @@ -136,7 +135,6 @@ def _list_outputs(self):


class GTMPVCInputSpec(FSTraitedSpec):

in_file = File(
exists=True,
argstr="--i %s",
Expand Down Expand Up @@ -422,7 +420,6 @@ class GTMPVCInputSpec(FSTraitedSpec):


class GTMPVCOutputSpec(TraitedSpec):

pvc_dir = Directory(desc="output directory")
ref_file = File(desc="Reference TAC in .dat")
hb_nifti = File(desc="High-binding TAC in nifti")
Expand Down
8 changes: 0 additions & 8 deletions nipype/interfaces/freesurfer/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -1833,7 +1833,6 @@ class BBRegister(FSCommand):
output_spec = BBRegisterOutputSpec

def _list_outputs(self):

outputs = self.output_spec().get()
_in = self.inputs

Expand Down Expand Up @@ -1893,7 +1892,6 @@ def _format_arg(self, name, spec, value):
return super(BBRegister, self)._format_arg(name, spec, value)

def _gen_filename(self, name):

if name == "out_reg_file":
return self._list_outputs()[name]
return None
Expand Down Expand Up @@ -2180,7 +2178,6 @@ def _gen_filename(self, name):


class RobustRegisterInputSpec(FSTraitedSpec):

source_file = File(
exists=True, mandatory=True, argstr="--mov %s", desc="volume to be registered"
)
Expand Down Expand Up @@ -2302,7 +2299,6 @@ class RobustRegisterInputSpec(FSTraitedSpec):


class RobustRegisterOutputSpec(TraitedSpec):

out_reg_file = File(exists=True, desc="output registration file")
registered_file = File(exists=True, desc="output image with registration applied")
weights_file = File(exists=True, desc="image of weights used")
Expand Down Expand Up @@ -2388,7 +2384,6 @@ def _list_outputs(self):


class FitMSParamsInputSpec(FSTraitedSpec):

in_files = traits.List(
File(exists=True),
argstr="%s",
Expand All @@ -2408,7 +2403,6 @@ class FitMSParamsInputSpec(FSTraitedSpec):


class FitMSParamsOutputSpec(TraitedSpec):

t1_image = File(exists=True, desc="image of estimated T1 relaxation values")
pd_image = File(exists=True, desc="image of estimated proton density values")
t2star_image = File(exists=True, desc="image of estimated T2* values")
Expand Down Expand Up @@ -2466,7 +2460,6 @@ def _gen_filename(self, name):


class SynthesizeFLASHInputSpec(FSTraitedSpec):

fixed_weighting = traits.Bool(
position=1,
argstr="-w",
Expand Down Expand Up @@ -2495,7 +2488,6 @@ class SynthesizeFLASHInputSpec(FSTraitedSpec):


class SynthesizeFLASHOutputSpec(TraitedSpec):

out_file = File(exists=True, desc="synthesized FLASH acquisition")


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def test_associated_file(tmpdir):
("./lh.white", "./lh.pial"),
(fsavginfo["white"], fsavginfo["pial"]),
]:

# Unspecified paths, possibly with missing hemisphere information,
# are equivalent to using the same directory and hemisphere
for name in ("pial", "lh.pial", pial):
Expand Down
4 changes: 0 additions & 4 deletions nipype/interfaces/freesurfer/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

@pytest.mark.skipif(fs.no_freesurfer(), reason="freesurfer is not installed")
def test_sample2surf(create_files_in_directory_plus_dummy_file):

s2s = fs.SampleToSurface()
# Test underlying command
assert s2s.cmd == "mri_vol2surf"
Expand Down Expand Up @@ -65,7 +64,6 @@ def set_illegal_range():

@pytest.mark.skipif(fs.no_freesurfer(), reason="freesurfer is not installed")
def test_surfsmooth(create_surf_file_in_directory):

smooth = fs.SurfaceSmooth()

# Test underlying command
Expand Down Expand Up @@ -104,7 +102,6 @@ def test_surfsmooth(create_surf_file_in_directory):

@pytest.mark.skipif(fs.no_freesurfer(), reason="freesurfer is not installed")
def test_surfxfm(create_surf_file_in_directory):

xfm = fs.SurfaceTransform()

# Test underlying command
Expand Down Expand Up @@ -141,7 +138,6 @@ def test_surfxfm(create_surf_file_in_directory):

@pytest.mark.skipif(fs.no_freesurfer(), reason="freesurfer is not installed")
def test_surfshots(create_files_in_directory_plus_dummy_file):

fotos = fs.SurfaceSnapshots()

# Test underlying command
Expand Down
Loading