@@ -70,18 +70,13 @@ class Bse(CommandLine):
70
70
_cmd = 'bse'
71
71
72
72
def _gen_filename (self , name ):
73
- exec ('is_user_defined = isdefined(self.inputs.' + name + ')' )
74
-
75
- if is_user_defined :
76
- exec ("toReturn = os.path.abspath(self.inputs." + name + ")" )
77
-
78
- return toReturn
73
+ inputs = self .inputs .get ()
74
+ if isdefined (inputs [name ]):
75
+ return os .path .abspath (inputs [name ])
79
76
80
77
if name == 'outputMRIVolume' :
81
- myExtension = '.nii.gz'
82
- return '' .join ((os .getcwd (), '/' ,
83
- getFileName (self .inputs .inputMRIFile ),
84
- "___" , self ._cmd , 'Output_' , name , myExtension ))
78
+ return getFileName (self , self .inputs .inputMRIFile , name , '.nii.gz' )
79
+
85
80
return None
86
81
87
82
def _list_outputs (self ):
@@ -170,15 +165,12 @@ class Bfc(CommandLine):
170
165
_cmd = 'bfc'
171
166
172
167
def _gen_filename (self , name ):
173
- exec ('is_user_defined = isdefined(self.inputs.' + name + ')' )
174
-
175
- if is_user_defined :
176
- exec ("toReturn = os.path.abspath(self.inputs." + name + ")" )
177
- return toReturn
168
+ inputs = self .inputs .get ()
169
+ if isdefined (inputs [name ]):
170
+ return os .path .abspath (inputs [name ])
178
171
179
172
if name == 'outputMRIVolume' :
180
- myExtension = '.nii.gz'
181
- return '' .join ((os .getcwd (), '/' , getFileName (self .inputs .inputMRIFile ), "___" , self ._cmd , 'Output_' , name , myExtension ))
173
+ return getFileName (self , self .inputs .inputMRIFile , name , '.nii.gz' )
182
174
183
175
return None
184
176
@@ -221,17 +213,12 @@ class Pvc(CommandLine):
221
213
_cmd = 'pvc'
222
214
223
215
def _gen_filename (self , name ):
224
- exec ('is_user_defined = isdefined(self.inputs.' + name + ')' )
225
- if is_user_defined :
226
- exec ("toReturn = os.path.abspath(self.inputs." + name + ")" )
227
- return toReturn
216
+ inputs = self .inputs .get ()
217
+ if isdefined (inputs [name ]):
218
+ return os .path .abspath (inputs [name ])
228
219
229
- if name == 'outputLabelFile' :
230
- myExtension = '.nii.gz'
231
- return '' .join ((os .getcwd (), '/' , self ._cmd , 'Output_' , name , myExtension ))
232
- if name == 'outputTissueFractionFile' :
233
- myExtension = '.nii.gz'
234
- return '' .join ((os .getcwd (), '/' , getFileName (self .inputs .inputMRIFile ), "___" , self ._cmd , 'Output_' , name , myExtension ))
220
+ if name == 'outputLabelFile' or name == 'outputTissueFractionFile' :
221
+ return getFileName (self , self .inputs .inputMRIFile , name , '.nii.gz' )
235
222
236
223
return None
237
224
@@ -286,18 +273,12 @@ class Cerebro(CommandLine):
286
273
_cmd = 'cerebro'
287
274
288
275
def _gen_filename (self , name ):
289
- exec ('is_user_defined = isdefined(self.inputs.' + name + ')' )
290
-
291
- if is_user_defined :
292
- exec ("toReturn = os.path.abspath(self.inputs." + name + ")" )
293
- return toReturn
276
+ inputs = self .inputs .get ()
277
+ if isdefined (inputs [name ]):
278
+ return os .path .abspath (inputs [name ])
294
279
295
- if name == 'outputCerebrumMaskFile' :
296
- myExtension = '.nii.gz'
297
- return '' .join ((os .getcwd (), '/' , getFileName (self .inputs .inputMRIFile ), "___" , self ._cmd , 'Output_' , name , myExtension ))
298
- if name == 'outputLabelMaskFile' :
299
- myExtension = '.nii.gz'
300
- return '' .join ((os .getcwd (), '/' , getFileName (self .inputs .inputMRIFile ), "___" , self ._cmd , 'Output_' , name , myExtension ))
280
+ if name == 'outputCerebrumMaskFile' or name == 'outputLabelMaskFile' :
281
+ return getFileName (self , self .inputs .inputMRIFile , name , '.nii.gz' )
301
282
302
283
return None
303
284
@@ -334,15 +315,12 @@ class Cortex(CommandLine):
334
315
_cmd = 'cortex'
335
316
336
317
def _gen_filename (self , name ):
337
- exec ('is_user_defined = isdefined(self.inputs.' + name + ')' )
338
- if is_user_defined :
339
- exec ("toReturn = os.path.abspath(self.inputs." + name + ")" )
340
- return toReturn
318
+ inputs = self .inputs .get ()
319
+ if isdefined (inputs [name ]):
320
+ return os .path .abspath (inputs [name ])
341
321
342
322
if name == 'outputCerebrumMask' :
343
- myExtension = '.nii.gz'
344
- return '' .join ((os .getcwd (), '/' , getFileName (self .inputs .inputHemisphereLabelFile ), "___" , self ._cmd , 'Output_' , name , myExtension ))
345
-
323
+ return getFileName (self , self .inputs .inputHemisphereLabelFile , name , '.nii.gz' )
346
324
return None
347
325
348
326
def _list_outputs (self ):
@@ -373,14 +351,14 @@ class Scrubmask(CommandLine):
373
351
_cmd = 'scrubmask'
374
352
375
353
def _gen_filename (self , name ):
376
- exec ('is_user_defined = isdefined(self.inputs.' + name + ')' )
377
- if is_user_defined :
378
- exec ("toReturn = os.path.abspath(self.inputs." + name + ")" )
379
- return toReturn
354
+ inputs = self .inputs .get ()
355
+ if isdefined (inputs [name ]):
356
+ return os .path .abspath (inputs [name ])
380
357
381
358
if name == 'outputMaskFile' :
382
- myExtension = '.nii.gz'
383
- return '' .join ((os .getcwd (), '/' , getFileName (self .inputs .inputMaskFile ), "___" , self ._cmd , 'Output_' , name , myExtension ))
359
+ return getFileName (self , self .inputs .inputMaskFile , name , '.nii.gz' )
360
+
361
+
384
362
return None
385
363
386
364
def _list_outputs (self ):
@@ -412,14 +390,12 @@ class Tca(CommandLine):
412
390
_cmd = 'tca'
413
391
414
392
def _gen_filename (self , name ):
415
- exec ('is_user_defined = isdefined(self.inputs.' + name + ')' )
416
- if is_user_defined :
417
- exec ("toReturn = os.path.abspath(self.inputs." + name + ")" )
418
- return toReturn
393
+ inputs = self .inputs .get ()
394
+ if isdefined (inputs [name ]):
395
+ return os .path .abspath (inputs [name ])
419
396
420
397
if name == 'outputMaskFile' :
421
- myExtension = '.nii.gz'
422
- return '' .join ((os .getcwd (), '/' , getFileName (self .inputs .inputMaskFile ), "___" , self ._cmd , 'Output_' , name , myExtension ))
398
+ return getFileName (self , self .inputs .inputMaskFile , name , '.nii.gz' )
423
399
424
400
return None
425
401
@@ -448,14 +424,12 @@ class Dewisp(CommandLine):
448
424
_cmd = 'dewisp'
449
425
450
426
def _gen_filename (self , name ):
451
- exec ('is_user_defined = isdefined(self.inputs.' + name + ')' )
452
- if is_user_defined :
453
- exec ("toReturn = os.path.abspath(self.inputs." + name + ")" )
454
- return toReturn
427
+ inputs = self .inputs .get ()
428
+ if isdefined (inputs [name ]):
429
+ return os .path .abspath (inputs [name ])
455
430
456
431
if name == 'outputMaskFile' :
457
- myExtension = '.nii.gz'
458
- return '' .join ((os .getcwd (), '/' , getFileName (self .inputs .inputMaskFile ), "___" , self ._cmd , 'Output_' , name , myExtension ))
432
+ return getFileName (self , self .inputs .inputMaskFile , name , '.nii.gz' )
459
433
460
434
return None
461
435
@@ -511,14 +485,12 @@ def _format_arg(self, name, spec, value):
511
485
return super (Dfs , self )._format_arg (name , spec , value )
512
486
513
487
def _gen_filename (self , name ):
514
- exec ('is_user_defined = isdefined(self.inputs.' + name + ')' )
515
- if is_user_defined :
516
- exec ("toReturn = os.path.abspath(self.inputs." + name + ")" )
517
- return toReturn
488
+ inputs = self .inputs .get ()
489
+ if isdefined (inputs [name ]):
490
+ return os .path .abspath (inputs [name ])
518
491
519
492
if name == 'outputSurfaceFile' :
520
- myExtension = '.dfs'
521
- return '' .join ((os .getcwd (), '/' , getFileName (self .inputs .inputVolumeFile ), "___" , self ._cmd , 'Output_' , name , myExtension ))
493
+ return getFileName (self , self .inputs .inputVolumeFile , name , '.dfs' )
522
494
523
495
return None
524
496
@@ -572,14 +544,12 @@ class Pialmesh(CommandLine):
572
544
_cmd = 'pialmesh'
573
545
574
546
def _gen_filename (self , name ):
575
- exec ('is_user_defined = isdefined(self.inputs.' + name + ')' )
576
- if is_user_defined :
577
- exec ("toReturn = os.path.abspath(self.inputs." + name + ")" )
578
- return toReturn
547
+ inputs = self .inputs .get ()
548
+ if isdefined (inputs [name ]):
549
+ return os .path .abspath (inputs [name ])
579
550
580
551
if name == 'outputSurfaceFile' :
581
- myExtension = '.dfs'
582
- return '' .join ((os .getcwd (), '/' , getFileName (self .inputs .inputSurfaceFile ), "___" , self ._cmd , 'Output_' , name , myExtension ))
552
+ return getFileName (self , self .inputs .inputSurfaceFile , name , '.dfs' )
583
553
584
554
return None
585
555
@@ -624,14 +594,12 @@ class Skullfinder(CommandLine):
624
594
_cmd = 'skullfinder'
625
595
626
596
def _gen_filename (self , name ):
627
- exec ('is_user_defined = isdefined(self.inputs.' + name + ')' )
628
- if is_user_defined :
629
- exec ("toReturn = os.path.abspath(self.inputs." + name + ")" )
630
- return toReturn
597
+ inputs = self .inputs .get ()
598
+ if isdefined (inputs [name ]):
599
+ return os .path .abspath (inputs [name ])
631
600
632
601
if name == 'outputLabelFile' :
633
- myExtension = '.nii.gz'
634
- return '' .join ((os .getcwd (), '/' , getFileName (self .inputs .inputMRIFile ), "___" , self ._cmd , 'Output_' , name , myExtension ))
602
+ return getFileName (self , self .inputs .inputMRIFile , name , '.nii.gz' )
635
603
636
604
return None
637
605
@@ -671,42 +639,31 @@ class Hemisplit(CommandLine):
671
639
_cmd = 'hemisplit'
672
640
673
641
def _gen_filename (self , name ):
674
- exec ('is_user_defined = isdefined(self.inputs.' + name + ')' )
675
- if is_user_defined :
676
- exec ("toReturn = os.path.abspath(self.inputs." + name + ")" )
677
- return toReturn
678
-
679
- if name == 'outputLeftHemisphere' :
680
- myExtension = '.dfs'
681
- return '' .join ((os .getcwd (), '/' , getFileName (self .inputs .inputSurfaceFile ), "___" , self ._cmd , 'Output_' , name , myExtension ))
682
- if name == 'outputRightHemisphere' :
683
- myExtension = '.dfs'
684
- return '' .join ((os .getcwd (), '/' , getFileName (self .inputs .inputSurfaceFile ), "___" , self ._cmd , 'Output_' , name , myExtension ))
685
- if name == 'outputLeftPialHemisphere' :
686
- myExtension = '.dfs'
687
- return '' .join ((os .getcwd (), '/' , getFileName (self .inputs .inputSurfaceFile ), "___" , self ._cmd , 'Output_' , name , myExtension ))
688
- if name == 'outputRightPialHemisphere' :
689
- myExtension = '.dfs'
690
- return '' .join ((os .getcwd (), '/' , getFileName (self .inputs .inputSurfaceFile ), "___" , self ._cmd , 'Output_' , name , myExtension ))
642
+ inputs = self .inputs .get ()
643
+ if isdefined (inputs [name ]):
644
+ return os .path .abspath (inputs [name ])
645
+
646
+
647
+ if (name == 'outputLeftHemisphere'
648
+ or name == 'outputRightHemisphere'
649
+ or name == 'outputLeftPialHemisphere'
650
+ or name == 'outputRightPialHemisphere' ):
651
+ return getFileName (self , self .inputs .inputSurfaceFile , name , '.dfs' )
691
652
692
653
return None
693
654
694
655
def _list_outputs (self ):
695
656
return l_outputs (self )
696
657
697
-
698
- # removes directory of a pathway to a file, removes extension, returns file name
699
- # up to first occurence of three consecutive underscore characters (if any)
700
- # ex: /home/abc/testData___bseOutput_output_file.nii.gz --> testData
701
- def getFileName (string ):
702
- underscoreRegex = regex .compile ("[_]{3}" )
658
+ # used to generate file names for outputs
659
+ # removes pathway and extension of inputName, returns concatenation of]
660
+ # inputName, command, name, and extension
661
+ def getFileName (self , inputName , name , extension ):
662
+ fullInput = os .path .basename (inputName )
703
663
dotRegex = regex .compile ("[^.]+" )
704
- slashRegex = regex .compile ("[^/]+" )
705
- arr = underscoreRegex .split (string )
706
- arr2 = dotRegex .findall (arr [0 ])
707
- arr3 = slashRegex .findall (arr2 [0 ])
708
- return arr3 [len (arr3 ) - 1 ]
709
-
664
+ inputNoExtension = dotRegex .findall (fullInput )[0 ]
665
+ return os .path .abspath (
666
+ '' .join ((inputNoExtension , '_' , self ._cmd , '_' , name , extension )))
710
667
711
668
def l_outputs (self ):
712
669
outputs = self .output_spec ().get ()
0 commit comments