Skip to content

Commit 714d94d

Browse files
committed
Merge and clean up FSLGLM into GLM.
1 parent 7708b9c commit 714d94d

File tree

2 files changed

+118
-202
lines changed

2 files changed

+118
-202
lines changed

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, GLM, FSLGLM)
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: 117 additions & 201 deletions
Original file line numberDiff line numberDiff line change
@@ -549,180 +549,6 @@ def _list_outputs(self):
549549
cwd=results_dir)
550550
return outputs
551551

552-
class FSLGLMInputSpec(FSLCommandInputSpec):
553-
"""
554-
Use FSL GLM
555-
@author: sebastian urchs
556-
557-
558-
"""
559-
560-
in_file = File(exists=True, argstr='-i %s', mandatory=True, position=1,
561-
desc='input file name (text matrix or 3D/4D image file)')
562-
563-
output_file = File(argstr='-o %s', mandatory=True, position=3,
564-
desc=('filename for GLM parameter estimates'
565-
+ ' (GLM betas)'))
566-
567-
design_file = File(exists=True, argstr='-d %s', mandatory=True, position=2,
568-
desc=('file name of the GLM design matrix (text time'
569-
+ ' courses for temporal regression or an image'
570-
+ ' file for spatial regression)'))
571-
572-
contrasts = File(exists=True, argstr='-c %s', desc=('matrix of t-statics'
573-
+ ' contrasts'))
574-
575-
mask = File(exists=True, argstr='-m %s', desc=('mask image file name if'
576-
+ ' input is image'))
577-
578-
dof = traits.Int(argstr='--dof %d', desc=('set degrees of freedom'
579-
+ ' explicitly'))
580-
581-
des_norm = traits.Bool(argstr='--des_norm', desc=('switch on normalization'
582-
+ ' of the design matrix'
583-
+ ' columns to unit std'
584-
+ ' deviation'))
585-
586-
dat_norm = traits.Bool(argstr='--dat_norm', desc=('switch on normalization'
587-
+ ' of the data time'
588-
+ ' series to unit std'
589-
+ ' deviation'))
590-
591-
var_norm = traits.Bool(argstr='--vn', desc=('perform MELODIC variance-'
592-
+ 'normalisation on data'))
593-
594-
demean = traits.Bool(argstr='--demean', desc=('switch on demeaining of '
595-
+ ' design and data'))
596-
597-
out_cope = File(argstr='--out_cope=%s',
598-
desc='output file name for COPE (either as txt or image')
599-
600-
out_z_name = File(argstr='--out_z=%s',
601-
desc='output file name for Z-stats (either as txt or image')
602-
603-
out_t_name = File(argstr='--out_t=%s',
604-
desc='output file name for t-stats (either as txt or image')
605-
606-
out_p_name = File(argstr='--out_p=%s',
607-
desc=('output file name for p-values of Z-stats (either as'
608-
+ ' text file or image)'))
609-
610-
out_f_name = File(argstr='--out_f=%s',
611-
desc='output file name for F-value of full model fit')
612-
613-
out_pf_name = File(argstr='--out_pf=%s',
614-
desc='output file name for p-value for full model fit')
615-
616-
out_res_name = File(argstr='--out_res=%s',
617-
desc='output file name for residuals')
618-
619-
out_varcb_name = File(argstr='--out_varcb=%s',
620-
desc='output file name for variance of COPEs')
621-
622-
out_sigsq_name = File(argstr='--out_sigsq=%s',
623-
desc=('output file name for residual noise variance'
624-
+ ' sigma-square'))
625-
626-
out_data_name = File(argstr='--out_data=%s',
627-
desc='output file name for pre-processed data')
628-
629-
out_vnscales_name = File(argstr='--out_vnscales=%s',
630-
desc=('output file name for scaling factors for variance'
631-
+ ' normalisation'))
632-
633-
634-
class FSLGLMOutputSpec(TraitedSpec):
635-
out_file = File(exists=True, desc=('file name of GLM parameters'
636-
+ ' (if generated)'))
637-
638-
out_cope = OutputMultiPath(exists=True, desc='output file name for COPEs' +
639-
' (either as text file or image)')
640-
641-
out_z = OutputMultiPath(exists=True, desc='output file name for COPEs' +
642-
' (either as text file or image)')
643-
644-
out_t = OutputMultiPath(exists=True, desc='output file name for t-stats' +
645-
' (either as text file or image)')
646-
647-
out_p = OutputMultiPath(exists=True, desc='output file name for p-values' +
648-
' of Z-stats (either as text file or image)')
649-
650-
out_f = OutputMultiPath(exists=True, desc='output file name for F-value' +
651-
' of full model fit')
652-
653-
out_pf = OutputMultiPath(exists=True, desc='output file name for p-value' +
654-
' for full model fit')
655-
656-
out_res = OutputMultiPath(exists=True, desc='output file name for' +
657-
' residuals')
658-
659-
out_varcb = OutputMultiPath(exists=True, desc='output file name for' +
660-
' variance of COPEs')
661-
662-
out_sigsq = OutputMultiPath(exists=True, desc='output file name for' +
663-
' residual noise variance sigma-square')
664-
665-
out_data = OutputMultiPath(exists=True, desc='output file name for' +
666-
' residual noise variance sigma-square')
667-
668-
out_vnscales = OutputMultiPath(exists=True, desc='output file name' +
669-
' for scaling factors for variance' +
670-
' normalisation')
671-
672-
673-
class FSLGLM(FSLCommand):
674-
"""
675-
Use FSL GLM.
676-
@author: sebastian urchs
677-
678-
@status: testing
679-
680-
"""
681-
_cmd = 'fsl_glm'
682-
input_spec = FSLGLMInputSpec
683-
output_spec = FSLGLMOutputSpec
684-
685-
def _list_outputs(self):
686-
import os
687-
outputs = self.output_spec().get()
688-
689-
outputs['out_file'] = os.path.join(os.getcwd(), self.inputs.output_file)
690-
691-
if isdefined(self.inputs.out_cope):
692-
outputs['out_cope'] = os.path.join(os.getcwd(), self.inputs.out_cope)
693-
694-
if isdefined(self.inputs.out_z_name):
695-
outputs['out_z'] = os.path.join(os.getcwd(), self.inputs.out_z_name)
696-
697-
if isdefined(self.inputs.out_t_name):
698-
outputs['out_t'] = os.path.join(os.getcwd(), self.inputs.out_t_name)
699-
700-
if isdefined(self.inputs.out_p_name):
701-
outputs['out_p'] = os.path.join(os.getcwd(), self.inputs.out_p_name)
702-
703-
if isdefined(self.inputs.out_f_name):
704-
outputs['out_f'] = os.path.join(os.getcwd(), self.inputs.out_f_name)
705-
706-
if isdefined(self.inputs.out_pf_name):
707-
outputs['out_pf'] = os.path.join(os.getcwd(), self.inputs.out_pf_name)
708-
709-
if isdefined(self.inputs.out_res_name):
710-
outputs['out_res'] = os.path.join(os.getcwd(), self.inputs.out_res_name)
711-
712-
if isdefined(self.inputs.out_varcb_name):
713-
outputs['out_varcb'] = os.path.join(os.getcwd(), self.inputs.out_varcb_name)
714-
715-
if isdefined(self.inputs.out_sigsq_name):
716-
outputs['out_sigsq'] = os.path.join(os.getcwd(), self.inputs.out_sigsq_name)
717-
718-
if isdefined(self.inputs.out_data_name):
719-
outputs['out_data'] = os.path.join(os.getcwd(), self.inputs.out_data_name)
720-
721-
if isdefined(self.inputs.out_vnscales_name):
722-
outputs['out_vnscales'] = os.path.join(os.getcwd(), self.inputs.out_vnscales_name)
723-
724-
return outputs
725-
726552

