Skip to content

Commit b9ba722

Browse files
committed
BF: more lgtm fixes
1 parent 34a7c1d commit b9ba722

File tree

14 files changed

+16
-271
lines changed

14 files changed

+16
-271
lines changed

nipype/algorithms/misc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,7 @@ def normalize_tpms(in_files, in_mask=None, out_files=None):
12021202

12031203
in_files = np.atleast_1d(in_files).tolist()
12041204

1205-
if not out_files:
1205+
if out_files is None:
12061206
out_files = []
12071207

12081208
if len(out_files) != len(in_files):

nipype/info.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ def get_nipype_gitversion():
120120
URL = 'http://nipy.org/nipype'
121121
DOWNLOAD_URL = 'http://github.com/nipy/nipype/archives/master'
122122
LICENSE = 'Apache License, 2.0'
123-
CLASSIFIERS = CLASSIFIERS
124123
AUTHOR = 'nipype developers'
125124
AUTHOR_EMAIL = 'neuroimaging@python.org'
126125
PLATFORMS = 'OS Independent'

nipype/interfaces/ants/registration.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,17 +1118,13 @@ def _get_outputfilenames(self, inverse=False):
11181118
output_filename = self.inputs.output_warped_image
11191119
if isinstance(output_filename, bool):
11201120
output_filename = '%s_Warped.nii.gz' % self.inputs.output_transform_prefix
1121-
else:
1122-
output_filename = output_filename
11231121
return output_filename
11241122
inv_output_filename = None
11251123
if isdefined(self.inputs.output_inverse_warped_image) and \
11261124
self.inputs.output_inverse_warped_image:
11271125
inv_output_filename = self.inputs.output_inverse_warped_image
11281126
if isinstance(inv_output_filename, bool):
11291127
inv_output_filename = '%s_InverseWarped.nii.gz' % self.inputs.output_transform_prefix
1130-
else:
1131-
inv_output_filename = inv_output_filename
11321128
return inv_output_filename
11331129

11341130
def _format_convergence(self, ii):

nipype/interfaces/ants/segmentation.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -700,12 +700,6 @@ def _list_outputs(self):
700700
return outputs
701701

702702

703-
class antsCorticalThickness(CorticalThickness):
704-
DeprecationWarning(
705-
'This class has been replaced by CorticalThickness and will be removed in version 0.13'
706-
)
707-
708-
709703
class BrainExtractionInputSpec(ANTSCommandInputSpec):
710704
dimension = traits.Enum(
711705
3, 2, argstr='-d %d', usedefault=True, desc='image dimension (2 or 3)')
@@ -924,12 +918,6 @@ def _list_outputs(self):
924918
return outputs
925919

926920

