Skip to content

Commit 2a58098

Browse files
author
bpinsard
committed
Merge branch 'master' into afni/resample
* master: (42 commits) fixed applymask output fixed test Fixed some details for the PR nipy#530 Removed accidentally added files (nipy#530) Updated changelog Updated dMRI and fMRI pre-processing Added motion correction pipeline Modified FSL FLIRT interface to provide log support Polished code buildtemplateparallel.sh - issue with input files Update legacy.py - buildtemplateparallel.sh Minor fixes Added MBIS to sub-package configuration list Standardized import to add all utilities at once First implementation for MBIS New EPI dewarp workflow (nipy#525) New EPI dewarping using a workflow api: force users to explicitly define whether to sort files BF: Fix SplitNifti to generate unique filenames for outputs. added mask input for bias field correction ...
2 parents b71f834 + ea909c7 commit 2a58098

File tree

31 files changed

+1138
-322
lines changed

31 files changed

+1138
-322
lines changed

CHANGES

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Next release
22
============
3+
* ENH: New interfaces: nipy.Trim
34

5+
* ENH: Allow control over terminal output for commandline interfaces
6+
* ENH: New workflows for dMRI and fMRI pre-processing: added motion artifact correction
7+
with rotation of the B-matrix, and susceptibility correction for EPI imaging using
8+
fieldmaps. Updated eddy_correct pipeline to support both dMRI and fMRI, and new parameters.
9+
* ENH: Minor improvements to FSL's FUGUE and FLIRT interfaces
410

511
Release 0.7.0 (Dec 18, 2012)
612
============================

