Skip to content

Commit 725e580

Browse files
committed
fix some pep8 errors
1 parent 0fc07fa commit 725e580

File tree

1 file changed

+68
-67
lines changed

1 file changed

+68
-67
lines changed

nipype/workflows/dmri/fsl/utils.py

Lines changed: 68 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,18 @@ def cleanup_edge_pipeline(name='Cleanup'):
3131

3232
wf = pe.Workflow(name=name)
3333
wf.connect([
34-
(inputnode, fugue, [('in_file', 'fmap_in_file'),
35-
('in_mask', 'mask_file')])
36-
,(inputnode, erode, [('in_mask', 'in_file')])
37-
,(inputnode, newmsk, [('in_mask', 'in_file')])
38-
,(erode, newmsk, [('out_file', 'operand_files')])
39-
,(fugue, applymsk, [('fmap_out_file', 'in_file')])
40-
,(newmsk, applymsk, [('out_file', 'mask_file')])
41-
,(erode, join, [('out_file', 'in1')])
42-
,(applymsk, join, [('out_file', 'in2')])
43-
,(inputnode, addedge, [('in_file', 'in_file')])
44-
,(join, addedge, [('out', 'operand_files')])
45-
,(addedge, outputnode, [('out_file', 'out_file')])
34+
(inputnode, fugue, [('in_file', 'fmap_in_file'),
35+
('in_mask', 'mask_file')]),
36+
(inputnode, erode, [('in_mask', 'in_file')]),
37+
(inputnode, newmsk, [('in_mask', 'in_file')]),
38+
(erode, newmsk, [('out_file', 'operand_files')]),
39+
(fugue, applymsk, [('fmap_out_file', 'in_file')]),
40+
(newmsk, applymsk, [('out_file', 'mask_file')]),
41+
(erode, join, [('out_file', 'in1')]),
42+
(applymsk, join, [('out_file', 'in2')]),
43+
(inputnode, addedge, [('in_file', 'in_file')]),
44+
(join, addedge, [('out', 'operand_files')]),
45+
(addedge, outputnode, [('out_file', 'out_file')])
4646
])
4747
return wf
4848

@@ -64,15 +64,14 @@ def vsm2warp(name='Shiftmap2Warping'):
6464

6565
wf = pe.Workflow(name=name)
6666
wf.connect([
67-
(inputnode, fixhdr, [('in_vsm', 'in_file'),
68-
('in_ref', 'in_file_hdr')])
69-
,(inputnode, vsm, [('scaling', 'operand_value')])
70-
,(fixhdr, vsm, [('out_file', 'in_file')])
71-
72-
,(vsm, vsm2dfm, [('out_file', 'shift_in_file')])
73-
,(inputnode, vsm2dfm, [('in_ref', 'reference'),
74-
('enc_dir', 'shift_direction')])
75-
,(vsm2dfm, outputnode, [('out_file', 'out_warp')])
67+
(inputnode, fixhdr, [('in_vsm', 'in_file'),
68+
('in_ref', 'in_file_hdr')]),
69+
(inputnode, vsm, [('scaling', 'operand_value')]),
70+
(fixhdr, vsm, [('out_file', 'in_file')]),
71+
(vsm, vsm2dfm, [('out_file', 'shift_in_file')]),
72+
(inputnode, vsm2dfm, [('in_ref', 'reference'),
73+
('enc_dir', 'shift_direction')]),
74+
(vsm2dfm, outputnode, [('out_file', 'out_warp')])
7675
])
7776
return wf
7877

@@ -111,25 +110,25 @@ def dwi_flirt(name='DWICoregistration', excl_nodiff=False,
111110
'out_xfms']), name='outputnode')
112111
wf = pe.Workflow(name=name)
113112
wf.connect([
114-
(inputnode, split, [('in_file', 'in_file')])
115-
,(inputnode, dilate, [('ref_mask', 'in_file')])
116-
,(inputnode, enhb0, [('ref_mask', 'in_mask')])
117-
,(inputnode, initmat, [('in_xfms', 'in_xfms'),
118-
('in_bval', 'in_bval')])
119-
,(inputnode, n4, [('reference', 'input_image'),
120-
('ref_mask', 'mask_image')])
121-
,(dilate, flirt, [('out_file', 'ref_weight'),
122-
('out_file', 'in_weight')])
123-
,(n4, enhb0, [('output_image', 'in_file')])
124-
,(split, enhdw, [('out_files', 'in_file')])
125-
,(dilate, enhdw, [('out_file', 'in_mask')])
126-
,(enhb0, flirt, [('out_file', 'reference')])
127-
,(enhdw, flirt, [('out_file', 'in_file')])
128-
,(initmat, flirt, [('init_xfms', 'in_matrix_file')])
129-
,(flirt, thres, [('out_file', 'in_file')])
130-
,(thres, merge, [('out_file', 'in_files')])
131-
,(merge, outputnode, [('merged_file', 'out_file')])
132-
,(flirt, outputnode, [('out_matrix_file', 'out_xfms')])
113+
(inputnode, split, [('in_file', 'in_file')]),
114+
(inputnode, dilate, [('ref_mask', 'in_file')]),
115+
(inputnode, enhb0, [('ref_mask', 'in_mask')]),
116+
(inputnode, initmat, [('in_xfms', 'in_xfms'),
117+
('in_bval', 'in_bval')]),
118+
(inputnode, n4, [('reference', 'input_image'),
119+
('ref_mask', 'mask_image')]),
120+
(dilate, flirt, [('out_file', 'ref_weight'),
121+
('out_file', 'in_weight')]),
122+
(n4, enhb0, [('output_image', 'in_file')]),
123+
(split, enhdw, [('out_files', 'in_file')]),
124+
(dilate, enhdw, [('out_file', 'in_mask')]),
125+
(enhb0, flirt, [('out_file', 'reference')]),
126+
(enhdw, flirt, [('out_file', 'in_file')]),
127+
(initmat, flirt, [('init_xfms', 'in_matrix_file')]),
128+
(flirt, thres, [('out_file', 'in_file')]),
129+
(thres, merge, [('out_file', 'in_files')]),
130+
(merge, outputnode, [('merged_file', 'out_file')]),
131+
(flirt, outputnode, [('out_matrix_file', 'out_xfms')])
133132
])
134133
return wf
135134