727553

728554
class FEATRegisterInputSpec(BaseInterfaceInputSpec):
@@ -1686,34 +1512,88 @@ def _list_outputs(self):
16861512

16871513

16881514
class GLMInputSpec(FSLCommandInputSpec):
1689-
in_file = File(
1690-
exists=True,mandatory=True,
1691-
argstr='-i %s',
1692-
desc='input 3d+t file',)
1693-
design = File(
1694-
exists=True, mandatory=True,
1695-
argstr='-d %s',
1696-
desc='design file or image file')
1697-
out_file = File(
1698-
genfile=True, argstr="-o %s",
1699-
desc="file or image output")
1700-
mask = File(
1701-
exists=True,
1702-
argstr='-m %s',
1703-
desc='mask file')
1704-
contrasts = File(
1705-
exists=True,
1706-
argstr='-c %s',
1707-
desc='t-contrasts file')
1708-
options = traits.String(
1709-
argstr='%s',
1710-
desc = 'fsl_glm options')
1515+
in_file = File(exists=True, argstr='-i %s', mandatory=True, position=1,
1516+
desc='input file name (text matrix or 3D/4D image file)')
1517+
out_file = File(argstr='-o %s', genfile=True, position=3,
1518+
desc=('filename for GLM parameter estimates'
1519+
+ ' (GLM betas)'))
1520+
design = File(exists=True, argstr='-d %s', mandatory=True, position=2,
1521+
desc=('file name of the GLM design matrix (text time'
1522+
+ ' courses for temporal regression or an image'
1523+
+ ' file for spatial regression)'))
1524+
contrasts = File(exists=True, argstr='-c %s', desc=('matrix of t-statics'
1525+
+ ' contrasts'))
1526+
mask = File(exists=True, argstr='-m %s', desc=('mask image file name if'
1527+
+ ' input is image'))
1528+
dof = traits.Int(argstr='--dof %d', desc=('set degrees of freedom'
1529+
+ ' explicitly'))
1530+
des_norm = traits.Bool(argstr='--des_norm', desc=('switch on normalization'
1531+
+ ' of the design matrix'
1532+
+ ' columns to unit std'
1533+
+ ' deviation'))
1534+
dat_norm = traits.Bool(argstr='--dat_norm', desc=('switch on normalization'
1535+
+ ' of the data time'
1536+
+ ' series to unit std'
1537+
+ ' deviation'))
1538+
var_norm = traits.Bool(argstr='--vn', desc=('perform MELODIC variance-'
1539+
+ 'normalisation on data'))
1540+
demean = traits.Bool(argstr='--demean', desc=('switch on demeaining of '
1541+
+ ' design and data'))
1542+
out_cope = File(argstr='--out_cope=%s',
1543+
desc='output file name for COPE (either as txt or image')
1544+
out_z_name = File(argstr='--out_z=%s',
1545+
desc='output file name for Z-stats (either as txt or image')
1546+
out_t_name = File(argstr='--out_t=%s',
1547+
desc='output file name for t-stats (either as txt or image')
1548+
1549+
out_p_name = File(argstr='--out_p=%s',
1550+
desc=('output file name for p-values of Z-stats (either as'
1551+
+ ' text file or image)'))
1552+
out_f_name = File(argstr='--out_f=%s',
1553+
desc='output file name for F-value of full model fit')
1554+
out_pf_name = File(argstr='--out_pf=%s',
1555+
desc='output file name for p-value for full model fit')
1556+
out_res_name = File(argstr='--out_res=%s',
1557+
desc='output file name for residuals')
1558+
out_varcb_name = File(argstr='--out_varcb=%s',
1559+
desc='output file name for variance of COPEs')
1560+
1561+
out_sigsq_name = File(argstr='--out_sigsq=%s',
1562+
desc=('output file name for residual noise variance'
1563+
+ ' sigma-square'))
1564+
out_data_name = File(argstr='--out_data=%s',
1565+
desc='output file name for pre-processed data')
1566+
out_vnscales_name = File(argstr='--out_vnscales=%s',
1567+
desc=('output file name for scaling factors for variance'
1568+
+ ' normalisation'))
17111569

