Skip to content

Commit 916aa98

Browse files
committed
Merge pull request #4 from sgiavasis/0.9.2_cpac-tested
0.9.2 cpac tested
2 parents 7412c81 + d83cfb9 commit 916aa98

28 files changed

+690
-208
lines changed

Vagrantfile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ $script = <<SCRIPT
2020
# qconf -aattr queue slots "2, [neuro=3]" main.q
2121
2222
# install anaconda
23-
wget http://repo.continuum.io/miniconda/Miniconda-3.0.0-Linux-x86_64.sh -O miniconda.sh
23+
wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh
2424
chmod +x miniconda.sh
2525
./miniconda.sh -b
2626
echo "export PATH=$HOME/miniconda/bin:\\$PATH" >> .bashrc
2727
2828
# install nipype dependencies
29-
$HOME/anaconda/bin/conda update --yes conda
30-
$HOME/anaconda/bin/conda install --yes pip numpy scipy nose traits networkx
31-
$HOME/anaconda/bin/conda install --yes dateutil ipython-notebook matplotlib
32-
$HOME/anaconda/bin/pip install nibabel --use-mirrors
33-
$HOME/anaconda/bin/pip install https://github.com/RDFLib/rdflib/archive/master.zip
34-
$HOME/anaconda/bin/pip install https://github.com/satra/prov/archive/enh/rdf.zip
35-
$HOME/anaconda/bin/pip install https://github.com/nipy/nipype/archive/master.zip
29+
$HOME/miniconda/bin/conda update --yes conda
30+
$HOME/miniconda/bin/conda install --yes pip numpy scipy nose traits networkx
31+
$HOME/miniconda/bin/conda install --yes dateutil ipython-notebook matplotlib
32+
$HOME/miniconda/bin/pip install nibabel --use-mirrors
33+
$HOME/miniconda/bin/pip install https://github.com/RDFLib/rdflib/archive/master.zip
34+
$HOME/miniconda/bin/pip install https://github.com/satra/prov/archive/enh/rdf.zip
35+
$HOME/miniconda/bin/pip install https://github.com/nipy/nipype/archive/master.zip
3636
SCRIPT
3737

3838
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
@@ -42,7 +42,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
4242
engine_config.vm.box = "gridneuro"
4343
#engine_config.vm.box_url = "http://files.vagrantup.com/precise64.box"
4444
engine_config.vm.box_url = "https://dl.dropboxusercontent.com/u/363467/precise64_neuro.box"
45-
engine_config.vm.network :forwarded_port, guest: 80, host: 8080
45+
#engine_config.vm.network :forwarded_port, guest: 80, host: 8080
4646

4747
#engine_config.vm.network :public_network, :bridge => 'en0: Wi-Fi (AirPort)'
4848
engine_config.vm.network :private_network, ip: "192.168.100.20"

nipype/info.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ def get_nipype_gitversion():
104104
NUMPY_MIN_VERSION = '1.3'
105105
SCIPY_MIN_VERSION = '0.7'
106106
TRAITS_MIN_VERSION = '4.0'
107+
DATEUTIL_MIN_VERSION = '1.0'
108+
NOSE_MIN_VERSION = '1.0'
107109

108110
NAME = 'nipype'
109111
MAINTAINER = "nipype developers"
@@ -122,6 +124,7 @@ def get_nipype_gitversion():
122124
MICRO = _version_micro
123125
ISRELEASE = _version_extra == ''
124126
VERSION = __version__
125-
REQUIRES = ["nibabel (>=1.0)", "networkx (>=1.0)", "numpy (>=1.3)",
126-
"scipy (>=0.7)", "traits (>=4.0)"]
127+
REQUIRES = ["nibabel>=1.0", "networkx>=1.0", "numpy>=1.3",
128+
"python-dateutil>1.0", "scipy>=0.7", "traits>=4.0",
129+
"nose>=1.0"]
127130
STATUS = 'stable'

