Skip to content

Commit 01de3a4

Browse files
committed
Fix logging in dipy interface.
1 parent 3a437c0 commit 01de3a4

File tree

7 files changed

+30
-34
lines changed

7 files changed

+30
-34
lines changed

nipype/interfaces/dipy/anisotropic_power.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def _run_interface(self, runtime):
6767
apm = shm.anisotropic_power(peaks.shm_coeff)
6868
out_file = self._gen_filename('apm')
6969
nb.Nifti1Image(apm.astype("float32"), affine).to_filename(out_file)
70-
IFLOGGER.info('APM qball image saved as {i}'.format(i=out_file))
70+
IFLOGGER.info('APM qball image saved as %s', out_file)
7171

7272
return runtime
7373

nipype/interfaces/dipy/preprocess.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def _run_interface(self, runtime):
6868
resample_proxy(self.inputs.in_file, order=order,
6969
new_zooms=vox_size, out_file=out_file)
7070

71-
IFLOGGER.info('Resliced image saved as {i}'.format(i=out_file))
71+
IFLOGGER.info('Resliced image saved as %s', out_file)
7272
return runtime
7373

7474
def _list_outputs(self):
@@ -159,8 +159,8 @@ def _run_interface(self, runtime):
159159
smask=signal_mask,
160160
nmask=noise_mask,
161161
out_file=out_file)
162-
IFLOGGER.info(('Denoised image saved as {i}, estimated '
163-
'SNR={s}').format(i=out_file, s=str(s)))
162+
IFLOGGER.info('Denoised image saved as %s, estimated SNR=%s',
163+
out_file, str(s))
164164
return runtime
165165

166166
def _list_outputs(self):

nipype/interfaces/dipy/reconstruction.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,12 @@ def _run_interface(self, runtime):
123123
sigma = mean_std * (1 + bias)
124124

125125
if sigma == 0:
126-
IFLOGGER.warn(
127-
('Noise std is 0.0, looks like data was masked and noise'
128-
' cannot be estimated correctly. Using default tensor '
129-
'model instead of RESTORE.'))
126+
IFLOGGER.warn('Noise std is 0.0, looks like data was masked and noise '
127+
'cannot be estimated correctly. Using default tensor '
128+
'model instead of RESTORE.')
130129
dti = TensorModel(gtab)
131130
else:
132-
IFLOGGER.info(('Performing RESTORE with noise std=%.4f.') % sigma)
131+
IFLOGGER.info('Performing RESTORE with noise std=%.4f.', sigma)
133132
dti = TensorModel(gtab, fit_method='RESTORE', sigma=sigma)
134133

135134
try:
@@ -252,14 +251,13 @@ def _run_interface(self, runtime):
252251
ratio = abs(response[1] / response[0])
253252

254253
if ratio > 0.25:
255-
IFLOGGER.warn(('Estimated response is not prolate enough. '
256-
'Ratio=%0.3f.') % ratio)
254+
IFLOGGER.warn('Estimated response is not prolate enough. '
255+
'Ratio=%0.3f.', ratio)
257256
elif ratio < 1.e-5 or np.any(np.isnan(response)):
258257
response = np.array([1.8e-3, 3.6e-4, 3.6e-4, S0])
259-
IFLOGGER.warn(
260-
('Estimated response is not valid, using a default one'))
258+
IFLOGGER.warn('Estimated response is not valid, using a default one')
261259
else:
262-
IFLOGGER.info(('Estimated response: %s') % str(response[:3]))
260+
IFLOGGER.info('Estimated response: %s', str(response[:3]))
263261

264262
np.savetxt(op.abspath(self.inputs.response), response)
265263

@@ -343,8 +341,8 @@ def _run_interface(self, runtime):
343341
ratio = response[0][1] / response[0][0]
344342

345343
if abs(ratio - 0.2) > 0.1:
346-
IFLOGGER.warn(('Estimated response is not prolate enough. '
347-
'Ratio=%0.3f.') % ratio)
344+
IFLOGGER.warn('Estimated response is not prolate enough. '
345+
'Ratio=%0.3f.', ratio)
348346

349347
csd_model = ConstrainedSphericalDeconvModel(
350348
gtab, response, sh_order=self.inputs.sh_order)

nipype/interfaces/dipy/simulate.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import os.path as op
1111
from builtins import range
1212

13+
import numpy as np
1314
import nibabel as nb
1415

1516
from ... import logging
@@ -227,8 +228,8 @@ def _run_interface(self, runtime):
227228
pool = Pool(processes=n_proc)
228229

229230
# Simulate sticks using dipy
230-
IFLOGGER.info(('Starting simulation of %d voxels, %d diffusion'
231-
' directions.') % (len(args), ndirs))
231+
IFLOGGER.info('Starting simulation of %d voxels, %d diffusion directions.',
232+
len(args), ndirs)
232233
result = np.array(pool.map(_compute_voxel, args))
233234
if np.shape(result)[1] != ndirs:
234235
raise RuntimeError(('Computed directions do not match number'
@@ -288,7 +289,6 @@ def _compute_voxel(args):
288289
angles=args['sticks'], fractions=ffs, snr=snr)
289290
except Exception as e:
290291
pass
291-
# IFLOGGER.warn('Exception simulating dwi signal: %s' % e)
292292

293293
return signal.tolist()
294294

nipype/interfaces/dipy/tensors.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ def _run_interface(self, runtime):
6565
img = nifti1_symmat(lower_triangular, affine)
6666
out_file = self._gen_filename('dti')
6767
nb.save(img, out_file)
68-
IFLOGGER.info('DTI parameters image saved as {i}'.format(i=out_file))
68+
IFLOGGER.info('DTI parameters image saved as %s', out_file)
6969

7070
#FA MD RD and AD
7171
for metric in ["fa", "md", "rd", "ad"]:
7272
data = getattr(ten_fit,metric).astype("float32")
7373
out_name = self._gen_filename(metric)
7474
nb.Nifti1Image(data, affine).to_filename(out_name)
75-
IFLOGGER.info('DTI {metric} image saved as {i}'.format(i=out_name, metric=metric))
75+
IFLOGGER.info('DTI %s image saved as %s', metric, out_name)
7676

7777
return runtime
7878

@@ -147,7 +147,7 @@ def _run_interface(self, runtime):
147147
img = nb.Nifti1Image(mode_data, affine)
148148
out_file = self._gen_filename('mode')
149149
nb.save(img, out_file)
150-
IFLOGGER.info('Tensor mode image saved as {i}'.format(i=out_file))
150+
IFLOGGER.info('Tensor mode image saved as %s', out_file)
151151
return runtime
152152

153153
def _list_outputs(self):

nipype/interfaces/dipy/tracks.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,8 @@ def _run_interface(self, runtime):
7171
data_dims = refnii.shape[:3]
7272
kwargs = dict(affine=affine)
7373
else:
74-
IFLOGGER.warn(
75-
'voxel_dims and data_dims are deprecated as of dipy 0.7.1. Please use reference '
76-
'input instead')
74+
IFLOGGER.warn('voxel_dims and data_dims are deprecated as of dipy '
75+
'0.7.1. Please use reference input instead')
7776

7877
if not isdefined(self.inputs.data_dims):
7978
data_dims = header['dim']
@@ -93,9 +92,8 @@ def _run_interface(self, runtime):
9392
out_file = op.abspath(self.inputs.out_filename)
9493
nb.save(img, out_file)
9594

96-
IFLOGGER.info(
97-
'Track density map saved as %s, size=%s, dimensions=%s',
98-
out_file, img.shape, img.header.get_zooms())
95+
IFLOGGER.info('Track density map saved as %s, size=%s, dimensions=%s',
96+
out_file, img.shape, img.header.get_zooms())
9997

10098
return runtime
10199

@@ -238,12 +236,12 @@ def _run_interface(self, runtime):
238236
seedps = np.array(np.where(seedmsk == 1), dtype=np.float32).T
239237
vseeds = seedps.shape[0]
240238
nsperv = (seeds // vseeds) + 1
241-
IFLOGGER.info(('Seed mask is provided (%d voxels inside '
242-
'mask), computing seeds (%d seeds/voxel).') %
243-
(vseeds, nsperv))
239+
IFLOGGER.info('Seed mask is provided (%d voxels inside '
240+
'mask), computing seeds (%d seeds/voxel).',
241+
vseeds, nsperv)
244242
if nsperv > 1:
245-
IFLOGGER.info(('Needed %d seeds per selected voxel '
246-
'(total %d).') % (nsperv, vseeds))
243+
IFLOGGER.info('Needed %d seeds per selected voxel (total %d).',
244+
nsperv, vseeds)
247245
seedps = np.vstack(np.array([seedps] * nsperv))
248246
voxcoord = seedps + np.random.uniform(-1, 1, size=seedps.shape)
249247
nseeds = voxcoord.shape[0]

nipype/interfaces/utility/wrappers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from ...utils.filemanip import filename_to_list
2222
from ...utils.functions import getsource, create_function_from_source
2323

24-
logger = logging.getLogger('interface')
24+
iflogger = logging.getLogger('interface')
2525

2626
class FunctionInputSpec(DynamicTraitedSpec, BaseInterfaceInputSpec):
2727
function_str = traits.Str(mandatory=True, desc='code for function')

0 commit comments

Comments
 (0)