]> Creatis software - vip-workflow-odin.git/blob - workflow/odin_epi_folder.gwendia
SMP folder selection
[vip-workflow-odin.git] / workflow / odin_epi_folder.gwendia
1 <?xml version="1.0" encoding="UTF-8"?>
2 <workflow name="odin" version="1.0">
3
4   <description>This application wraps the Odin MRI simulator. The Odin code source is available at http://od1n.sourceforge.net</description>
5
6   <interface>
7     <source name="ProData" type="uri">
8       <source-comment>&lt;b&gt;&lt;font color="blue"&gt;new input&lt;/font&gt;&lt;/b&gt;: Pro file
9       </source-comment>
10     </source>
11     <source name="SmpDir" type="uri">
12       <source-comment>&lt;b&gt;&lt;font color="blue"&gt;new input&lt;/font&gt;&lt;/b&gt;: Folder containing all (and only) Smp files
13       </source-comment>
14     </source>
15     <source name="ResultsDirectory" type="uri">
16       <source-comment>&lt;b&gt;&lt;font color="blue"&gt;new input&lt;/font&gt;&lt;/b&gt;: add description here...
17       </source-comment>
18     </source>
19     <constant name="OdinSeq" type="string" value="odinepiexe" cardinality="scalar" />
20     <source name="options" type="string">
21       <source-comment>&lt;b&gt;&lt;font color="blue"&gt;options&lt;/font&gt;&lt;/b&gt;: any option string, to be appended to the recon-all command line. For instance: '-all'. &lt;b&gt;Important:&lt;/b&gt; don't put spaces, use '_'  instead. And put 'no' in case you don't want to use any option.
22       </source-comment>
23     </source>
24   </interface>
25
26   <processors>
27     <processor name="odin" >
28       <in name="input4" type="string" depth="0" />
29       <in name="input3" type="string" depth="0" />
30       <in name="input2" type="string" depth="0" />
31       <in name="input1" type="string" depth="0" />
32       <in name="input0" type="uri" depth="0" />
33       <iterationstrategy>
34         <cross>
35           <port name="input0" />
36           <port name="input1" />
37           <port name="input2" />
38           <port name="input3" />
39           <port name="input4" />
40         </cross>
41       </iterationstrategy>
42       <gasw descriptor="[GASW_DIR]/odin.xml"/>
43     </processor>
44     <processor name="append-date" >
45       <in name="dir" type="uri" depth="0" />
46       <out name="result" type="string" depth="0" />
47       <beanshell>/*----------Beginning of Beanshell------------*/
48                         import java.text.DateFormat;
49                         import java.text.SimpleDateFormat;
50                         import java.util.Date;
51
52 DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy_HH:mm:ss");
53 String result = dir.toString()+"/"+(dateFormat.format(System.currentTimeMillis()));
54 /*------------End of Beanshell------------*/
55       </beanshell>
56     </processor>
57     <processor name="listSmpDir" >
58       <in name="inDir" type="uri" depth="0" />
59       <out name="arrayLfn" type="string" depth="1" />
60       <beanshell>
61 String smpDir=inDir.toString();    
62 arrayLfn = new ArrayList();
63 String smpLfn="";
64 Runtime rt = Runtime.getRuntime();
65 try{
66             String [] cmd1 = new String [2];
67             cmd1[0] = "lfc-ls";
68             cmd1[1] = smpDir;
69             Process p1 = rt.exec(cmd1);
70             p1.waitFor();
71                                                                                                                                          
72             String line ="";
73             BufferedReader in = new BufferedReader(new InputStreamReader(p1.getInputStream()));
74             System.out.println(" Listing directory "+smpDir);
75             while(in.ready()){
76         line=in.readLine();
77         try{
78           System.out.println(" Line is "+line); 
79           smpLfn=smpDir+"/"+line;
80           arrayLfn.add(""+smpLfn);
81         }catch(Exception e){
82                                         System.out.println(" exception:"+e.getMessage());
83                 }
84
85                 
86                 BufferedReader err = new BufferedReader(new InputStreamReader(p1.getErrorStream()));
87                 while(err.ready()){
88                     line=err.readLine();
89                     System.out.println(" error listing directory "+smpDir+": "+line);
90                 }
91                 p1.getErrorStream().close();
92                 p1.getInputStream().close();
93                 p1.getOutputStream().close();
94             }
95                 }
96
97         catch(Exception e){
98             System.out.println(" exception:"+e.getMessage());
99         }
100       </beanshell>
101     </processor>
102   </processors>
103
104   <links>
105       <link from="ProData" to="odin:input0" />
106       <link from="ResultsDirectory" to="append-date:dir" />
107       <link from="append-date:result" to="odin:input2" />
108       <link from="OdinSeq" to="odin:input3" />
109       <link from="options" to="odin:input4" />
110       <link from="SmpDir" to="listSmpDir:inDir" />
111       <link from="listSmpDir:arrayLfn" to="odin:input1" />
112   </links>
113
114 </workflow>