nipype/interfaces/afni/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def set_default_output_type(cls, outputtype):
144144
else:
145145
raise AttributeError('Invalid AFNI outputtype: %s' % outputtype)
146146

147-
def _overload_extension(self, value):
147+
def _overload_extension(self, value, name=None):
148148
path, base, _ = split_filename(value)
149149
return os.path.join(path, base + Info.outputtype_to_ext(self.inputs.outputtype))
150150

nipype/interfaces/afni/preprocess.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,6 @@ class VolregInputSpec(AFNICommandInputSpec):
560560
copyfile=False)
561561
out_file = File(name_template="%s_volreg", desc='output image file name',
562562
argstr='-prefix %s', name_source="in_file")
563-
564563
basefile = File(desc='base file for registration',
565564
argstr='-base %s',
566565
position=-6,
@@ -582,12 +581,18 @@ class VolregInputSpec(AFNICommandInputSpec):
582581
argstr='-tshift 0')
583582
copyorigin = traits.Bool(desc='copy base file origin coords to output',
584583
argstr='-twodup')
584+
oned_matrix_save = File(name_template='%s.aff12.1D',
585+
desc='Save the matrix transformation',
586+
argstr='-1Dmatrix_save %s',
587+
keep_extension=True,
588+
name_source="in_file")
585589

586590

587591
class VolregOutputSpec(TraitedSpec):
588592
out_file = File(desc='registered file', exists=True)
589593
md1d_file = File(desc='max displacement info file', exists=True)
590594
oned_file = File(desc='movement parameters info file', exists=True)
595+
oned_matrix_save = File(desc='matrix transformation from base to input', exists=True)
591596

592597

593598
class Volreg(AFNICommand):

nipype/interfaces/ants/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
# Segmentation Programs
14-
from .segmentation import Atropos, N4BiasFieldCorrection
14+
from .segmentation import Atropos, LaplacianThickness, N4BiasFieldCorrection
1515

1616
# Utility Programs
1717
from .utils import AverageAffineTransform, AverageImages, MultiplyImages, JacobianDeterminant

nipype/interfaces/ants/segmentation.py

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,67 @@ def _list_outputs(self):
160160
outputs['posteriors'].append(os.path.abspath(self.inputs.output_posteriors_name_template % (i + 1)))
161161
return outputs
162162