nipype/interfaces/afni/base.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ def version():
4242
Version number as string or None if AFNI not found
4343
4444
"""
45-
clout = CommandLine(command='afni_vcheck').run()
45+
clout = CommandLine(command='afni_vcheck',
46+
terminal_output='allatonce').run()
4647
out = clout.runtime.stdout
4748
return out.split('\n')[1]
4849

@@ -87,7 +88,8 @@ def standard_image(img_name):
8788
'''Grab an image from the standard location.
8889
8990
Could be made more fancy to allow for more relocatability'''
90-
clout = CommandLine('which afni').run()
91+
clout = CommandLine('which afni',
92+
terminal_output='allatonce').run()
9193
if clout.runtime.returncode is not 0:
9294
return None
9395

@@ -214,9 +216,10 @@ def _gen_filename(self, name):
214216

215217
_, base, _ = split_filename(
216218
getattr(self.inputs, trait_spec.name_source))
217-
return self._gen_fname(basename=base, prefix=prefix, suffix=suffix, cwd='')
219+
return self._gen_fname(basename=base, prefix=prefix, suffix=suffix, cwd=os.getcwd())
218220
else:
219-
return super(AFNICommand, self)._gen_filename(name)
221+
return os.path.join(os.getcwd(),
222+
super(AFNICommand, self)._gen_filename(name))
220223

221224
def _overload_extension(self, value):
222225
path, base, _ = split_filename(value)
@@ -229,7 +232,8 @@ def _list_outputs(self):
229232
outputs = self.output_spec().get()
230233
for name in out_names:
231234
out = self._gen_filename(name)
232-
outputs[name] = os.path.abspath(out)
235+
if isdefined(out):
236+
outputs[name] = os.path.abspath(out)
233237
return outputs
234238

235239

nipype/interfaces/afni/preprocess.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import os
1313
from .base import AFNIBaseCommandInputSpec, AFNIBaseCommand
1414
from ..base import (Directory, CommandLineInputSpec, CommandLine, TraitedSpec,
15-
traits, isdefined, File, InputMultiPath)
15+
traits, isdefined, File, InputMultiPath, Undefined)
1616
from ...utils.filemanip import (load_json, save_json, split_filename)
1717
from nipype.utils.filemanip import fname_presuffix
1818
from nipype.interfaces.afni.base import AFNICommand, AFNICommandInputSpec,\
@@ -292,7 +292,7 @@ class ResampleInputSpec(AFNICommandInputSpec):
292292

293293

294294

295-
class Resample(AFNIBaseCommand):
295+
class Resample(AFNICommand):
296296
"""Resample or reorient an image using AFNI 3dresample command
297297
298298
For complete details, see the `3dresample Documentation.
@@ -546,7 +546,7 @@ def _gen_filename(self, name):
546546

547547
_, base, _ = split_filename(
548548
getattr(self.inputs, trait_spec.name_source))
549-
return self._gen_fname(basename=base, prefix=prefix, suffix=suffix, cwd='')
549+
return self._gen_fname(basename=base, prefix=prefix, suffix=suffix, cwd=os.getcwd())
550550
elif name == "brain_file" and isdefined(self.inputs.apply_suffix):
551551
suffix = ''
552552
prefix = ''
@@ -555,7 +555,7 @@ def _gen_filename(self, name):
555555

556556
_, base, _ = split_filename(
557557
getattr(self.inputs, trait_spec.name_source))
558-
return self._gen_fname(basename=base, prefix=prefix, suffix=suffix, cwd='')
558+
return self._gen_fname(basename=base, prefix=prefix, suffix=suffix, cwd=os.getcwd())
559559
elif name == "apply_mask" and isdefined(self.inputs.apply_suffix):
560560
suffix = ''
561561
prefix = ''
@@ -564,9 +564,10 @@ def _gen_filename(self, name):
564564

565565
_, base, _ = split_filename(
566566
getattr(self.inputs, trait_spec.name_source))
567-
return self._gen_fname(basename=base, prefix=prefix, suffix=suffix, cwd='')
568-
else:
569-
return super(AFNICommand, self)._gen_filename(name)
567+
return self._gen_fname(basename=base, prefix=prefix, suffix=suffix, cwd=os.getcwd())
568+
elif hasattr(self.inputs,name) and isdefined(getattr(self.inputs,name)):
569+
return super(Automask, self)._gen_filename(name)
570+
return Undefined
570571

571572
def _list_outputs(self):
572573
outputs = super(Automask, self)._list_outputs()

nipype/interfaces/ants/legacy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,15 @@ class buildtemplateparallel(ANTSCommand):
205205
def _format_arg(self, opt, spec, val):
206206
if opt == 'num_cores':
207207
if self.inputs.parallelization == 2:
208-
return '-j ' + val
208+
return '-j ' + str(val)
209209
else:
210210
return ''
211211
if opt == 'in_files':
212212
if self.inputs.use_first_as_target:
213213
start = '-z '
214214
else:
215215
start = ''
216-
return start + ' '.join([os.path.split(name)[1] for name in val])
216+
return start + ' '.join(name for name in val)
217217
return super(buildtemplateparallel, self)._format_arg(opt, spec, val)
218218

219219
def _list_outputs(self):

nipype/interfaces/ants/registration.py

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -264,16 +264,16 @@ class RegistrationInputSpec(ANTSCommandInputSpec):
264264

265265
class RegistrationOutputSpec(TraitedSpec):
266266
forward_transforms = traits.List(
267-
File(), desc='List of output transforms for forward registration')
267+
File(exists=True), desc='List of output transforms for forward registration')
268268
reverse_transforms = traits.List(
269-
File(), desc='List of output transforms for reverse registration')
269+
File(exists=True), desc='List of output transforms for reverse registration')
270270
forward_invert_flags = traits.List(traits.Bool(
271271
), desc='List of flags corresponding to the forward transforms')
272272
reverse_invert_flags = traits.List(traits.Bool(
273273
), desc='List of flags corresponding to the reverse transforms')
274-
composite_transform = traits.List(File(), desc='Composite transform file')
274+
composite_transform = traits.List(File(exists=True), desc='Composite transform file')
275275
inverse_composite_transform = traits.List(
276-
File(), desc='Inverse composite transform file')
276+
File(exists=True), desc='Inverse composite transform file')
277277

278278

279279
class Registration(ANTSCommand):
@@ -336,7 +336,6 @@ class Registration(ANTSCommand):
336336
_cmd = 'antsRegistration'
337337
input_spec = RegistrationInputSpec
338338
output_spec = RegistrationOutputSpec
339-
_numberOfOutputTransforms = 0
340339
_quantilesDone = False
341340

342341
def _optionalMetricParameters(self, index):
@@ -419,10 +418,6 @@ def _format_arg(self, opt, spec, val):
419418
if opt == 'moving_image_mask':
420419
return '--masks [ %s, %s ]' % (self.inputs.fixed_image_mask, self.inputs.moving_image_mask)
421420
elif opt == 'transforms':
422-
if self.inputs.collapse_output_transforms:
423-
self._numberOfOutputTransforms = 2 # Affine and displacement
424-
else:
425-
self._numberOfOutputTransforms = len(self.inputs.transforms)
426421
return self._formatRegistration()
427422
elif opt == 'initial_moving_transform':
428423
if self.inputs.invert_initial_moving_transform:
@@ -449,7 +444,8 @@ def _format_arg(self, opt, spec, val):
449444

450445
def _outputFileNames(self, prefix, count, transform, inverse=False):
451446
self.lowDimensionalTransformMap = {'Rigid': 'Rigid.mat',
452-
'Affine': 'Affine.mat',
447+
#seems counterontuitive, but his is how ANTS is calling it
448+
'Affine': 'GenericAffine.mat',
453449
'GenericAffine': 'GenericAffine.mat',
454450
'CompositeAffine': 'Affine.mat',
455451
'Similarity': 'Similarity.mat',
@@ -473,6 +469,7 @@ def _list_outputs(self):
473469
outputs['reverse_transforms'] = []
474470
outputs['reverse_invert_flags'] = []
475471
if not self.inputs.collapse_output_transforms:
472+
transformCount = 0
476473
if isdefined(self.inputs.initial_moving_transform):
477474
outputs['forward_transforms'].append(
478475
self.inputs.initial_moving_transform)
@@ -481,20 +478,21 @@ def _list_outputs(self):
481478
outputs['reverse_transforms'].insert(
482479
0, self.inputs.initial_moving_transform)
483480
outputs['reverse_invert_flags'].insert(0, not self.inputs.invert_initial_moving_transform) # Prepend
484-
transformCount = 1
485-
for count in range(self._numberOfOutputTransforms):
486-
forwardFileName, forwardInverseMode = self._outputFileNames(self.inputs.output_transform_prefix, transformCount,
487-
self.inputs.transforms[count])
488-
reverseFileName, reverseInverseMode = self._outputFileNames(self.inputs.output_transform_prefix, transformCount,
489-
self.inputs.transforms[count], True)
490-
outputs['forward_transforms'].append(
491-
os.path.abspath(forwardFileName))
492-
outputs['forward_invert_flags'].append(forwardInverseMode)
493-
outputs['reverse_transforms'].insert(
494-
0, os.path.abspath(reverseFileName))
495-
outputs[
496-
'reverse_invert_flags'].insert(0, reverseInverseMode)
497-
transformCount += 1
481+
transformCount += 1
482+
483+
for count in range(len(self.inputs.transforms)):
484+
forwardFileName, forwardInverseMode = self._outputFileNames(self.inputs.output_transform_prefix, transformCount,
485+
self.inputs.transforms[count])
486+
reverseFileName, reverseInverseMode = self._outputFileNames(self.inputs.output_transform_prefix, transformCount,
487+
self.inputs.transforms[count], True)
488+
outputs['forward_transforms'].append(
489+
os.path.abspath(forwardFileName))
490+
outputs['forward_invert_flags'].append(forwardInverseMode)
491+
outputs['reverse_transforms'].insert(
492+
0, os.path.abspath(reverseFileName))
493+
outputs[
494+
'reverse_invert_flags'].insert(0, reverseInverseMode)
495+
transformCount += 1
498496
else:
499497
transformCount = 0
500498
for transform in ['GenericAffine', 'SyN']: # Only files returned by collapse_output_transforms

nipype/interfaces/ants/segmentation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ class N4BiasFieldCorrectionInputSpec(ANTSCommandInputSpec):
162162
input_image = File(argstr='--input-image %s', mandatory=True,
163163
desc=('image to apply transformation to (generally a '
164164
'coregistered functional)'))
165+
mask_image = File(argstr='--mask-image %s')
165166
output_image = traits.Str(argstr='--output %s',
166167
desc=('output file name'), genfile=True,
167168
hash_file=False)

0 commit comments

Comments
 (0)