@@ -170,28 +169,27 @@ def apply_all_corrections(name='UnwarpArtifacts'):
170169

171170
wf = pe.Workflow(name=name)
172171
wf.connect([
173-
(inputnode, warps, [('in_sdc', 'warp1'),
174-
('in_hmc', 'premat'),
175-
('in_ecc', 'postmat'),
176-
('in_dwi', 'reference')])
177-
,(inputnode, split, [('in_dwi', 'in_file')])
178-
,(split, selref, [('out_files', 'inlist')])
179-
,(warps, unwarp, [('out_file', 'field_file')])
180-
,(split, unwarp, [('out_files', 'in_file')])
181-
,(selref, unwarp, [('out', 'ref_file')])
182-
,(selref, coeffs, [('out', 'reference')])
183-
,(warps, coeffs, [('out_file', 'in_file')])
184-
,(selref, jacobian, [('out', 'reference')])
185-
,(coeffs, jacobian, [('out_file', 'in_file')])
186-
,(unwarp, jacmult, [('out_file', 'in_file')])
187-
,(jacobian, jacmult, [('out_jacobian', 'operand_files')])
188-
,(jacmult, thres, [('out_file', 'in_file')])
189-
,(thres, merge, [('out_file', 'in_files')])
190-
191-
,(warps, outputnode, [('out_file', 'out_warp')])
192-
,(coeffs, outputnode, [('out_file', 'out_coeff')])
193-
,(jacobian, outputnode, [('out_jacobian', 'out_jacobian')])
194-
,(merge, outputnode, [('merged_file', 'out_file')])
172+
(inputnode, warps, [('in_sdc', 'warp1'),
173+
('in_hmc', 'premat'),
174+
('in_ecc', 'postmat'),
175+
('in_dwi', 'reference')]),
176+
(inputnode, split, [('in_dwi', 'in_file')]),
177+
(split, selref, [('out_files', 'inlist')]),
178+
(warps, unwarp, [('out_file', 'field_file')]),
179+
(split, unwarp, [('out_files', 'in_file')]),
180+
(selref, unwarp, [('out', 'ref_file')]),
181+
(selref, coeffs, [('out', 'reference')]),
182+
(warps, coeffs, [('out_file', 'in_file')]),
183+
(selref, jacobian, [('out', 'reference')]),
184+
(coeffs, jacobian, [('out_file', 'in_file')]),
185+
(unwarp, jacmult, [('out_file', 'in_file')]),
186+
(jacobian, jacmult, [('out_jacobian', 'operand_files')]),
187+
(jacmult, thres, [('out_file', 'in_file')]),
188+
(thres, merge, [('out_file', 'in_files')]),
189+
(warps, outputnode, [('out_file', 'out_warp')]),
190+
(coeffs, outputnode, [('out_file', 'out_coeff')]),
191+
(jacobian, outputnode, [('out_jacobian', 'out_jacobian')]),
192+
(merge, outputnode, [('merged_file', 'out_file')])
195193
])
196194
return wf
197195

@@ -281,7 +279,8 @@ def insert_mat(inlist, volid=0):
281279

282280
def recompose_dwi(in_dwi, in_bval, in_corrected, out_file=None):
283281
"""
284-
Recompose back the dMRI data accordingly the b-values table after EC correction
282+
Recompose back the dMRI data accordingly the b-values table after EC
283+
correction
285284
"""
286285
import numpy as np
287286
import nibabel as nb
@@ -300,7 +299,8 @@ def recompose_dwi(in_dwi, in_bval, in_corrected, out_file=None):
300299
dwis = np.where(bvals != 0)[0].tolist()
301300

302301
if len(dwis) != len(in_corrected):
303-
raise RuntimeError('Length of DWIs in b-values table and after correction should match')
302+
raise RuntimeError(('Length of DWIs in b-values table and after'
303+
'correction should match'))
304304

305305
for bindex, dwi in zip(dwis, in_corrected):
306306
dwidata[..., bindex] = nb.load(dwi).get_data()
@@ -348,15 +348,16 @@ def b0_average(in_dwi, in_bval, out_file=None):
348348
import os.path as op
349349

350350
if out_file is None:
351-
fname,ext = op.splitext(op.basename(in_dwi))
351+
fname, ext = op.splitext(op.basename(in_dwi))
352352
if ext == ".gz":
353-
fname,ext2 = op.splitext(fname)
353+
fname, ext2 = op.splitext(fname)
354354
ext = ext2 + ext
355355
out_file = op.abspath("%s_avg_b0%s" % (fname, ext))
356356

357357
imgs = np.array(nb.four_to_three(nb.load(in_dwi)))
358358
bval = np.loadtxt(in_bval)
359-
b0s = [im.get_data().astype(np.float32) for im in imgs[np.where(bval==0)]]
359+
b0s = [im.get_data().astype(np.float32)
360+
for im in imgs[np.where(bval == 0)]]
360361
b0 = np.average(np.array(b0s), axis=0)
361362

362363
hdr = imgs[0].get_header().copy()

0 commit comments

Comments
 (0)