163+
class LaplacianThicknessInputSpec(ANTSCommandInputSpec):
164+
input_wm = File(argstr='%s', mandatory=True, copyfile=True,
165+
desc=('white matter segmentation image'),
166+
position=1)
167+
input_gm = File(argstr='%s', mandatory=True, copyfile=True,
168+
desc=('gray matter segmentation image'),
169+
position=2)
170+
output_image = File(desc='name of output file', argstr='%s', position=3,
171+
genfile=True, hash_files=False)
172+
smooth_param = traits.Float(argstr='smoothparam=%d', desc='', position=4)
173+
prior_thickness = traits.Float(argstr='priorthickval=%d', desc='',
174+
position=5)
175+
dT = traits.Float(argstr='dT=%d', desc='', position=6)
176+
sulcus_prior = traits.Bool(argstr='use-sulcus-prior', desc='', position=7)
177+
opt_tolerance = traits.Float(argstr='optional-laplacian-tolerance=%d',
178+
desc='', position=8)
179+
180+
181+
class LaplacianThicknessOutputSpec(TraitedSpec):
182+
output_image = File(exists=True, desc='Cortical thickness')
183+
184+
185+
class LaplacianThickness(ANTSCommand):
186+
"""Calculates the cortical thickness from an anatomical image
187+
188+
Examples
189+
--------
190+
191+
>>> from nipype.interfaces.ants import LaplacianThickness
192+
>>> cort_thick = LaplacianThickness()
193+
>>> cort_thick.inputs.input_wm = 'white_matter.nii.gz'
194+
>>> cort_thick.inputs.input_gm = 'gray_matter.nii.gz'
195+
>>> cort_thick.inputs.output_image = 'output_thickness.nii.gz'
196+
>>> cort_thick.cmdline
197+
'LaplacianThickness white_matter.nii.gz gray_matter.nii.gz output_thickness.nii.gz'
198+
199+
"""
200+
201+
_cmd = 'LaplacianThickness'
202+
input_spec = LaplacianThicknessInputSpec
203+
output_spec = LaplacianThicknessOutputSpec
204+
205+
def _gen_filename(self, name):
206+
if name == 'output_image':
207+
output = self.inputs.output_image
208+
if not isdefined(output):
209+
_, name, ext = split_filename(self.inputs.input_wm)
210+
output = name + '_thickness' + ext
211+
return output
212+
return None
213+
214+
def _list_outputs(self):
215+
outputs = self._outputs().get()
216+
_, name, ext = split_filename(os.path.abspath(self.inputs.input_wm))
217+
outputs['output_image'] = os.path.join(os.getcwd(),
218+
''.join((name,
219+
self.inputs.output_image,
220+
ext)))
221+
return outputs
222+
223+
163224
class N4BiasFieldCorrectionInputSpec(ANTSCommandInputSpec):
164225
dimension = traits.Enum(3, 2, argstr='--image-dimension %d',
165226
usedefault=True,
@@ -228,4 +289,4 @@ def _gen_filename(self, name):
228289
def _list_outputs(self):
229290
outputs = self._outputs().get()
230291
outputs['output_image'] = os.path.abspath(self._gen_filename('output_image'))
231-
return outputs
292+
return outputs

nipype/interfaces/base.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,7 @@ def _get_trait_desc(self, inputs, name, spec):
731731
desc = spec.desc
732732
xor = spec.xor
733733
requires = spec.requires
734+
argstr = spec.argstr
734735

735736
manhelpstr = ['\t%s' % name]
736737

@@ -753,6 +754,17 @@ def _get_trait_desc(self, inputs, name, spec):
753754
initial_indent='\t\t',
754755
subsequent_indent='\t\t')
755756

757+
if argstr:
758+
pos = spec.position
759+
if pos is not None:
760+
manhelpstr += wrap('flag: %s, position: %s' % (argstr, pos), 70,
761+
initial_indent='\t\t',
762+
subsequent_indent='\t\t')
763+
else:
764+
manhelpstr += wrap('flag: %s' % argstr, 70,
765+
initial_indent='\t\t',
766+
subsequent_indent='\t\t')
767+
756768
if xor:
757769
line = '%s' % ', '.join(xor)
758770
manhelpstr += wrap(line, 70,
@@ -1480,13 +1492,13 @@ def _filename_from_source(self, name):
14801492
_, _, ext = split_filename(retval)
14811493
if trait_spec.keep_extension and ext:
14821494
return retval
1483-
return self._overload_extension(retval)
1495+
return self._overload_extension(retval, name)
14841496
return retval
14851497

14861498
def _gen_filename(self, name):
14871499
raise NotImplementedError
14881500

1489-
def _overload_extension(self, value):
1501+
def _overload_extension(self, value, name=None):
14901502
return value
14911503

14921504
def _list_outputs(self):

nipype/interfaces/camino/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
ComputeTensorTrace, ComputeEigensystem, DTMetric)
1414
from .calib import (SFPICOCalibData, SFLUTGen)
1515
from .odf import (QBallMX, LinRecon, SFPeaks, MESD)
16+
from .utils import ImageStats
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from nipype.testing import assert_equal
3+
from nipype.interfaces.camino.utils import ImageStats
4+
5+
def test_ImageStats_inputs():
6+
input_map = dict(args=dict(argstr='%s',
7+
),
8+
environ=dict(nohash=True,
9+
usedefault=True,
10+
),
11+
ignore_exception=dict(nohash=True,
12+
usedefault=True,
13+
),
14+
in_files=dict(argstr='-images %s',
15+
mandatory=True,
16+
position=-1,
17+
),
18+
out_type=dict(argstr='-outputdatatype %s',
19+
usedefault=True,
20+
),
21+
output_root=dict(argstr='-outputroot %s',
22+
mandatory=True,
23+
),
24+
stat=dict(argstr='-stat %s',
25+
mandatory=True,
26+
units='NA',
27+
),
28+
terminal_output=dict(mandatory=True,
29+
nohash=True,
30+
),
31+
)
32+
inputs = ImageStats.input_spec()
33+
34+
for key, metadata in input_map.items():
35+
for metakey, value in metadata.items():
36+
yield assert_equal, getattr(inputs.traits()[key], metakey), value
37+
38+
def test_ImageStats_outputs():
39+
output_map = dict(out_file=dict(),
40+
)
41+
outputs = ImageStats.output_spec()
42+
43+
for key, metadata in output_map.items():
44+
for metakey, value in metadata.items():
45+
yield assert_equal, getattr(outputs.traits()[key], metakey), value
46+

