44
55
66class Smooth (Process ):
7+
8+ # def __init__(self):
9+ # self.requirement = ['spm', 'nipype']
10+
11+ #We can't use types defined by nipype because it use traits ...
12+ #from nipype.interfaces.base import (File, InputMultiPath, InputMultiObject,
13+ # OutputMultiPath, traits,
14+ # TraitListObject,
15+ # traits_extension)
16+ #from nipype.interfaces.spm.base import ImageFileSPM
17+
18+ #in_files: InputMultiPath[ImageFileSPM] = field(extensions='.nii',
19+ # optional=False,
20+ # doc='in_files')
721 # Inputs
8- in_files : field (type_ = File ,
9- extensions = ('.nii' ,),
10- optional = False ,
11- doc = 'in_files' )
12-
13- fwhm : field (type_ = typing .Union [float , list [float ]],
14- optional = True ,
15- doc = 'fwhm' )
22+ in_files : File = field (extensions = '.nii' ,
23+ optional = False ,
24+ doc = 'in_files description' )
25+
26+ fwhm : typing .Union [float , list [float ]] = field (optional = True ,
27+ default_factory = lambda : [6. , 6. , 6. ],
28+ doc = 'fwhm description' )
1629
17- data_type : field (type_ = int ,
18- optional = True ,
19- doc = 'data_type' )
30+ data_type : int = field (default_factory = lambda : 0 ,
31+ optional = True ,
32+ doc = 'data_type' )
2033
21- implicit_masking : field (type_ = bool ,
22- optional = True ,
23- doc = 'implicit_masking' )
34+ implicit_masking : bool = field (optional = True ,
35+ default_factory = lambda : False ,
36+ doc = 'implicit_masking description ' )
2437
25- out_prefix : field (type_ = str ,
26- optional = True ,
27- default_factory = lambda : 's' ,
28- doc = 'out_prefix' )
38+ out_prefix : str = field (optional = True ,
39+ default_factory = lambda : 's' ,
40+ doc = 'out_prefix description' )
2941
3042 # Outputs
31- smoothed_files : field (type_ = File ,
32- write = True ,
33- doc = 'smoothed_files' )
43+ smoothed_files : File = field (write = True ,
44+ doc = 'smoothed_files description' )
45+
46+ capsul = Capsul ()
47+ process = capsul .executable ('nipype.interfaces.spm.preprocess.Smooth' )
48+
49+ def execute (self , context ):
50+ # with open(self.input) as f:
51+ # content = f.read()
52+ # content = f'{content}Bias correction with strength={self.strength}\n'
53+ # Path(self.output).parent.mkdir(parents=True, exist_ok=True)
54+ # with open(self.output, 'w') as f:
55+ # f.write(content)
56+ print ('self.in_files: ' , self .in_files )
57+ print ('self.fwhm: ' , self .fwhm )
58+ print ('self.data_type: ' , self .data_type )
59+ print ('self.implicit_masking: ' , self .implicit_masking )
60+ print ('self.out_prefix: ' , self .out_prefix )
61+ self .process .in_files = self .in_files
62+ self .process .fwhm = self .fwhm
63+ self .process .data_type = self .data_type
64+ self .process .implicit_masking = self .implicit_masking
65+ self .process .out_prefix = self .out_prefix
66+ self .process .output_directory = self .output_directory
67+
68+ #print('self.smoothed_files: ', self.smoothed_files)
69+ print ('self.process: ' , self .process )
3470
3571
3672
@@ -39,12 +75,55 @@ class Smooth(Process):
3975 import sys
4076 from soma .qt_gui .qt_backend import QtGui
4177 from capsul .qt_gui .widgets import PipelineDeveloperView
42- smooth = Capsul .executable ('test.Smooth' )
78+ from capsul .config .configuration import ApplicationConfiguration
79+
4380 app = QtGui .QApplication .instance ()
81+
82+ capsul = Capsul ()
83+ smooth = capsul .executable ('tests.Smooth' )
84+
85+ config = ApplicationConfiguration ('test_smoothV3' )
86+ user_conf_dict = {
87+ 'local' : {
88+ 'spm' : {
89+ 'spm12_standalone' : {
90+ 'directory' : '/usr/local/SPM/spm12_standalone' ,
91+ 'standalone' : True ,
92+ 'version' : 12 },
93+ },
94+ 'nipype' : {
95+ 'nipype' : {}
96+ },
97+ 'matlab' : {
98+ 'matlab' : {
99+ 'mcr_directory' : '/usr/local/MATLAB/MATLAB_Runtime/v95 ' }
100+ }
101+ }
102+ }
103+
104+ config .user = user_conf_dict
105+ config .merge_configs ()
106+ capsul .config = config .merged_config
107+ print ('local config: ' , capsul .config .asdict ())
108+
109+ smooth .in_files = '/home/econdami/Desktop/Data_tests_capsulV3/raw/alej170316-IRM_Fonct._+_perfusion-2016-03-17_08-34-44-0-BOLD_CVR_7_53sl_ModeratePNS_SENSE-FEEPI-00-12-12.000.nii'
110+ smooth .output_directory = '/home/econdami/Desktop/Data_tests_capsulV3/derived'
111+
112+
113+ #c.engine().config.local ###### pas bon
114+ #c.config.local= un dict ou un controller
115+ #https://github.com/populse/capsul/blob/pydantic_controller/capsul/config/test/test_config.py
44116 if not app :
45117 app = QtGui .QApplication (sys .argv )
118+
46119 view1 = PipelineDeveloperView (smooth , allow_open_controller = True , show_sub_pipelines = True )
120+
47121 view1 .show ()
48122 app .exec_ ()
49123 del view1
50124
125+
126+ with capsul .engine () as engine :
127+ engine .run (smooth )
128+
129+ print ('smooth.asdict(): ' , smooth .asdict ())
0 commit comments