@@ -548,6 +548,19 @@ class FILMGLSInputSpec505(FSLCommandInputSpec):
548
548
results_dir = Directory ('results' , argstr = '--rn=%s' , usedefault = True ,
549
549
desc = 'directory to store results in' )
550
550
551
+ class FILMGLSInputSpec507 (FILMGLSInputSpec505 ):
552
+ threshold = traits .Float (default = - 1000. , argstr = '--thr=%f' ,
553
+ position = - 1 , usedefault = True ,
554
+ desc = 'threshold' )
555
+ tcon_file = File (exists = True , argstr = '--con=%s' ,
556
+ desc = 'contrast file containing T-contrasts' )
557
+ fcon_file = File (exists = True , argstr = '--fcon=%s' ,
558
+ desc = 'contrast file containing F-contrasts' )
559
+ mode = traits .Enum ('volumetric' , 'surface' , argstr = "--mode=%s" ,
560
+ desc = "Type of analysis to be done" )
561
+ surface = File (exists = True , argstr = "--in2=%s" ,
562
+ desc = ("input surface for autocorr smoothing in "
563
+ "surface-based analyses" ))
551
564
552
565
class FILMGLSOutputSpec (TraitedSpec ):
553
566
param_estimates = OutputMultiPath (File (exists = True ),
@@ -561,10 +574,40 @@ class FILMGLSOutputSpec(TraitedSpec):
561
574
desc = 'directory storing model estimation output' )
562
575
corrections = File (exists = True ,
563
576
desc = 'statistical corrections used within FILM modelling' )
577
+ thresholdac = File (exists = True ,
578
+ desc = 'The FILM autocorrelation parameters' )
564
579
logfile = File (exists = True ,
565
580
desc = 'FILM run logfile' )
566
581
567
582
583
+ class FILMGLSOutputSpec507 (TraitedSpec ):
584
+ param_estimates = OutputMultiPath (File (exists = True ),
585
+ desc = 'Parameter estimates for each column of the design matrix' )
586
+ residual4d = File (exists = True ,
587
+ desc = 'Model fit residual mean-squared error for each time point' )
588
+ dof_file = File (exists = True , desc = 'degrees of freedom' )
589
+ sigmasquareds = File (
590
+ exists = True , desc = 'summary of residuals, See Woolrich, et. al., 2001' )
591
+ results_dir = Directory (exists = True ,
592
+ desc = 'directory storing model estimation output' )
593
+ thresholdac = File (exists = True ,
594
+ desc = 'The FILM autocorrelation parameters' )
595
+ logfile = File (exists = True ,
596
+ desc = 'FILM run logfile' )
597
+ copes = OutputMultiPath (File (exists = True ),
598
+ desc = 'Contrast estimates for each contrast' )
599
+ varcopes = OutputMultiPath (File (exists = True ),
600
+ desc = 'Variance estimates for each contrast' )
601
+ zstats = OutputMultiPath (File (exists = True ),
602
+ desc = 'z-stat file for each contrast' )
603
+ tstats = OutputMultiPath (File (exists = True ),
604
+ desc = 't-stat file for each contrast' )
605
+ fstats = OutputMultiPath (File (exists = True ),
606
+ desc = 'f-stat file for each contrast' )
607
+ zfstats = OutputMultiPath (File (exists = True ),
608
+ desc = 'z-stat file for each F contrast' )
609
+
610
+
568
611
class FILMGLS (FSLCommand ):
569
612
"""Use FSL film_gls command to fit a design matrix to voxel timeseries
570
613
@@ -597,11 +640,16 @@ class FILMGLS(FSLCommand):
597
640
598
641
_cmd = 'film_gls'
599
642
600
- if Info .version () and LooseVersion (Info .version ()) > LooseVersion ('5.0.4' ):
643
+ if Info .version () and LooseVersion (Info .version ()) > LooseVersion ('5.0.6' ):
644
+ input_spec = FILMGLSInputSpec507
645
+ elif Info .version () and LooseVersion (Info .version ()) > LooseVersion ('5.0.4' ):
601
646
input_spec = FILMGLSInputSpec505
602
647
else :
603
648
input_spec = FILMGLSInputSpec
604
- output_spec = FILMGLSOutputSpec
649
+ if Info .version () and LooseVersion (Info .version ()) > LooseVersion ('5.0.6' ):
650
+ output_spec = FILMGLSOutputSpec507
651
+ else :
652
+ output_spec = FILMGLSOutputSpec
605
653
606
654
def _get_pe_files (self , cwd ):
607
655
files = None
@@ -618,6 +666,25 @@ def _get_pe_files(self, cwd):
618
666
fp .close ()
619
667
return files
620
668
669
+ def _get_numcons (self ):
670
+ numtcons = 0
671
+ numfcons = 0
672
+ if isdefined (self .inputs .tcon_file ):
673
+ fp = open (self .inputs .tcon_file , 'rt' )
674
+ for line in fp .readlines ():
675
+ if line .startswith ('/NumContrasts' ):
676
+ numtcons = int (line .split ()[- 1 ])
677
+ break
678
+ fp .close ()
679
+ if isdefined (self .inputs .fcon_file ):
680
+ fp = open (self .inputs .fcon_file , 'rt' )
681
+ for line in fp .readlines ():
682
+ if line .startswith ('/NumContrasts' ):
683
+ numfcons = int (line .split ()[- 1 ])
684
+ break
685
+ fp .close ()
686
+ return numtcons , numfcons
687
+
621
688
def _list_outputs (self ):
622
689
outputs = self ._outputs ().get ()
623
690
cwd = os .getcwd ()
@@ -630,11 +697,50 @@ def _list_outputs(self):
630
697
outputs ['dof_file' ] = os .path .join (results_dir , 'dof' )
631
698
outputs ['sigmasquareds' ] = self ._gen_fname ('sigmasquareds.nii' ,
632
699
cwd = results_dir )
633
- outputs ['corrections ' ] = self ._gen_fname ('corrections .nii' ,
700
+ outputs ['thresholdac ' ] = self ._gen_fname ('threshac1 .nii' ,
634
701
cwd = results_dir )
702
+ if Info .version () and LooseVersion (Info .version ()) < LooseVersion ('5.0.7' ):
703
+ outputs ['corrections' ] = self ._gen_fname ('corrections.nii' ,
704
+ cwd = results_dir )
635
705
outputs ['logfile' ] = self ._gen_fname ('logfile' ,
636
706
change_ext = False ,
637
707
cwd = results_dir )
708
+
709
+ if Info .version () and LooseVersion (Info .version ()) > LooseVersion ('5.0.6' ):
710
+ pth = results_dir
711
+ numtcons , numfcons = self ._get_numcons ()
712
+ base_contrast = 1
713
+ copes = []
714
+ varcopes = []
715
+ zstats = []
716
+ tstats = []
717
+ neffs = []
718
+ for i in range (numtcons ):
719
+ copes .append (self ._gen_fname ('cope%d.nii' % (base_contrast + i ),
720
+ cwd = pth ))
721
+ varcopes .append (
722
+ self ._gen_fname ('varcope%d.nii' % (base_contrast + i ),
723
+ cwd = pth ))
724
+ zstats .append (self ._gen_fname ('zstat%d.nii' % (base_contrast + i ),
725
+ cwd = pth ))
726
+ tstats .append (self ._gen_fname ('tstat%d.nii' % (base_contrast + i ),
727
+ cwd = pth ))
728
+ if copes :
729
+ outputs ['copes' ] = copes
730
+ outputs ['varcopes' ] = varcopes
731
+ outputs ['zstats' ] = zstats
732
+ outputs ['tstats' ] = tstats
733
+ fstats = []
734
+ zfstats = []
735
+ for i in range (numfcons ):
736
+ fstats .append (self ._gen_fname ('fstat%d.nii' % (base_contrast + i ),
737
+ cwd = pth ))
738
+ zfstats .append (
739
+ self ._gen_fname ('zfstat%d.nii' % (base_contrast + i ),
740
+ cwd = pth ))
741
+ if fstats :
742
+ outputs ['fstats' ] = fstats
743
+ outputs ['zfstats' ] = zfstats
638
744
return outputs
639
745
640
746
0 commit comments