Skip to content

Commit 4450915

Browse files
committed
make flake8 happy
1 parent 7874bc7 commit 4450915

File tree

5 files changed

+20
-15
lines changed

5 files changed

+20
-15
lines changed

fmriprep/interfaces/images.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,6 @@ class ValidateImage(SimpleInterface):
345345
def _run_interface(self, runtime):
346346

347347
def deoblique(img):
348-
import os
349348
import nibabel as nb
350349
import numpy as np
351350
affine = img.affine
@@ -381,7 +380,8 @@ def deoblique(img):
381380
# Both match, qform valid (implicit with match), codes okay -> do nothing, empty report
382381
if matching_affines and qform_code > 0 and sform_code > 0:
383382
if self.inputs.deoblique:
384-
out_fname = fname_presuffix(self.inputs.in_file, suffix='_valid', newpath=runtime.cwd)
383+
out_fname = fname_presuffix(self.inputs.in_file, suffix='_valid',
384+
newpath=runtime.cwd)
385385
img = deoblique(img)
386386
img.to_filename(out_fname)
387387
self._results['out_file'] = out_fname

fmriprep/utils/misc.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,17 @@ def split_and_deoblique_func(in_file):
1414
import numpy as np
1515
out_files = []
1616
for i, img in enumerate(iter_img(in_file)):
17-
out_file = os.path.abspath('vol%04d.nii.gz'%i)
17+
out_file = os.path.abspath('vol%04d.nii.gz' % i)
1818
affine = img.affine
19-
affine[:3,:3] = np.diag(np.diag(affine[:3, :3]))
19+
affine[:3, :3] = np.diag(np.diag(affine[:3, :3]))
2020
nb.Nifti1Image(np.asanyarray(img.dataobj), affine, img.header).to_filename(out_file)
2121
out_files.append(out_file)
2222
return out_files
2323

2424

2525
def afni2itk_func(in_file):
2626
import os
27-
from scipy.io import loadmat, savemat
28-
from numpy import loadtxt, around, hstack, vstack, zeros, float64
27+
from numpy import loadtxt, hstack, vstack, zeros, float64
2928

3029
def read_afni_affine(input_file, debug=False):
3130
orig_afni_mat = loadtxt(input_file)
@@ -34,13 +33,13 @@ def read_afni_affine(input_file, debug=False):
3433

3534
output = []
3635
for i in range(orig_afni_mat.shape[0]):
37-
output.append(vstack((orig_afni_mat[i,:].reshape(3, 4, order='C'), [0, 0, 0, 1])))
36+
output.append(vstack((orig_afni_mat[i, :].reshape(3, 4, order='C'), [0, 0, 0, 1])))
3837
return output
3938

4039
def get_ants_dict(affine, debug=False):
4140
out_dict = {}
42-
out_dict['AffineTransform_double_3_3'] = hstack(
43-
(affine[:3, :3].reshape(1, -1), affine[:3, 3].reshape(1, -1))).reshape(-1, 1).astype(float64)
41+
ants_affine_2d = hstack((affine[:3, :3].reshape(1, -1), affine[:3, 3].reshape(1, -1)))
42+
out_dict['AffineTransform_double_3_3'] = ants_affine_2d.reshape(-1, 1).astype(float64)
4443
out_dict['fixed'] = zeros((3, 1))
4544
if debug:
4645
print(out_dict)
@@ -51,11 +50,18 @@ def get_ants_dict(affine, debug=False):
5150
with open(out_file, 'w') as fp:
5251
fp.write("#Insight Transform File V1.0\n")
5352
for i, affine in enumerate(read_afni_affine(in_file)):
54-
fp.write("#Transform %d\n"%i)
53+
fp.write("#Transform %d\n" % i)
5554
fp.write("Transform: AffineTransform_double_3_3\n")
5655
trans_dict = get_ants_dict(affine)
57-
fp.write("Parameters: " + ' '.join(["%g"%i for i in list(trans_dict['AffineTransform_double_3_3'])]) + "\n")
58-
fp.write("FixedParameters: " + ' '.join(["%g"%i for i in list(trans_dict['fixed'])]) + "\n")
56+
57+
params_list = ["%g" % i for i in list(trans_dict['AffineTransform_double_3_3'])]
58+
params_str = ' '.join(params_list)
59+
fp.write("Parameters: " + params_str + "\n")
60+
61+
fixed_params_list = ["%g" % i for i in list(trans_dict['fixed'])]
62+
fixed_params_str = ' '.join(fixed_params_list)
63+
fp.write("FixedParameters: " + ' '.join(fixed_params_str) + "\n")
64+
5965
return out_file
6066

6167

fmriprep/workflows/bold/base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import nibabel as nb
1616
from nipype import logging
1717

18-
from nipype.interfaces.fsl import Split as FSLSplit
1918
from nipype.pipeline import engine as pe
2019
from nipype.interfaces import utility as niu
2120

fmriprep/workflows/bold/hmc.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from niworkflows.interfaces import NormalizeMotionParams
1515
from fmriprep.utils.misc import afni2itk_func
1616
from ...engine import Workflow
17-
from ...interfaces import MCFLIRT2ITK
1817

1918
DEFAULT_MEMORY_MIN_GB = 0.01
2019

fmriprep/workflows/bold/util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ def init_bold_reference_wf(omp_nthreads, bold_file=None, name='bold_reference_wf
104104
gen_ref = pe.Node(EstimateReferenceImage(), name="gen_ref",
105105
mem_gb=1) # OE: 128x128x128x50 * 64 / 8 ~ 900MB.
106106
# Re-run validation; no effect if no sbref; otherwise apply same validation to sbref as bold
107-
validate_ref = pe.Node(ValidateImage(deoblique=True), name='validate_ref', mem_gb=DEFAULT_MEMORY_MIN_GB)
107+
validate_ref = pe.Node(ValidateImage(deoblique=True), name='validate_ref',
108+
mem_gb=DEFAULT_MEMORY_MIN_GB)
108109
enhance_and_skullstrip_bold_wf = init_enhance_and_skullstrip_bold_wf(omp_nthreads=omp_nthreads)
109110

110111
workflow.connect([

0 commit comments

Comments
 (0)