17121570

17131571
class GLMOutputSpec(TraitedSpec):
1714-
out_file = File(
1715-
exists=True,
1716-
desc = 'file or image output')
1572+
out_file = File(exists=True, desc=('file name of GLM parameters'
1573+
+ ' (if generated)'))
1574+
out_cope = OutputMultiPath(exists=True, desc='output file name for COPEs' +
1575+
' (either as text file or image)')
1576+
out_z = OutputMultiPath(exists=True, desc='output file name for COPEs' +
1577+
' (either as text file or image)')
1578+
out_t = OutputMultiPath(exists=True, desc='output file name for t-stats' +
1579+
' (either as text file or image)')
1580+
out_p = OutputMultiPath(exists=True, desc='output file name for p-values' +
1581+
' of Z-stats (either as text file or image)')
1582+
out_f = OutputMultiPath(exists=True, desc='output file name for F-value' +
1583+
' of full model fit')
1584+
out_pf = OutputMultiPath(exists=True, desc='output file name for p-value' +
1585+
' for full model fit')
1586+
out_res = OutputMultiPath(exists=True, desc='output file name for' +
1587+
' residuals')
1588+
out_varcb = OutputMultiPath(exists=True, desc='output file name for' +
1589+
' variance of COPEs')
1590+
out_sigsq = OutputMultiPath(exists=True, desc='output file name for' +
1591+
' residual noise variance sigma-square')
1592+
out_data = OutputMultiPath(exists=True, desc='output file name for' +
1593+
' residual noise variance sigma-square')
1594+
out_vnscales = OutputMultiPath(exists=True, desc='output file name' +
1595+
' for scaling factors for variance' +
1596+
' normalisation')
17171597

