Repository: nipy/nipype

Issue:
nipype depends on dev version of nipy
```
/scr/melisse1/dev/nipype/nipype/interfaces/nipy/preprocess.py in <module>()
    25     from nipy.algorithms.registration import FmriRealign4d as FR4d
    26     from nipy import save_image, load_image
---> 27     from nipy.algorithms.registration import SpaceTimeRealign
    28     from nipy.algorithms.registration.groupwise_registration import SpaceRealign
    29 

ImportError: cannot import name SpaceTimeRealign
```



Discussion:

Resolving patch:
diff --git a/nipype/interfaces/freesurfer/__init__.py b/nipype/interfaces/freesurfer/__init__.py
--- a/nipype/interfaces/freesurfer/__init__.py
+++ b/nipype/interfaces/freesurfer/__init__.py
@@ -11,4 +11,5 @@
                     SegStats, Label2Vol, MS_LDA)
 from .utils import (SampleToSurface, SurfaceSmooth, SurfaceTransform,
                     SurfaceSnapshots,ApplyMask, MRIsConvert, MRITessellate,
-                    MRIMarchingCubes, SmoothTessellation, MakeAverageSubject)
+                    MRIMarchingCubes, SmoothTessellation, MakeAverageSubject,
+                    ExtractMainComponent)
diff --git a/nipype/interfaces/freesurfer/preprocess.py b/nipype/interfaces/freesurfer/preprocess.py
--- a/nipype/interfaces/freesurfer/preprocess.py
+++ b/nipype/interfaces/freesurfer/preprocess.py
@@ -28,6 +28,9 @@
                                     CommandLineInputSpec, isdefined)
 
 
+from ... import logging
+iflogger = logging.getLogger('interface')
+
 class ParseDICOMDirInputSpec(FSTraitedSpec):
     dicom_dir = Directory(exists=True, argstr='--d %s', mandatory=True,
                          desc='path to siemens dicom directory')
@@ -593,7 +596,8 @@ class ReconAllInputSpec(CommandLineInputSpec):
     directive = traits.Enum('all', 'autorecon1', 'autorecon2', 'autorecon2-cp',
                             'autorecon2-wm', 'autorecon2-inflate1', 'autorecon2-perhemi',
                             'autorecon3', 'localGI', 'qcache', argstr='-%s',
-                            desc='process directive', usedefault=True)
+                            desc='process directive', usedefault=True,
+                            position=0)
     hemi = traits.Enum('lh', 'rh', desc='hemisphere to process', argstr="-hemi %s")
     T1_files = InputMultiPath(File(exists=True), argstr='-i %s...',
                               desc='name of T1 file to process')
@@ -621,7 +625,7 @@ class ReconAll(CommandLine):
     >>> reconall.inputs.subjects_dir = '.'
     >>> reconall.inputs.T1_files = 'structural.nii'
     >>> reconall.cmdline
