Repository: nipy/nipype

Issue:
Missing mask1 and mask2 arguments in doc example for Similarity
The mandatory arguments mask1 and mask2 are missing from the example here:

http://nipy.sourceforge.net/nipype/interfaces/generated/nipype.interfaces.nipy.utils.html

ApplyXFM does not set default value of required flag
from @davidgutman

Just noticed this, after scratching my head for a bit....  by default
it seems the ApplyXfm doesn't bass the applyxfm.inputs.apply_xfm=True
parameter... in which case it is rerunning the registration ...

I couldn't figure out why my transformation was working oddly and
realized it's because that flag wasn't being passed, and I
inadvertently assumed that that was the default behavior of ApplyXfm
(i.e. to apply an XFM)....

Not sure if this should be changed or not as the default behavior that
can be overridden (in which case.. you'd probably just want to use
fsl.FLIRT() anyway)..

More of a semantics thing I guess..

ApplyXfm
Code: http://github.com/nipy/nipype/blob/master/nipype/interfaces/fsl/preprocess.py#L495

Wraps command flirt

Currently just a light wrapper around FLIRT, with no modifications

ApplyXfm is used to apply an existing tranform to an image

Examples

> > > import nipype.interfaces.fsl as fsl
> > > from nipype.testing import example_data
> > > applyxfm = fsl.ApplyXfm()
> > > applyxfm.inputs.in_file = example_data('structural.nii')
> > > applyxfm.inputs.in_matrix_file = example_data('trans.mat')
> > > applyxfm.inputs.out_file = 'newfile.nii'
> > > applyxfm.inputs.reference = example_data('mni.nii')
> > > applyxfm.inputs.apply_xfm = True
> > > result = applyxfm.run()
> > > Inputs:

[Mandatory]
in_file: (an existing file name)
        input file
reference: (an existing file name)
        reference file

[Optional]
angle_rep: ('quaternion' or 'euler')
        representation of rotation angles
apply_xfm: (a boolean)
        apply transformation supplied by in_matrix_file
## 

David A Gutman, M.D. Ph.D.



Discussion:

Resolving patch:
diff --git a/nipype/interfaces/fsl/__init__.py b/nipype/interfaces/fsl/__init__.py
--- a/nipype/interfaces/fsl/__init__.py
+++ b/nipype/interfaces/fsl/__init__.py
@@ -11,7 +11,7 @@
                          SliceTimer, SUSAN, PRELUDE, FUGUE, FIRST)
 from .model import (Level1Design, FEAT, FEATModel, FILMGLS, FEATRegister,
                     FLAMEO, ContrastMgr, MultipleRegressDesign, L2Model, SMM,
-                    MELODIC, SmoothEstimate, Cluster, Randomise)
+                    MELODIC, SmoothEstimate, Cluster, Randomise, GLM)
 from .utils import (Smooth, Merge, ExtractROI, Split, ImageMaths, ImageMeants,
                     ImageStats, FilterRegressor, Overlay, Slicer,
                     PlotTimeSeries, PlotMotionParams, ConvertXFM,
diff --git a/nipype/interfaces/fsl/model.py b/nipype/interfaces/fsl/model.py
--- a/nipype/interfaces/fsl/model.py
+++ b/nipype/interfaces/fsl/model.py
@@ -18,12 +18,12 @@
 
 import numpy as np
 
-from nipype.interfaces.fsl.base import (FSLCommand, FSLCommandInputSpec)
+from nipype.interfaces.fsl.base import (FSLCommand, FSLCommandInputSpec, Info)
 from nipype.interfaces.base import (load_template, File, traits, isdefined,
                                     TraitedSpec, BaseInterface, Directory,
                                     InputMultiPath, OutputMultiPath,
                                     BaseInterfaceInputSpec)
-from nipype.utils.filemanip import (list_to_filename, filename_to_list)
+from nipype.utils.filemanip import (list_to_filename, filename_to_list, split_filename)
 from nibabel import load
 
 warn = warnings.warn
@@ -1511,3 +1511,66 @@ def _list_outputs(self):
             outputs['f_corrected_p_files'] = glob(self._gen_fname(\
                 '%s_%s_corrp_fstat*.nii' % (self.inputs.base_name, prefix)))
         return outputs
+
+
+class GLMInputSpec(FSLCommandInputSpec):
+    in_file = File(
+        exists=True,mandatory=True,
+        argstr='-i %s',
+        desc='input 3d+t file',)
+    design = File(
+        exists=True, mandatory=True,
+        argstr='-d %s',
+        desc='design file or image file')
+    out_file = File(
+        genfile=True, argstr="-o %s",
+        desc="file or image output")
+    mask = File(
+        exists=True,
+        argstr='-m %s',
+        desc='mask file')
+    contrasts = File(
+        exists=True,
+        argstr='-c %s',
+        desc='t-contrasts file')
+    options = traits.String(
+        argstr='%s',
+        desc = 'fsl_glm options')
+class GLMOutputSpec(TraitedSpec):
+    out_file = File(
+        exists=True,
+        desc = 'file or image output')
+
+class GLM(FSLCommand):
+    """
+    FSL GLM: 
+
+    Example
+    -------
+    >>> import nipype.interfaces.fsl as fsl
+    >>> glm = fsl.GLM(in_file='functional.nii', design = 'maps.nii')
+    >>> glm.cmdline
+    """
+    _cmd = 'fsl_glm'
+    input_spec = GLMInputSpec
+    output_spec = GLMOutputSpec
+
+    def _list_outputs(self):
+        outputs = self.output_spec().get()
+        outputs['out_file'] = self.inputs.out_file
+        # Generate an out_file if one is not provided
+        if not isdefined(outputs['out_file']) and isdefined(self.inputs.in_file):
+            ext = Info.output_type_to_ext(self.inputs.output_type)
+            if split_filename(self.inputs.in_file)[-1] in Info.ftypes.values():
+                ext = '.txt'
+            outputs['out_file'] = self._gen_fname(self.inputs.in_file,
+                                                  suffix='_glm',
+                                                  ext=ext)
+
+        return outputs
+
+    def _gen_filename(self, name):
+        if name in ('out_file'):
+            return self._list_outputs()[name]
+        else:
+            return None


Test patch: