1212import os
1313
1414class ICA_AROMAInputSpec (CommandLineInputSpec ):
15- featDir = Directory (exists = True ,
15+ feat_dir = Directory (exists = True , mandatory = True ,
16+ argstr = '-feat %s' ,
17+ xor = ['in_file' ,'mat_file' ,'fnirt_warp_file' ,'motion_parameters' ],
1618 desc = 'If a feat directory exists and temporal filtering '
1719 'has not been run yet, ICA_AROMA can use the files in '
18- 'this directory.' ,mandatory = False ,xor = ['infile' ,'mask' ,'affmat' ,'warp' ,'mc' ])
19- infile = File (exists = True ,
20- desc = 'volume to be denoised' ,
21- argstr = '-i %s' ,mandatory = False ,xor = ['featDir' ])
22- outdir = Directory (desc = 'path to output directory' ,
23- argstr = '-o %s' ,mandatory = True )
24- mask = File (exists = True ,
25- desc = 'path/name volume mask' ,
26- argstr = '-m %s' ,mandatory = False ,xor = ['featDir' ])
27- dim = traits .Int (desc = 'Dimensionality reduction when running '
28- 'MELODIC (defualt is automatic estimation)' ,
29- argstr = '-dim %d' )
30- TR = traits .Float (desc = 'TR in seconds. If this is not specified '
31- 'the TR will be extracted from the header of the fMRI nifti file.' ,
32- argstr = '%.2f' )
33- melodic_dir = Directory (exists = True ,
34- desc = 'path to MELODIC directory if MELODIC has already been ran' ,
35- argstr = '-meldir %s' )
36- affmat = File (exists = True ,
37- desc = 'path/name of the mat-file describing the '
38- 'affine registration (e.g. FSL FLIRT) of the '
39- 'functional data to structural space (.mat file)' ,
40- argstr = '-affmat %s' ,mandatory = False ,xor = ['featDir' ])
41- warp = File (exists = True ,
42- desc = 'File name of the warp-file describing '
43- 'the non-linear registration (e.g. FSL FNIRT) '
44- 'of the structural data to MNI152 space (.nii.gz)' ,
45- argstr = '-warp %s' ,mandatory = False ,xor = ['featDir' ])
46- mc = File (exists = True ,
47- desc = 'motion parameters file' ,
48- argstr = '-mc %s' ,mandatory = False ,xor = ['featDir' ])
49- denoise_type = traits .Str (argstr = '-den %s' ,
20+ 'this directory.' )
21+ in_file = File (exists = True , mandatory = True ,
22+ argstr = '-i %s' , xor = ['feat_dir' ],
23+ desc = 'volume to be denoised' )
24+ out_dir = Directory ('out' , mandatory = True ,
25+ argstr = '-o %s' ,
26+ desc = 'output directory' )
27+ mask = File (exists = True , argstr = '-m %s' , xor = ['feat_dir' ],
28+ desc = 'path/name volume mask' )
29+ dim = traits .Int (argstr = '-dim %d' ,
30+ desc = 'Dimensionality reduction when running '
31+ 'MELODIC (defualt is automatic estimation)' )
32+ TR = traits .Float (argstr = '-tr %.3f' ,
33+ desc = 'TR in seconds. If this is not specified '
34+ 'the TR will be extracted from the '
35+ 'header of the fMRI nifti file.' )
36+ melodic_dir = Directory (exists = True , argstr = '-meldir %s' ,
37+ desc = 'path to MELODIC directory if MELODIC has already been run' )
38+ mat_file = File (exists = True , mandatory = True ,
39+ argstr = '-affmat %s' , xor = ['feat_dir' ],
40+ desc = 'path/name of the mat-file describing the '
41+ 'affine registration (e.g. FSL FLIRT) of the '
42+ 'functional data to structural space (.mat file)' )
43+ fnirt_warp_file = File (exists = True , mandatory = True ,
44+ argstr = '-warp %s' , xor = ['feat_dir' ],
45+ desc = 'File name of the warp-file describing '
46+ 'the non-linear registration (e.g. FSL FNIRT) '
47+ 'of the structural data to MNI152 space (.nii.gz)' )
48+ motion_parameters = File (exists = True , mandatory = True ,
49+ argstr = '-mc %s' , xor = ['feat_dir' ],
50+ desc = 'motion parameters file' )
51+ denoise_type = traits .Enum ('nonaggr' , 'aggr' , 'both' , 'no' , usedefault = True ,
52+ mandatory = True , argstr = '-den %s' ,
5053 desc = 'Type of denoising strategy: '
5154 '-none: only classification, no denoising '
5255 '-nonaggr (default): non-aggresssive denoising, i.e. partial component regression '
5356 '-aggr: aggressive denoising, i.e. full component regression '
54- '-both: both aggressive and non-aggressive denoising (two outputs)' ,
55- mandatory = True )
57+ '-both: both aggressive and non-aggressive denoising (two outputs)' )
5658
5759class ICA_AROMAOutputSpec (TraitedSpec ):
58- out_file = OutputMultiPath (File (exists = True ),
59- desc = 'if generated: 1-(non aggressive denoised volume),'
60- '2-(aggressive denoised volume)' )
60+ aggr_denoised_file = File (exists = True ,
61+ desc = 'if generated: aggressively denoised volume' )
62+ nonaggr_denoised_file = File (exists = True ,
63+ desc = 'if generated: non aggressively denoised volume' )
64+ out_dir = Directory (exists = True ,
65+ desc = 'directory contains (in addition to the denoised files): '
66+ 'melodic.ica + classified_motion_components + '
67+ 'classification_overview + feature_scores + melodic_ic_mni)' )
6168
6269class ICA_AROMA (CommandLine ):
6370 """
@@ -66,50 +73,40 @@ class ICA_AROMA(CommandLine):
6673 -------
6774
6875 >>> from nipype.interfaces.fsl import ICA_AROMA
69- >>> AROMA_obj=ICA_AROMA.ICA_AROMA()
70- >>> outDir=os.path.join(os.getcwd(),'ICA_AROMA_testout')
71- >>> func='/path/to/mcImg_brain.nii.gz'
72- >>> affmat='/path/to/functoT1.mat'
73- >>> warp='/path/to/T1toMNI_warp.nii.gz'
74- >>> mc='/path/to/mcImg.par'
75- >>> mask='/path/to/mcImg_mask.nii.gz'
76- >>> denoise_type='both'
77- >>> AROMA_obj.inputs.infile=func
78- >>> AROMA_obj.inputs.affmat=affmat
79- >>> AROMA_obj.inputs.warp=warp
80- >>> AROMA_obj.inputs.mc=mc
81- >>> AROMA_obj.inputs.mask=mask
82- >>> AROMA_obj.inputs.denoise_type=denoise_type
83- >>> AROMA_obj.inputs.outdir=outDir
76+ >>> from nipype.testing import example_data
77+ >>> AROMA_obj = ICA_AROMA.ICA_AROMA()
78+ >>> AROMA_obj.inputs.in_file=example_data('functional.nii')
79+ >>> AROMA_obj.inputs.mat_file=example_data('func_to_struct.mat')
80+ >>> AROMA_obj.inputs.fnirt_warp_file=example_data('warpfield.nii')
81+ >>> AROMA_obj.inputs.motion_parameters=example_data('functional.par')
82+ >>> AROMA_obj.inputs.mask=example_data('mask.nii.gz')
83+ >>> AROMA_obj.inputs.denoise_type='both'
84+ >>> AROMA_obj.inputs.out_dir='ICA_testout'
8485 >>> AROMA_obj.cmdline
85- 'ICA_AROMA.py -affmat /path/to/functoT1.mat - den both
86- -i /path/to/mcImg_brain .nii.gz
87- -m /path/to/mcImg_mask .nii.gz
88- -mc /path/to/mcImg.par
89- -o /path/to/ICA_AROMA_testout
90- -warp /path/to/T1toMNI_warp.nii.gz'
91- >>> AROMA_obj.run()
86+ 'ICA_AROMA.py -den both
87+ -warp /home/james/dev/nipype/nipype/testing/data/warpfield .nii
88+ -i /home/james/dev/nipype/nipype/testing/data/functional .nii
89+ -m /home/james/dev/nipype/nipype/testing/data/mask.nii.gz
90+ -affmat /home/james/dev/nipype/nipype/testing/data/func_to_struct.mat
91+ -mc /home/james/dev/nipype/nipype/testing/data/functional.par
92+ -o ICA_testout'
9293
9394 """
9495 _cmd = 'ICA_AROMA.py'
9596 input_spec = ICA_AROMAInputSpec
9697 output_spec = ICA_AROMAOutputSpec
9798
9899 def _list_outputs (self ):
99- outputs = self .output_spec .get ()
100- outdir = self .input_spec .outdir
101- denoising_strategy = input_spec .denoise_type
102100
103- if denoising_strategy is "noaggr" :
104- outputs ['out_file' ] = os .path .join (outdir ,'denoised_func_data_nonaggr.nii.gz' )
105- elif denoising_strategy is "aggr" :
106- outputs ['out_file' ] = os .path .join (outdir ,'denoised_func_data_aggr.nii.gz' )
107- elif denoising_strategy is "both" :
108- outputs ['out_file' ] = (os .path .join (outdir ,'denoised_func_data_nonaggr.nii.gz' ), os .path .join (outdir ,'denoised_func_data_aggr.nii.gz' ))
109- elif denoising_strategy is "none" :
110- print "No denoising selected"
111- else :
112- raise RuntimeError ('denoise_type must be specified as one of'
113- ' noaggr,aggr,both, or none' )
101+ out_dir = os .path .abspath (self .inputs .out_dir )
102+ outputs ['out_dir' ] = out_dir
103+ #outputs = self.output_spec.get()
104+ #outdir = self.input_spec.outdir
105+ #denoising_strategy = input_spec.denoise_type
114106
115- return outputs
107+ if self .inputs .denoise_type in ('aggr' , 'both' ):
108+ outputs ['aggr_denoised_file' ] = os .path .join (out_dir , 'denoised_func_data_aggr.nii.gz' )
109+ if self .inputs .denoise_type in ('nonaggr' , 'both' ):
110+ outputs ['nonaggr_denoised_file' ] = os .path .join (out_dir , 'denoised_func_data_nonaggr.nii.gz' )
111+
112+ return outputs
0 commit comments