-    'recon-all -i structural.nii -all -subjid foo -sd .'
+    'recon-all -all -i structural.nii -subjid foo -sd .'
 
     """
 
@@ -629,6 +633,89 @@ class ReconAll(CommandLine):
     _additional_metadata = ['loc', 'altkey']
     input_spec = ReconAllInputSpec
     output_spec = ReconAllIOutputSpec
+    _can_resume = True
+
+
+    _steps = [
+        #autorecon1
+        ('motioncor', ['mri/rawavg.mgz', 'mri/orig.mgz']),
+        ('talairach', ['mri/transforms/talairach.auto.xfm',
+                       'mri/transforms/talairach.xfm']),
+        ('nuintensitycor', ['mri/nu.mgz']),
+        ('normalization', ['mri/T1.mgz']),
+        ('skullstrip',
+         ['mri/transforms/talairach_with_skull.lta',
+          'mri/brainmask.auto.mgz',
+          'mri/brainmask.mgz']),
+        #autorecon2
+        ('gcareg', ['mri/transforms/talairach.lta']),
+        ('canorm', ['mri/norm.mgz']),
+        ('careg', ['mri/transforms/talairach.m3z']),
+        ('careginv', ['mri/transforms/talairach.m3z.inv.x.mgz',
+                      'mri/transforms/talairach.m3z.inv.y.mgz',
+                      'mri/transforms/talairach.m3z.inv.z.mgz']),
+        ('rmneck', ['mri/nu_noneck.mgz']),
+        ('skull-lta', ['mri/transforms/talairach_with_skull_2.lta']),
+        ('calabel',
+         ['mri/aseg.auto_noCCseg.mgz', 'mri/aseg.auto.mgz', 'mri/aseg.mgz']),
+        ('normalization2', ['mri/brain.mgz']),
+        ('maskbfs', ['mri/brain.finalsurfs.mgz']),
+        ('segmentation', ['mri/wm.asegedit.mgz', 'mri/wm.mgz']),
+        ('fill', ['mri/filled.mgz']),
+        ('tessellate', ['surf/lh.orig.nofix', 'surf/rh.orig.nofix']),
+        ('smooth1', ['surf/lh.smoothwm.nofix', 'surf/rh.smoothwm.nofix']),
+        ('inflate1', ['surf/lh.inflated.nofix', 'surf/rh.inflated.nofix']),
+        ('qsphere', ['surf/lh.qsphere.nofix', 'surf/rh.qsphere.nofix']),
+        ('fix', ['surf/lh.orig', 'surf/rh.orig']),
+        ('white',
+         ['surf/lh.white',
+          'surf/rh.white',
+          'surf/lh.curv',
+          'surf/rh.curv',
+          'surf/lh.area',
+          'surf/rh.area',
+          'label/lh.cortex.label',
+          'label/rh.cortex.label']),
+        ('smooth2', ['surf/lh.smoothwm', 'surf/rh.smoothwm']),
+        ('inflate2',
+         ['surf/lh.inflated',
+          'surf/rh.inflated',
+          'surf/lh.sulc',
+          'surf/rh.sulc',
+          'surf/lh.inflated.H',
+          'surf/rh.inflated.H',
+          'surf/lh.inflated.K',
+          'surf/rh.inflated.K']),
+        #autorecon3
+        ('sphere', ['surf/lh.sphere', 'surf/rh.sphere']),
+        ('surfreg', ['surf/lh.sphere.reg', 'surf/rh.sphere.reg']),
+        ('jacobian_white', ['surf/lh.jacobian_white',
+                            'surf/rh.jacobian_white']),
+        ('avgcurv', ['surf/lh.avg_curv', 'surf/rh.avg_curv']),
+        ('cortparc', ['label/lh.aparc.annot', 'label/rh.aparc.annot']),
+        ('pial',
+         ['surf/lh.pial',
+          'surf/rh.pial',
+          'surf/lh.curv.pial',
+          'surf/rh.curv.pial',
+          'surf/lh.area.pial',
+          'surf/rh.area.pial',
+          'surf/lh.thickness',
+          'surf/rh.thickness']),
+        ('cortparc2', ['label/lh.aparc.a2009s.annot',
+                       'label/rh.aparc.a2009s.annot']),
+        ('parcstats2',
+         ['stats/lh.aparc.a2009s.stats',
+          'stats/rh.aparc.a2009s.stats',
+          'stats/aparc.annot.a2009s.ctab']),
+        ('cortribbon', ['mri/lh.ribbon.mgz', 'mri/rh.ribbon.mgz',
+                        'mri/ribbon.mgz']),
+        ('segstats', ['stats/aseg.stats']),
+        ('aparc2aseg', ['mri/aparc+aseg.mgz', 'mri/aparc.a2009s+aseg.mgz']),
+        ('wmparc', ['mri/wmparc.mgz', 'stats/wmparc.stats']),
+        ('balabels', ['BA.ctab', 'BA.thresh.ctab']),
+        ('label-exvivo-ec', ['label/lh.entorhinal_exvivo.label',
+                             'label/rh.entorhinal_exvivo.label'])]
 
     def _gen_subjects_dir(self):
         return os.getcwd()
@@ -660,6 +747,39 @@ def _list_outputs(self):
         outputs['subjects_dir'] = subjects_dir
         return outputs
 
+    @property
+    def cmdline(self):
+        subjects_dir = self.inputs.subjects_dir
+        if not isdefined(subjects_dir):
+            subjects_dir = self._gen_subjects_dir()
+        if not os.path.isdir(
+            os.path.join(subjects_dir,self.inputs.subject_id,'mri')):
+            return super(ReconAll, self).cmdline
+        self._check_mandatory_inputs()
+        skip = ['T1_files']
+        subjects_dir = self.inputs.subjects_dir
+        if not isdefined(subjects_dir):
+            subjects_dir = self._gen_subjects_dir()
+        flags = []
+        directive = 'all'
+        for idx, step in enumerate(self._steps):
+            step, outfiles = step
+            if all([os.path.exists(os.path.join(subjects_dir,self.inputs.subject_id,f)) for f  in outfiles]):
+                flags.append('-no%s'%step)
+                if idx > 4:
+                    directive = 'autorecon2'
+                elif idx > 23:
+                    directive = 'autorecon3'
+            else:
+                flags.append('-%s'%step)
+        self.inputs.args = ' '.join([self.inputs.args] + flags)
+        self.inputs.directive = directive
+        allargs = self._parse_inputs(skip=skip)
+        allargs.insert(0, self.cmd)
+        cmd = ' '.join(allargs)
+        iflogger.info('resume recon-all : %s'%cmd)
+        return cmd
+    
 
 class BBRegisterInputSpec(FSTraitedSpec):
     subject_id = traits.Str(argstr='--s %s',
diff --git a/nipype/interfaces/freesurfer/utils.py b/nipype/interfaces/freesurfer/utils.py
--- a/nipype/interfaces/freesurfer/utils.py
+++ b/nipype/interfaces/freesurfer/utils.py
@@ -16,7 +16,7 @@
 from nipype.utils.filemanip import fname_presuffix, split_filename
 
 from nipype.interfaces.freesurfer.base import FSCommand, FSTraitedSpec
-from nipype.interfaces.base import TraitedSpec, File, traits, OutputMultiPath, isdefined
+from nipype.interfaces.base import TraitedSpec, File, traits, OutputMultiPath, isdefined, CommandLine, CommandLineInputSpec
 
 filemap = dict(cor='cor', mgh='mgh', mgz='mgz', minc='mnc',
                afni='brik', brik='brik', bshort='bshort',
@@ -1026,3 +1026,32 @@ def _list_outputs(self):
         outputs = self.output_spec().get()
         outputs['average_subject_name'] = self.inputs.out_name
         return outputs
+
+class ExtractMainComponentInputSpec(CommandLineInputSpec):
+    in_file = File(
+        exists=True, mandatory=True, argstr='%s', position=1,
+        desc='input surface file')
+    out_file = File(
+        name_template ='%s.maincmp', name_source='in_file',
+        argstr='%s', position=2, keep_extension = True,
+        desc='surface containing main component')
+
+class ExtractMainComponentOutputSpec(TraitedSpec):
+    out_file = File(exists=True, desc='surface containing main component')
+
+class ExtractMainComponent(CommandLine):
+    """Extract the main component of a tesselated surface
+
+    Examples
+    --------
+
+    >>> from nipype.interfaces.freesurfer import ExtractMainComponent
+    >>> mcmp = ExtractMainComponent(in_file='lh.pial')
+    >>> mcmp.cmdline
+    'mris_extract_main_component lh.pial lh.pial.maincmp'
+
+    """    
+
+    _cmd='mris_extract_main_component'
+    input_spec=ExtractMainComponentInputSpec
+    output_spec=ExtractMainComponentOutputSpec


Test patch: