Skip to content

Commit f083895

Browse files
committed
Fixed some (too) long logical statements to agree with PEP8
1 parent cd329a4 commit f083895

File tree

2 files changed

+39
-25
lines changed

2 files changed

+39
-25
lines changed

nipype/interfaces/fsl/preprocess.py

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,13 +1213,15 @@ class FUGUEInputSpec(FSLCommandInputSpec):
12131213
nokspace = traits.Bool(False, argstr='--nokspace', desc='do not use k-space forward warping')
12141214

12151215
# Special outputs: shift (voxel shift map, vsm)
1216-
save_shift = traits.Bool(False, desc='write pixel shift volume')
1216+
save_shift = traits.Bool(False, xor=['save_unmasked_shift'],
1217+
desc='write pixel shift volume')
12171218
shift_out_file = File(argstr='--saveshift=%s', desc='filename for saving pixel shift volume')
12181219
save_unmasked_shift = traits.Bool(argstr='--unmaskshift', xor=['save_shift'],
12191220
desc='saves the unmasked shiftmap when using --saveshift')
12201221

12211222
# Special outputs: fieldmap (fmap)
1222-
save_fmap = traits.Bool(False, desc='write field map volume')
1223+
save_fmap = traits.Bool(False, xor=['save_unmasked_fmap'],
1224+
desc='write field map volume')
12231225
fmap_out_file = File(argstr='--savefmap=%s', desc='filename for saving fieldmap (rad/s)')
12241226
save_unmasked_fmap = traits.Bool(False, argstr='--unmaskfmap', xor=['save_fmap'],
12251227
desc='saves the unmasked fieldmap when using --savefmap')
@@ -1325,46 +1327,56 @@ def _parse_inputs(self, skip=None):
13251327
trait_spec.output_name = 'unwarped_file'
13261328

13271329
# Handle shift output
1328-
vsm_save_masked = isdefined(self.inputs.save_shift) and self.inputs.save_shift
1329-
vsm_save_unmasked = isdefined(self.inputs.save_unmasked_shift) \
1330-
and self.inputs.save_unmasked_shift
1330+
vsm_save_masked = (isdefined(self.inputs.save_shift) and self.inputs.save_shift)
1331+
vsm_save_unmasked = (isdefined(self.inputs.save_unmasked_shift) and
1332+
self.inputs.save_unmasked_shift)
13311333

1332-
if (vsm_save_masked or vsm_save_unmasked) and not isdefined(self.inputs.shift_out_file):
1334+
if ((vsm_save_masked or vsm_save_unmasked) and
1335+
not isdefined(self.inputs.shift_out_file)):
13331336
trait_spec = self.inputs.trait('shift_out_file')
1334-
trait_spec.output_name = 'shift_out_file'
1335-
1336-
if vsm_save_unmasked:
1337-
trait_spec.name_template = '%s_vsm_unmasked'
1338-
else:
1339-
trait_spec.name_template = '%s_vsm'
13401337

13411338
if input_fmap:
13421339
trait_spec.name_source = 'fmap_in_file'
13431340
elif input_phase:
13441341
trait_spec.name_source = 'phasemap_in_file'
1345-
else:
1342+
elif input_vsm:
13461343
trait_spec.name_source = 'shift_in_file'
1344+
else:
1345+
raise RuntimeError(('Either phasemap_in_file, shift_in_file or '
1346+
'fmap_in_file must be set.'))
1347+
1348+
trait_spec.output_name = 'shift_out_file'
1349+
1350+
if vsm_save_unmasked:
1351+
trait_spec.name_template = '%s_vsm_unmasked'
1352+
else:
1353+
trait_spec.name_template = '%s_vsm'
13471354

13481355
# Handle fieldmap output
13491356
fmap_save_masked = isdefined(self.inputs.save_fmap) and self.inputs.save_shift
1350-
fmap_save_unmasked = isdefined(self.inputs.save_unmasked_fmap) and \
1351-
self.inputs.save_unmasked_fmap
1357+
fmap_save_unmasked = (isdefined(self.inputs.save_unmasked_fmap) and
1358+
self.inputs.save_unmasked_fmap)
13521359

1353-
if (fmap_save_masked or fmap_save_unmasked) and not isdefined(self.inputs.fmap_out_file):
1360+
if ((fmap_save_masked or fmap_save_unmasked) and
1361+
not isdefined(self.inputs.fmap_out_file)):
13541362
trait_spec = self.inputs.trait('fmap_out_file')
1355-
trait_spec.output_name = 'fmap_out_file'
1356-
1357-
if fmap_save_unmasked:
1358-
trait_spec.name_template = '%s_fieldmap_unmasked'
1359-
else:
1360-
trait_spec.name_template = '%s_fieldmap'
13611363

13621364
if input_vsm:
13631365
trait_spec.name_source = 'shift_in_file'
13641366
elif input_phase:
13651367
trait_spec.name_source = 'phasemap_in_file'
1366-
else:
1368+
elif input_fmap:
13671369
trait_spec.name_source = 'fmap_in_file'
1370+
else:
1371+
raise RuntimeError(('Either phasemap_in_file, shift_in_file or '
1372+
'fmap_in_file must be set.'))
1373+
1374+
trait_spec.output_name = 'fmap_out_file'
1375+
1376+
if fmap_save_unmasked:
1377+
trait_spec.name_template = '%s_fieldmap_unmasked'
1378+
else:
1379+
trait_spec.name_template = '%s_fieldmap'
13681380

13691381
return super(FUGUE, self)._parse_inputs(skip=skip)
13701382

nipype/interfaces/fsl/tests/test_auto_FUGUE.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ def test_FUGUE_inputs():
5656
),
5757
poly_order=dict(argstr='--poly=%d',
5858
),
59-
save_fmap=dict(),
60-
save_shift=dict(),
59+
save_fmap=dict(xor=['save_unmasked_fmap'],
60+
),
61+
save_shift=dict(xor=['save_unmasked_shift'],
62+
),
6163
save_unmasked_fmap=dict(argstr='--unmaskfmap',
6264
xor=['save_fmap'],
6365
),

0 commit comments

Comments
 (0)