927-
class antsBrainExtraction(BrainExtraction):
928-
DeprecationWarning(
929-
'This class has been replaced by BrainExtraction and will be removed in version 0.13'
930-
)
931-
932-
933921
class JointFusionInputSpec(ANTSCommandInputSpec):
934922
dimension = traits.Enum(
935923
3,

nipype/interfaces/base/specs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ def _clean_container(self, objekt, undefinedval=None, skipundefined=False):
197197
if isinstance(objekt, tuple):
198198
out = tuple(out)
199199
else:
200+
out = None
200201
if isdefined(objekt):
201202
out = objekt
202203
else:
@@ -283,6 +284,7 @@ def _get_sorteddict(self,
283284
if isinstance(objekt, tuple):
284285
out = tuple(out)
285286
else:
287+
out = None
286288
if isdefined(objekt):
287289
if (hash_files and isinstance(objekt, (str, bytes))
288290
and os.path.isfile(objekt)):

nipype/interfaces/cmtk/cmtk.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ def cmat(track_file,
222222
gp = nx.read_gpickle(resolution_network_file)
223223
elif ext == '.graphml':
224224
gp = nx.read_graphml(resolution_network_file)
225-
225+
else:
226+
raise TypeError("Unable to read file:", resolution_network_file)
226227
nROIs = len(gp.nodes())
227228

228229
# add node information from parcellation

nipype/interfaces/fsl/tests/test_preprocess.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -615,15 +615,15 @@ def test_first_genfname():
615615
first.inputs.out_file = 'segment.nii'
616616
first.inputs.output_type = "NIFTI_GZ"
617617

618-
value = first._gen_fname(name='original_segmentations')
618+
value = first._gen_fname(basename='original_segmentations')
619619
expected_value = os.path.abspath('segment_all_fast_origsegs.nii.gz')
620620
assert value == expected_value
621621
first.inputs.method = 'none'
622-
value = first._gen_fname(name='original_segmentations')
622+
value = first._gen_fname(basename='original_segmentations')
623623
expected_value = os.path.abspath('segment_all_none_origsegs.nii.gz')
624624
assert value == expected_value
625625
first.inputs.method = 'auto'
626626
first.inputs.list_of_specific_structures = ['L_Hipp', 'R_Hipp']
627-
value = first._gen_fname(name='original_segmentations')
627+
value = first._gen_fname(basename='original_segmentations')
628628
expected_value = os.path.abspath('segment_all_none_origsegs.nii.gz')
629629
assert value == expected_value

nipype/interfaces/nipy/preprocess.py

Lines changed: 0 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -85,146 +85,7 @@ def _list_outputs(self):
8585
return outputs
8686

8787

88-
class FmriRealign4dInputSpec(BaseInterfaceInputSpec):
89-
90-
in_file = InputMultiPath(
91-
File(exists=True), mandatory=True, desc="File to realign")
92-
tr = traits.Float(desc="TR in seconds", mandatory=True)
93-
slice_order = traits.List(
94-
traits.Int(),
95-
desc=('0 based slice order. This would be equivalent to entering'
96-
'np.argsort(spm_slice_order) for this field. This effects'
97-
'interleaved acquisition. This field will be deprecated in'
98-
'future Nipy releases and be replaced by actual slice'
99-
'acquisition times.'),
100-
requires=["time_interp"])
101-
tr_slices = traits.Float(desc="TR slices", requires=['time_interp'])
102-
start = traits.Float(
103-
0.0, usedefault=True, desc="time offset into TR to align slices to")
104-
time_interp = traits.Enum(
105-
True,
106-
requires=["slice_order"],
107-
desc="Assume smooth changes across time e.g.,\
108-
fmri series. If you don't want slice timing \
109-
correction set this to undefined")
110-
loops = InputMultiPath(
111-
[5], traits.Int, usedefault=True, desc="loops within each run")
112-
between_loops = InputMultiPath(
113-
[5],
114-
traits.Int,
115-
usedefault=True,
116-
desc="loops used to \
117-
realign different \
118-
runs")
119-
speedup = InputMultiPath(
120-
[5],
121-
traits.Int,
122-
usedefault=True,
123-
desc="successive image \
124-
sub-sampling factors \
125-
for acceleration")
126-
127-
128-
class FmriRealign4dOutputSpec(TraitedSpec):
129-
130-
out_file = OutputMultiPath(File(exists=True), desc="Realigned files")
131-
par_file = OutputMultiPath(
132-
File(exists=True), desc="Motion parameter files")
133-
134-
135-
class FmriRealign4d(BaseInterface):
136-
"""Simultaneous motion and slice timing correction algorithm
137-
138-
This interface wraps nipy's FmriRealign4d algorithm [1]_.
139-
140-
Examples
141-
--------
142-
>>> from nipype.interfaces.nipy.preprocess import FmriRealign4d
143-
>>> realigner = FmriRealign4d()
144-
>>> realigner.inputs.in_file = ['functional.nii']
145-
>>> realigner.inputs.tr = 2
146-
>>> realigner.inputs.slice_order = list(range(0,67))
147-
>>> res = realigner.run() # doctest: +SKIP
148-
149-
References
150-
----------
151-
.. [1] Roche A. A four-dimensional registration algorithm with \
152-
application to joint correction of motion and slice timing \
153-
in fMRI. IEEE Trans Med Imaging. 2011 Aug;30(8):1546-54. DOI_.
154-
155-
.. _DOI: http://dx.doi.org/10.1109/TMI.2011.2131152
156-
157-
"""
158-
159-
input_spec = FmriRealign4dInputSpec
160-
output_spec = FmriRealign4dOutputSpec
161-
keywords = ['slice timing', 'motion correction']
162-
163-
def __init__(self, **inputs):
164-
DeprecationWarning(('Will be deprecated in release 0.13. Please use'
165-
'SpaceTimeRealigner'))
166-
BaseInterface.__init__(self, **inputs)
167-
168-
def _run_interface(self, runtime):
169-
from nipy.algorithms.registration import FmriRealign4d as FR4d
170-
all_ims = [load_image(fname) for fname in self.inputs.in_file]
171-
172-
if not isdefined(self.inputs.tr_slices):
173-
TR_slices = None
174-
else:
175-
TR_slices = self.inputs.tr_slices
176-
177-
R = FR4d(
178-
all_ims,
179-
tr=self.inputs.tr,
180-
slice_order=self.inputs.slice_order,
181-
tr_slices=TR_slices,
182-
time_interp=self.inputs.time_interp,
183-
start=self.inputs.start)
184-
185-
R.estimate(
186-
loops=list(self.inputs.loops),
187-
between_loops=list(self.inputs.between_loops),
188-
speedup=list(self.inputs.speedup))
189-
190-
corr_run = R.resample()
191-
self._out_file_path = []
192-
self._par_file_path = []
193-
194-
for j, corr in enumerate(corr_run):
195-
self._out_file_path.append(
196-
os.path.abspath('corr_%s.nii.gz' %
197-
(split_filename(self.inputs.in_file[j])[1])))
198-
save_image(corr, self._out_file_path[j])
199-
200-
self._par_file_path.append(
201-
os.path.abspath('%s.par' %
202-
(os.path.split(self.inputs.in_file[j])[1])))
203-
mfile = open(self._par_file_path[j], 'w')
204-
motion = R._transforms[j]
205-
# nipy does not encode euler angles. return in original form of
206-
# translation followed by rotation vector see:
207-
# http://en.wikipedia.org/wiki/Rodrigues'_rotation_formula
208-
for i, mo in enumerate(motion):
209-
params = [
210-
'%.10f' % item
211-
for item in np.hstack((mo.translation, mo.rotation))
212-
]
213-
string = ' '.join(params) + '\n'
214-
mfile.write(string)
215-
mfile.close()
216-
217-
return runtime
218-
219-
def _list_outputs(self):
220-
outputs = self._outputs().get()
221-
outputs['out_file'] = self._out_file_path
222-
outputs['par_file'] = self._par_file_path
223-
return outputs
224-
225-
22688
class SpaceTimeRealignerInputSpec(BaseInterfaceInputSpec):
227-
22889
in_file = InputMultiPath(
22990
File(exists=True),
23091
mandatory=True,

nipype/pipeline/engine/base.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,4 @@ def save(self, filename=None):
109109
savepkl(filename, self)
110110

111111
def load(self, filename):
112-
if '.npz' in filename:
113-
DeprecationWarning(('npz files will be deprecated in the next '
114-
'release. you can use numpy to open them.'))
115-
return np.load(filename)
116112
return loadpkl(filename)

nipype/pipeline/engine/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def load_resultfile(path, name):
280280
except UnicodeDecodeError:
281281
# Was this pickle created with Python 2.x?
282282
pickle.load(pkl_file, fix_imports=True, encoding='utf-8')
283-
logger.warning('Successfully loaded pickle in compatibility mode')
283+
logger.warning('Successfully loaded pkl in compatibility mode')
284284
except (traits.TraitError, AttributeError, ImportError,
285285
EOFError) as err:
286286
if isinstance(err, (AttributeError, ImportError)):
@@ -439,6 +439,8 @@ def modify_paths(object, relative=True, basedir=None):
439439
raise IOError('File %s not found' % out)
440440
else:
441441
out = object
442+
else:
443+
raise TypeError("Object {} is undefined".format(object))
442444
return out
443445

444446

nipype/pipeline/engine/workflows.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ def export(self,
496496
flatgraph = self._create_flat_graph()
497497
nodes = nx.topological_sort(flatgraph)
498498

499+
all_lines = None
499500
lines = ['# Workflow']
500501
importlines = [
501502
'from nipype.pipeline.engine import Workflow, '

nipype/pipeline/plugins/ipython.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ def execute_task(pckld_task, node_config, updatehash):
3939
result = task.run(updatehash=updatehash)
4040
except:
4141
traceback = format_exc()
42+
from pickle import loads
43+
task = loads(pckld_task)
4244
result = task.result
4345
os.chdir(cwd)
4446
return result, traceback, gethostname()

nipype/pipeline/plugins/ipythonx.py

Lines changed: 0 additions & 95 deletions
This file was deleted.

0 commit comments

Comments
 (0)