17181598

17191599
class GLM(FSLCommand):
@@ -1731,13 +1611,49 @@ class GLM(FSLCommand):
17311611
_cmd = 'fsl_glm'
17321612
input_spec = GLMInputSpec
17331613
output_spec = GLMOutputSpec
1734-
1614+
17351615
def _list_outputs(self):
17361616
outputs = self.output_spec().get()
1617+
17371618
outputs['out_file'] = self.inputs.out_file
17381619
# Generate an out_file if one is not provided
17391620
if not isdefined(outputs['out_file']) and isdefined(self.inputs.in_file):
1740-
outputs['out_file'] = os.path.abspath(self._gen_filename('out_file'))
1621+
outputs['out_file'] = self._gen_filename('out_file')
1622+
outputs['out_file'] = os.path.abspath(outputs['out_file'])
1623+
1624+
if isdefined(self.inputs.out_cope):
1625+
outputs['out_cope'] = os.path.abspath(self.inputs.out_cope)
1626+
1627+
if isdefined(self.inputs.out_z_name):
1628+
outputs['out_z'] = os.path.abspath(self.inputs.out_z_name)
1629+
1630+
if isdefined(self.inputs.out_t_name):
1631+
outputs['out_t'] = os.path.abspath(self.inputs.out_t_name)
1632+
1633+
if isdefined(self.inputs.out_p_name):
1634+
outputs['out_p'] = os.path.abspath(self.inputs.out_p_name)
1635+
1636+
if isdefined(self.inputs.out_f_name):
1637+
outputs['out_f'] = os.path.abspath(self.inputs.out_f_name)
1638+
1639+
if isdefined(self.inputs.out_pf_name):
1640+
outputs['out_pf'] = os.path.abspath(self.inputs.out_pf_name)
1641+
1642+
if isdefined(self.inputs.out_res_name):
1643+
outputs['out_res'] = os.path.abspath(self.inputs.out_res_name)
1644+
1645+
if isdefined(self.inputs.out_varcb_name):
1646+
outputs['out_varcb'] = os.path.abspath(self.inputs.out_varcb_name)
1647+
1648+
if isdefined(self.inputs.out_sigsq_name):
1649+
outputs['out_sigsq'] = os.path.abspath(self.inputs.out_sigsq_name)
1650+
1651+
if isdefined(self.inputs.out_data_name):
1652+
outputs['out_data'] = os.path.abspath(self.inputs.out_data_name)
1653+
1654+
if isdefined(self.inputs.out_vnscales_name):
1655+
outputs['out_vnscales'] = os.path.abspath(self.inputs.out_vnscales_name)
1656+
17411657
return outputs
17421658

17431659
def _gen_filename(self, name):

0 commit comments

Comments
 (0)