nipype/interfaces/camino/utils.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
"""
2+
Change directory to provide relative paths for doctests
3+
>>> import os
4+
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
5+
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
6+
>>> os.chdir(datadir)
7+
8+
"""
9+
from nipype.interfaces.base import (traits, TraitedSpec, File,
10+
CommandLine, CommandLineInputSpec, isdefined,
11+
InputMultiPath)
12+
from nipype.utils.filemanip import split_filename
13+
import os
14+
15+
class ImageStatsInputSpec(CommandLineInputSpec):
16+
in_files = InputMultiPath(File(exists=True), argstr='-images %s', mandatory=True,
17+
position=-1, desc=('List of images to process. They must '
18+
'be in the same space and have the same '
19+
'dimensions.'))
20+
stat = traits.Enum("min", "max", "mean", "median", "sum", "std", "var",
21+
argstr='-stat %s', units='NA', mandatory=True,
22+
desc="The statistic to compute.")
23+
24+
out_type = traits.Enum("float", "char", "short", "int", "long", "double",
25+
argstr='-outputdatatype %s', usedefault=True,
26+
desc=('A Camino data type string, default is "float". '
27+
'Type must be signed.'))
28+
output_root = File(argstr='-outputroot %s', mandatory=True,
29+
desc=('Filename root prepended onto the names of the output '
30+
' files. The extension will be determined from the input.'))
31+
32+
class ImageStatsOutputSpec(TraitedSpec):
33+
out_file = File(exists=True, desc='Path of the file computed with the statistic chosen')
34+
35+
class ImageStats(CommandLine):
36+
"""
37+
This program computes voxelwise statistics on a series of 3D images. The images
38+
must be in the same space; the operation is performed voxelwise and one output
39+
is produced per voxel.
40+
41+
Examples
42+
--------
43+
44+
>>> import nipype.interfaces.camino as cam
45+
>>> imstats = cam.ImageStats()
46+
>>> imstats.inputs.in_files = ['im1.nii','im2.nii','im3.nii']
47+
>>> imstats.inputs.stat = 'max'
48+
>>> imstats.run() # doctest: +SKIP
49+
"""
50+
_cmd = 'imagestats'
51+
input_spec = ImageStatsInputSpec
52+
output_spec = ImageStatsOutputSpec
53+
54+
def _list_outputs(self):
55+
outputs = self.output_spec().get()
56+
outputs['out_file'] = os.path.abspath(self._gen_outfilename())
57+
return outputs
58+
59+
def _gen_outfilename(self):
60+
output_root = self.inputs.output_root
61+
first_file = self.inputs.in_files[0]
62+
_, _ , ext = split_filename(first_file)
63+
return output_root + ext

nipype/interfaces/fsl/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def _gen_fname(self, basename, cwd=None, suffix=None, change_ext=True,
239239
use_ext=False, newpath=cwd)
240240
return fname
241241

242-
def _overload_extension(self, value):
242+
def _overload_extension(self, value, name=None):
243243
return value + Info.output_type_to_ext(self.inputs.output_type)
244244

245245

0 commit comments

Comments
 (0)