Skip to content

Commit 641fc7c

Browse files
committed
Merge branch 'fsl_model'
2 parents d486984 + 6d90447 commit 641fc7c

File tree

3 files changed

+67
-4
lines changed

3 files changed

+67
-4
lines changed

CHANGES

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Next release
22
============
3-
* ENH: New interfaces: nipy.Trim
3+
* ENH: New interfaces: nipy.Trim, fsl.GLM, fsl.SigLoss
44

55
* ENH: Allow control over terminal output for commandline interfaces
66
* ENH: New workflows for dMRI and fMRI pre-processing: added motion artifact correction

nipype/interfaces/fsl/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
SliceTimer, SUSAN, PRELUDE, FUGUE, FIRST)
1212
from .model import (Level1Design, FEAT, FEATModel, FILMGLS, FEATRegister,
1313
FLAMEO, ContrastMgr, MultipleRegressDesign, L2Model, SMM,
14-
MELODIC, SmoothEstimate, Cluster, Randomise)
14+
MELODIC, SmoothEstimate, Cluster, Randomise, GLM)
1515
from .utils import (Smooth, Merge, ExtractROI, Split, ImageMaths, ImageMeants,
1616
ImageStats, FilterRegressor, Overlay, Slicer,
1717
PlotTimeSeries, PlotMotionParams, ConvertXFM,

nipype/interfaces/fsl/model.py

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818

1919
import numpy as np
2020

21-
from nipype.interfaces.fsl.base import (FSLCommand, FSLCommandInputSpec)
21+
from nipype.interfaces.fsl.base import (FSLCommand, FSLCommandInputSpec, Info)
2222
from nipype.interfaces.base import (load_template, File, traits, isdefined,
2323
TraitedSpec, BaseInterface, Directory,
2424
InputMultiPath, OutputMultiPath,
2525
BaseInterfaceInputSpec)
26-
from nipype.utils.filemanip import (list_to_filename, filename_to_list)
26+
from nipype.utils.filemanip import (list_to_filename, filename_to_list, split_filename)
2727
from nibabel import load
2828

2929
warn = warnings.warn
@@ -1511,3 +1511,66 @@ def _list_outputs(self):
15111511
outputs['f_corrected_p_files'] = glob(self._gen_fname(\
15121512
'%s_%s_corrp_fstat*.nii' % (self.inputs.base_name, prefix)))
15131513
return outputs
1514+
1515+
1516+
class GLMInputSpec(FSLCommandInputSpec):
1517+
in_file = File(
1518+
exists=True,mandatory=True,
1519+
argstr='-i %s',
1520+
desc='input 3d+t file',)
1521+
design = File(
1522+
exists=True, mandatory=True,
1523+
argstr='-d %s',
1524+
desc='design file or image file')
1525+
out_file = File(
1526+
genfile=True, argstr="-o %s",
1527+
desc="file or image output")
1528+
mask = File(
1529+
exists=True,
1530+
argstr='-m %s',
1531+
desc='mask file')
1532+
contrasts = File(
1533+
exists=True,
1534+
argstr='-c %s',
1535+
desc='t-contrasts file')
1536+
options = traits.String(
1537+
argstr='%s',
1538+
desc = 'fsl_glm options')
1539+
class GLMOutputSpec(TraitedSpec):
1540+
out_file = File(
1541+
exists=True,
1542+
desc = 'file or image output')
1543+
1544+
class GLM(FSLCommand):
1545+
"""
1546+
FSL GLM:
1547+
1548+
Example
1549+
-------
1550+
>>> import nipype.interfaces.fsl as fsl
1551+
>>> glm = fsl.GLM(in_file='functional.nii', design = 'maps.nii')
1552+
>>> glm.cmdline
1553+
"""
1554+
_cmd = 'fsl_glm'
1555+
input_spec = GLMInputSpec
1556+
output_spec = GLMOutputSpec
1557+
1558+
def _list_outputs(self):
1559+
outputs = self.output_spec().get()
1560+
outputs['out_file'] = self.inputs.out_file
1561+
# Generate an out_file if one is not provided
1562+
if not isdefined(outputs['out_file']) and isdefined(self.inputs.in_file):
1563+
ext = Info.output_type_to_ext(self.inputs.output_type)
1564+
if split_filename(self.inputs.in_file)[-1] in Info.ftypes.values():
1565+
ext = '.txt'
1566+
outputs['out_file'] = self._gen_fname(self.inputs.in_file,
1567+
suffix='_glm',
1568+
ext=ext)
1569+
1570+
return outputs
1571+
1572+
def _gen_filename(self, name):
1573+
if name in ('out_file'):
1574+
return self._list_outputs()[name]
1575+
else:
1576+
return None

0 commit comments

Comments
 (0)