14
14
from nipype .interfaces import fsl
15
15
#from nipype.utils.config import config
16
16
#config.enable_debug_mode()
17
- from QA_utils import plot_ADnorm , tsdiffana , tsnr_roi , combine_table , art_output , plot_motion
17
+ from QA_utils import plot_ADnorm , tsdiffana , tsnr_roi , combine_table , art_output , plot_motion , plot_ribbon , plot_anat
18
18
import sys
19
19
sys .path .insert (0 ,'../../utils/' )
20
20
from reportsink .io import ReportSink
@@ -45,6 +45,7 @@ def preproc_datagrabber(name='preproc_datagrabber'):
45
45
name = name )
46
46
datasource .inputs .base_directory = os .path .join (c .sink_dir ,'analyses' ,'func' )
47
47
datasource .inputs .template = '*'
48
+ datasource .sort_filelist = True
48
49
datasource .inputs .field_template = dict (motion_parameters = '%s/preproc/motion/*.par' ,
49
50
outlier_files = '%s/preproc/art/*_outliers.txt' ,
50
51
art_norm = '%s/preproc/art/norm.*.txt' ,
@@ -268,11 +269,24 @@ def QA_workflow(name='QA'):
268
269
name = 'tsdiffana' , iterfield = ["img" ])
269
270
270
271
art_info = pe .MapNode (util .Function (input_names = ['art_file' ],
271
- output_names = ['table' ],
272
+ output_names = ['table' , 'out' ],
272
273
function = art_output ),
273
274
name = 'art_output' , iterfield = ["art_file" ])
274
275
275
276
fssource = pe .Node (interface = FreeSurferSource (),name = 'fssource' )
277
+
278
+ plotribbon = pe .Node (util .Function (input_names = ['Brain' ],
279
+ output_names = ['images' ],
280
+ function = plot_ribbon ),
281
+ name = "plot_ribbon" )
282
+
283
+ workflow .connect (fssource , 'ribbon' , plotribbon , 'Brain' )
284
+
285
+
286
+ plotanat = pe .Node (util .Function (input_names = ['brain' ],
287
+ output_names = ['images' ],
288
+ function = plot_anat ),
289
+ name = "plot_anat" )
276
290
277
291
roidevplot = tsnr_roi (plot = False ,name = 'tsnr_stddev_roi' ,roi = ['all' ])
278
292
roidevplot .inputs .inputspec .TR = c .TR
@@ -285,6 +299,7 @@ def QA_workflow(name='QA'):
285
299
workflow .connect (infosource , 'subject_id' , roidevplot , 'inputspec.subject' )
286
300
workflow .connect (infosource , 'subject_id' , roisnrplot , 'inputspec.subject' )
287
301
302
+
288
303
tablecombine = pe .MapNode (util .Function (input_names = ['roidev' ,
289
304
'roisnr' ],
290
305
output_names = ['roisnr' ],
@@ -293,12 +308,12 @@ def QA_workflow(name='QA'):
293
308
294
309
295
310
296
- adnormplot = pe .MapNode (util .Function (input_names = ['ADnorm' ,'TR' ],
311
+ adnormplot = pe .MapNode (util .Function (input_names = ['ADnorm' ,'TR' , 'norm_thresh' , 'out' ],
297
312
output_names = ['plot' ],
298
313
function = plot_ADnorm ),
299
- name = 'ADnormplot' , iterfield = ['ADnorm' ])
300
-
301
-
314
+ name = 'ADnormplot' , iterfield = ['ADnorm' , 'out' ])
315
+ adnormplot . inputs . norm_thresh = c . norm_thresh
316
+ workflow . connect ( art_info , 'out' , adnormplot , 'out' )
302
317
303
318
convert = pe .Node (interface = fs .MRIConvert (),name = 'converter' )
304
319
@@ -315,24 +330,17 @@ def QA_workflow(name='QA'):
315
330
name = 'overlay_mask' )
316
331
overlaymask .inputs .threshold = 0
317
332
318
- #overlaymask = pe.Node(interface=fsl.Overlay(),name='fsl_overlaymask')
319
- #overlaymask.inputs.transparency = True
320
- #overlaymask.inputs.stat_thresh = (0,1)
321
- #overlaymask.inputs.full_bg_range= True
322
-
323
- #slicermask = pe.Node(interface=fsl.Slicer(),name='slicer_mask')
324
- #slicermask.inputs.all_axial = True
325
- #slicermask.inputs.image_width = 4
326
333
327
- workflow .connect (datagrabber , 'mask' , overlaymask , 'background_image' )
328
- workflow .connect (datagrabber , 'mean_image' , overlaymask , 'stat_image ' )
334
+ # workflow.connect(datagrabber, 'mask', overlaymask, 'background_image')
335
+ workflow .connect (datagrabber , 'mean_image' , plotanat , 'brain ' )
329
336
#workflow.connect(overlaymask,'out_file', slicermask, 'in_file')
330
337
331
338
write_rep = pe .Node (interface = ReportSink (orderfields = ['Introduction' ,
332
339
'in_file' ,
333
340
'config_params' ,
334
341
'Art_Detect' ,
335
- 'Brain_Mask_and_Mean_Functional' ,
342
+ 'Mean_Functional' ,
343
+ 'Ribbon' ,
336
344
'motion_plots' ,
337
345
'tsdiffana' ,
338
346
'ADnorm' ,
@@ -344,7 +352,7 @@ def QA_workflow(name='QA'):
344
352
write_rep .inputs .report_name = "Preprocessing_Report"
345
353
write_rep .inputs .json_sink = c .json_sink
346
354
workflow .connect (infosource ,'subject_id' ,write_rep ,'container' )
347
- workflow .connect (overlaymask , 'fnames ' , write_rep , "Brain_Mask_and_Mean_Functional " )
355
+ workflow .connect (plotanat , 'images ' , write_rep , "Mean_Functional " )
348
356
#workflow.connect(slicermask,'out_file', write_rep, "Brain_Mask_and_Mean_Functional")
349
357
350
358
# Define Inputs
@@ -376,7 +384,7 @@ def QA_workflow(name='QA'):
376
384
workflow .connect (convert ,'out_file' ,voltransform ,'target_file' )
377
385
workflow .connect (inputspec ,'reg_file' ,voltransform ,'reg_file' )
378
386
workflow .connect (inputspec ,'tsnr' ,voltransform , 'source_file' )
379
-
387
+ workflow . connect ( plotribbon , 'images' , write_rep , 'Ribbon' )
380
388
workflow .connect (voltransform ,'transformed_file' , overlaynew ,'stat_image' )
381
389
workflow .connect (convert ,'out_file' , overlaynew ,'background_image' )
382
390
@@ -403,7 +411,7 @@ def QA_workflow(name='QA'):
403
411
a .base_dir = c .working_dir
404
412
a .write_graph ()
405
413
a .inputs .inputspec .config_params = start_config_table ()
406
-
414
+ a . config = { 'execution' : { 'crashdump_dir' : c . crash_dir }}
407
415
if c .run_on_grid :
408
416
a .run (plugin = c .plugin ,plugin_args = c .plugin_args )
409
417
else :
0 commit comments