@@ -361,9 +361,8 @@ def create_workflow(files,
361
361
(segment , normalize_func , [('transformation_mat' , 'parameter_file' )]),
362
362
(realign , slice_timing , [('realigned_files' , 'in_files' )]),
363
363
(slice_timing , normalize_func , [('timecorrected_files' , 'apply_to_files' )]),
364
- (normalize_func , smooth , [('normalized_files' , 'in_files ' )]),
364
+ (normalize_func , art , [('normalized_files' , 'realigned_files ' )]),
365
365
(realign , art , [('realignment_parameters' , 'realignment_parameters' )]),
366
- (smooth , art , [('smoothed_files' , 'realigned_files' )]),
367
366
])
368
367
369
368
def selectN (files , N = 1 ):
@@ -428,7 +427,7 @@ def merge_files(in1, in2):
428
427
wf .connect (art , 'norm_files' , createfilter1 , 'comp_norm' )
429
428
wf .connect (art , 'outlier_files' , createfilter1 , 'outliers' )
430
429
431
- # Filter the motion and art confounds and detrend
430
+
432
431
filter1 = MapNode (fsl .GLM (out_f_name = 'F_mcart.nii' ,
433
432
out_pf_name = 'pF_mcart.nii' ,
434
433
demean = True ),
@@ -439,9 +438,8 @@ def merge_files(in1, in2):
439
438
wf .connect (normalize_func , ('normalized_files' , rename , '_filtermotart' ),
440
439
filter1 , 'out_res_name' )
441
440
wf .connect (createfilter1 , 'out_files' , filter1 , 'design' )
442
- #wf.connect(masktransform, 'transformed_file', filter1, 'mask')
443
441
444
- # Create a filter to remove noise components based on white matter and CSF
442
+
445
443
createfilter2 = MapNode (Function (input_names = ['realigned_file' , 'mask_file' ,
446
444
'num_components' ,
447
445
'extra_regressors' ],
@@ -450,58 +448,44 @@ def merge_files(in1, in2):
450
448
imports = imports ),
451
449
iterfield = ['realigned_file' , 'extra_regressors' ],
452
450
name = 'makecompcorrfilter' )
453
- createfilter2 .inputs .num_components = num_components
451
+ createfilter2 .inputs .num_components = 5
452
+
454
453
wf .connect (createfilter1 , 'out_files' , createfilter2 , 'extra_regressors' )
455
454
wf .connect (filter1 , 'out_res' , createfilter2 , 'realigned_file' )
456
- wf .connect (bin_and_erode , ('out_file' , selectN , 2 ), createfilter2 , 'mask_file' )
455
+ wf .connect (bin_and_erode , 'out_file' , createfilter2 , 'mask_file' )
456
+
457
457
458
- # Filter noise components from unsmoothed data
459
458
filter2 = MapNode (fsl .GLM (out_f_name = 'F.nii' ,
460
459
out_pf_name = 'pF.nii' ,
461
460
demean = True ),
462
461
iterfield = ['in_file' , 'design' , 'out_res_name' ],
463
462
name = 'filter_noise_nosmooth' )
464
- wf .connect (normalize_func , 'normalized_files ' , filter2 , 'in_file' )
465
- wf .connect (normalize_func , ('normalized_files ' , rename , '_unsmooth_cleaned' ),
463
+ wf .connect (filter1 , 'out_res ' , filter2 , 'in_file' )
464
+ wf .connect (filter1 , ('out_res ' , rename , '_unsmooth_cleaned' ),
466
465
filter2 , 'out_res_name' )
467
466
wf .connect (createfilter2 , 'out_files' , filter2 , 'design' )
468
- wf .connect (mask , 'mask_file' , filter2 , 'mask' )
469
467
470
- # Filter noise components from smoothed data
471
- filter3 = MapNode (fsl .GLM (out_f_name = 'F.nii' ,
472
- out_pf_name = 'pF.nii' ,
473
- demean = True ),
474
- iterfield = ['in_file' , 'design' , 'out_res_name' ],
475
- name = 'filter_noise_smooth' )
476
- wf .connect (smooth , ('smoothed_files' , rename , '_cleaned' ),
477
- filter3 , 'out_res_name' )
478
- wf .connect (smooth , 'smoothed_files' , filter3 , 'in_file' )
479
- wf .connect (createfilter2 , 'out_files' , filter3 , 'design' )
480
- wf .connect (mask , 'mask_file' , filter3 , 'mask' )
481
-
482
- # Bandpass filter the data
483
- bandpass1 = Node (Function (input_names = ['files' , 'lowpass_freq' ,
468
+
469
+ bandpass = Node (Function (input_names = ['files' , 'lowpass_freq' ,
484
470
'highpass_freq' , 'fs' ],
485
471
output_names = ['out_files' ],
486
472
function = bandpass_filter ,
487
473
imports = imports ),
488
474
name = 'bandpass_unsmooth' )
489
- bandpass1 .inputs .fs = 1. / TR
475
+ bandpass .inputs .fs = 1. / TR
476
+ bandpass .inputs .highpass_freq = highpass_freq
477
+ bandpass .inputs .lowpass_freq = lowpass_freq
478
+ wf .connect (filter2 , 'out_res' , bandpass , 'files' )
490
479
491
- bandpass1 .inputs .highpass_freq = highpass_freq
492
- bandpass1 .inputs .lowpass_freq = lowpass_freq
493
- wf .connect (filter2 , 'out_res' , bandpass1 , 'files' )
494
480
495
- bandpass2 = bandpass1 .clone (name = 'bandpass_smooth' )
496
- wf .connect (filter3 , 'out_res' , bandpass2 , 'files' )
481
+ wf .connect (bandpass , 'out_files' , smooth , 'in_files' )
482
+
483
+
484
+ collector = Node (Merge (2 ), name = 'collect_streams' )
485
+ wf .connect (smooth , 'smoothed_files' , collector , 'in1' )
486
+ wf .connect (bandpass , 'out_files' , collector , 'in2' )
487
+
497
488
498
- bandpass = Node (Function (input_names = ['in1' , 'in2' ],
499
- output_names = ['out_file' ],
500
- function = merge_files ,
501
- imports = imports ),
502
- name = 'bandpass_merge' )
503
- wf .connect (bandpass1 , 'out_files' , bandpass , 'in1' )
504
- wf .connect (bandpass2 , 'out_files' , bandpass , 'in2' )
505
489
506
490
# Save the relevant data into an output directory
507
491
datasink = Node (interface = DataSink (), name = "datasink" )
@@ -513,16 +497,14 @@ def merge_files(in1, in2):
513
497
wf .connect (art , 'norm_files' , datasink , 'resting.qa.art.@norm' )
514
498
wf .connect (art , 'intensity_files' , datasink , 'resting.qa.art.@intensity' )
515
499
wf .connect (art , 'outlier_files' , datasink , 'resting.qa.art.@outlier_files' )
516
- wf .connect (smooth , 'smoothed_files' , datasink , 'resting.timeseries.fullpass' )
517
500
wf .connect (bin_and_erode , 'out_file' , datasink , 'resting.mask_files' )
518
501
wf .connect (mask , 'mask_file' , datasink , 'resting.mask_files.@brainmask' )
519
502
wf .connect (filter1 , 'out_f' , datasink , 'resting.qa.compmaps.@mc_F' )
520
503
wf .connect (filter1 , 'out_pf' , datasink , 'resting.qa.compmaps.@mc_pF' )
521
504
wf .connect (filter2 , 'out_f' , datasink , 'resting.qa.compmaps' )
522
505
wf .connect (filter2 , 'out_pf' , datasink , 'resting.qa.compmaps.@p' )
523
- wf .connect (filter3 , 'out_f' , datasink , 'resting.qa.compmaps.@sF' )
524
- wf .connect (filter3 , 'out_pf' , datasink , 'resting.qa.compmaps.@sp' )
525
506
wf .connect (bandpass , 'out_file' , datasink , 'resting.timeseries.bandpassed' )
507
+ wf .connect (smooth , 'smoothed_files' , datasink , 'resting.timeseries.smoothed' )
526
508
wf .connect (createfilter1 , 'out_files' ,
527
509
datasink , 'resting.regress.@regressors' )
528
510
wf .connect (createfilter2 , 'out_files' ,
0 commit comments