-
Notifications
You must be signed in to change notification settings - Fork 15
/
tbx_cfg_rsHRF.m
896 lines (798 loc) · 38 KB
/
tbx_cfg_rsHRF.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
function HRFrs = tbx_cfg_rsHRF
% Configuration file for toolbox 'rsHRF'
% https://github.com/guorongwu/rsHRF
% $Id: rsHRF.m
if ~isdeployed
addpath(fullfile(spm('Dir'),'toolbox','rsHRF'));
end
% ---------------------------------------------------------------------
% NIfTI Data
% ---------------------------------------------------------------------
GNIfTI_Data = cfg_files;
GNIfTI_Data.tag = 'images';
GNIfTI_Data.name = 'Scans';
GNIfTI_Data.help = {'Select NIfTI/GIfTI images.'};
GNIfTI_Data.filter = {'image','mesh'};
GNIfTI_Data.ufilter = '.*';
GNIfTI_Data.num = [1 inf];
GNIfTI_Data.help = {'3D or 4D NIfTI images; 2D GIfTI file (.gii)'
'or select 1st volume/frame of a 4D NIfTI file,'
'we will expand all the volumes from this file.'};
% ---------------------------------------------------------------------
% ROI signal Data
% ---------------------------------------------------------------------
Signal_file = cfg_files;
Signal_file.tag = 'sigdata';
Signal_file.name = 'Preprocessed ROI signals';
Signal_file.help = {'Select ROI signal files.'};
Signal_file.filter = 'any';
Signal_file.ufilter = '.*';
Signal_file.num = [1 1];
Signal_file.help = { 'Select the *.txt/*.mat file(s) containing your ROI signal.' };
% ---------------------------------------------------------------------
% name Name
% ---------------------------------------------------------------------
name = cfg_entry;
name.tag = 'name';
name.name = 'Variable Name in the Mat-file';
name.help = {
'Only for *.mat file'
'Enter the variable name of your ROI signals in Mat file; eg. ''data'' '};
name.strtype = 's';
name.val = {''};
name.num = [1 inf];
Signal_Dat = cfg_branch;
Signal_Dat.tag = 'Datasig';
Signal_Dat.name = 'Data';
Signal_Dat.val = {Signal_file, name};
Signal_Dat.help = {
'Select the *.txt/*.mat file(s) containing details of your ROI signal.'
'You will need to enter the "Variable Name in Mat-file" if you select Mat-file '
};
Signal_Data = cfg_repeat;
Signal_Data.tag = 'Data';
Signal_Data.name = 'Data';
Signal_Data.values = {Signal_Dat};
Signal_Data.num = [1 inf];
Signal_Data.help = {
'The same parameters specified below '
'will be applied to all data'
};
% ---------------------------------------------------------------------
% odir Output Directory
% ---------------------------------------------------------------------
Outdir = cfg_files;
Outdir.tag = 'outdir';
Outdir.name = 'Output Directory';
Outdir.help = {'Select the directory where write analysis results.'};
Outdir.filter = 'dir';
Outdir.ufilter = '.*';
Outdir.num = [1 1];
Outdir.val = {{''}};
% ---------------------------------------------------------------------
% RT Interscan interval
% ---------------------------------------------------------------------
TR = cfg_entry;
TR.tag = 'TR';
TR.name = 'TR';
TR.help = {'Interscan interval, TR, (specified in seconds). This is the time between acquiring a plane of one volume and the same plane in the next volume. It is assumed to be constant throughout.'};
TR.strtype = 'r';
TR.num = [1 1];
% ---------------------------------------------------------------------
% Bands
% ---------------------------------------------------------------------
Bands = cfg_entry;
Bands.tag = 'bands';
Bands.name = 'Band-pass filter(Hz)';
Bands.help = {'0.01 ~ 0.1 Hz. '};
Bands.strtype = 'e';
Bands.val = {[0.01, 0.1]};
Bands.num = [1 2];
TR2filter = TR;
TR2filter.val = {nan};
TR2filter.help = {'Keep "nan" if it has been specified in HRF estimation step.'};
% ---------------------------------------------------------------------
% Bandfilters
% ---------------------------------------------------------------------
Bandfilter = cfg_repeat;
Bandfilter.tag = 'BPF';
Bandfilter.name = 'Band-pass Filter';
Bandfilter.help = {'Band-pass Filter.'};
Bandfilter.values = {Bands,TR2filter};
Bandfilter.num = [0 2];
% ---------------------------------------------------------------------
% Despiking
% ---------------------------------------------------------------------
Despiking = cfg_menu;
Despiking.tag = 'Despiking';
Despiking.name = 'Despiking';
Despiking.help = {'Temporal despiking with a hyperbolic tangent squashing function'};
Despiking.labels = {'No', 'Yes'};
Despiking.values = {0,1};
Despiking.val = {0};
% ---------------------------------------------------------------------
% Detrend
% ---------------------------------------------------------------------
Detrending = cfg_menu;
Detrending.tag = 'Detrend';
Detrending.name = 'Polynomial Detrending';
Detrending.help = {'...'};
Detrending.labels = {'No', 'Linear', '2nd order Poly', '3rd order Poly'};
Detrending.values = {0,1,2,3};
Detrending.val = {0};
% ---------------------------------------------------------------------
% Despiking
% ---------------------------------------------------------------------
ROI1st = cfg_menu;
ROI1st.tag = 'which1st';
ROI1st.name = 'Which First?';
ROI1st.labels = {
'First denoise then generate ROI signal'
'First generate ROI signal then denoise'
'No ROI analysis'
}';
ROI1st.values = {1,2,3};
ROI1st.val = {3};
% ---------------------------------------------------------------------
% ROI
% ---------------------------------------------------------------------
ROIs_coordinate = cfg_entry;
ROIs_coordinate.tag = 'ROI';
ROIs_coordinate.name = 'ROI (x,y,z,radius [in mm])';
ROIs_coordinate.strtype = 'e';
ROIs_coordinate.num = [inf 4];
ROIs_coordinate.val = {[4,-53,26,6];};
ROIs_coordinate.help = {'ROI (x, y & z, in mm, with k mm radius)'};
% ---------------------------------------------------------------------
% ROI mask
% ---------------------------------------------------------------------
ROImasks = cfg_files;
ROImasks.tag = 'images';
ROImasks.name = 'ROI mask images';
ROImasks.help = {'Select ROI mask images (>=1).'};
ROImasks.filter = 'image';
ROImasks.ufilter = '.*';
ROImasks.val = {{''}};
ROImasks.num = [1 inf];
ROImasks.help = {'you can select more than one NIfTI image'};
% ---------------------------------------------------------------------
% White matter/CSF/Whole brain mask
% ---------------------------------------------------------------------
covmasks = ROImasks ;
covmasks.name = 'Covariate images (white matter, CSF, whole brain mask etc.)';
% ---------------------------------------------------------------------
% Mean or Principal component for covariate images
% ---------------------------------------------------------------------
mpc = cfg_entry;
mpc.tag = 'mpc';
mpc.name = 'Mean or Eigenvariate';
mpc.help = {'0: mean signal'
'1: 1st eigenvariate (principal component,PC)'
'5: 1st to 5th eigenvariates'
'[0 1 2]: Extract mean from the 1st mask, 1st PC from 2nd mask, 1st to 2nd PCs from 3rd mask'
};
mpc.strtype = 'e';
mpc.val = {[0]};
mpc.num = [1 inf];
WMCSFmasks = cfg_branch;
WMCSFmasks.tag = 'imcov';
WMCSFmasks.name = 'Image Covariates';
WMCSFmasks.help = {'Only for NIfTI data'
'Image mask to extract Regressors that may confound the data.'};
WMCSFmasks.val = {covmasks, mpc};
% ---------------------------------------------------------------------
% multi_reg Multiple regressors
% ---------------------------------------------------------------------
multi_reg = cfg_files;
multi_reg.tag = 'multi_reg';
multi_reg.name = 'Multiple regressors';
multi_reg.val = {{''}};
multi_reg.help = {
'Select the *.txt/*.mat file(s) containing details of your multiple regressors. '
'If you have multiple regressors eg. realignment parameters (rp_*.txt), then entering the details a regressor at a time is very inefficient. This option can be used to load all the required information in one go. '
'You will first need to create a *.mat file containing a matrix R or a *.txt file containing the regressors. Each column of R will contain a different regressor.'
''
}';
multi_reg.filter = 'mat';
multi_reg.ufilter = '.*';
multi_reg.num = [0 Inf];
% ---------------------------------------------------------------------
% generic Regressors
% ---------------------------------------------------------------------
covreg = cfg_repeat;
covreg.tag = 'generic';
covreg.name = 'Nuisance Covariates';
covreg.help = {'Regressors that may confound the data.'};
covreg.values = {multi_reg WMCSFmasks};
covreg.num = [0 Inf];
% ---------------------------------------------------------------------
% ROI Atlas
% ---------------------------------------------------------------------
Atlas = cfg_files;
Atlas.tag = 'atlas';
Atlas.name = 'Atlas image';
Atlas.help = {'Select a Atlas image.'};
Atlas.filter = 'image';
Atlas.ufilter = '.*';
Atlas.val = {{''}};
Atlas.num = [1 1];
% ---------------------------------------------------------------------
% ROI Mesh Atlas
% ---------------------------------------------------------------------
Atlasmesh = cfg_files;
Atlasmesh.tag = 'meshatlas';
Atlasmesh.name = 'Mesh Atlas';
Atlasmesh.help = {'Select a surface based Atlas.'};
Atlasmesh.filter = 'mesh';
Atlasmesh.ufilter = '.*';
Atlasmesh.val = {{''}};
Atlasmesh.num = [1 1];
% ---------------------------------------------------------------------
% ROI Mesh
% ---------------------------------------------------------------------
maskmesh = cfg_files;
maskmesh.tag = 'meshmask';
maskmesh.name = 'Mesh Mask';
maskmesh.help = {'Select a surface based mask.'};
maskmesh.filter = 'mesh';
maskmesh.ufilter = '.*';
maskmesh.val = {{''}};
maskmesh.num = [1 1];
% ---------------------------------------------------------------------
% ROI All together
% ---------------------------------------------------------------------
genericROI = cfg_repeat;
genericROI.tag = 'genericROI';
genericROI.name = 'ROI (Coordinate / NIfTI)';
genericROI.help = {
'Select ROIs (Coordinates / NIfTI)'
}';
genericROI.values = {ROIs_coordinate ROImasks Atlas};
genericROI.num = [1 Inf];
% ---------------------------------------------------------------------
% SurfROI All together
% ---------------------------------------------------------------------
genericSurfROI = cfg_repeat;
genericSurfROI.tag = 'genericROI';
genericSurfROI.name = 'ROI (GIfTI)';
genericSurfROI.help = {
'Select ROIs (GIfTI)'
}';
genericSurfROI.values = {maskmesh Atlasmesh};
genericSurfROI.num = [1 Inf];
% ---------------------------------------------------------------------
% Denoising
% ---------------------------------------------------------------------
Denoising = cfg_branch;
Denoising.tag = 'Denoising';
Denoising.name = 'Denoising';
Denoising.val = {covreg, Detrending, Bandfilter, Despiking,ROI1st};
Denoising.help = {'Remove possible confounds.'};
Denoising2 = Denoising;
Denoising2.val = {covreg, Detrending, Bandfilter, Despiking};
Denoising_surf = Denoising;
Denoising_surf.val = {covreg, Detrending, Bandfilter, Despiking, ROI1st};
% ---------------------------------------------------------------------
% Despiking
% ---------------------------------------------------------------------
rmoutlier = cfg_menu;
rmoutlier.tag = 'rmoutlier';
rmoutlier.name = 'Remove Outlier& Inpaint 3D';
rmoutlier.help = {'Remove Outlier in HRF parameters (replaced by nan ) and inpaint nan value by inpaint_nans3.m'};
rmoutlier.labels = {'No', 'Yes'};
rmoutlier.values = {0,1};
rmoutlier.val = {1};
% ---------------------------------------------------------------------
% Explicit Mask
% ---------------------------------------------------------------------
brainmask = cfg_files;
brainmask.tag = 'mask';
brainmask.name = 'Explicit Mask';
brainmask.help = {'Specify an image for expicity masking the analysis.'};
brainmask.filter = {'image','mesh'};
brainmask.ufilter = '.*';
brainmask.val = {{''}};
brainmask.num = [1 1];
%--------------------------------------------------------------------------
% prefix Filename Prefix
%--------------------------------------------------------------------------
prefix = cfg_entry;
prefix.tag = 'prefix';
prefix.name = 'Filename prefix';
prefix.strtype = 's';
prefix.num = [1 Inf];
prefix.help = {'String to be prepended to the filenames of the HRF deconvolved image file(s). Default prefix is ''Deconv_''.'};
prefix.val = {'Deconv_'};
%--------------------------------------------------------------------------
% HRF model
%--------------------------------------------------------------------------
hrfm = cfg_menu;
hrfm.tag = 'hrfm';
hrfm.name = 'HRF Basis Functions';
hrfm.labels = {
'Canonical HRF (with time derivative)'
'Canonical HRF (with time and dispersion derivatives)'
'Gamma Functions'
'Fourier Set'
'Fourier Set (Hanning)'
'Finite Impulse Response (FIR)'
'Smooth FIR'
}';
hrfm.values = {1,2,3,4,5,6,7};
hrfm.val = {2};
hrfm.help = {
'The canonical HRF combined with time and dispersion derivatives comprise an ''informed'' basis set, as the shape of the canonical response conforms to the hemodynamic response that is commonly observed. The incorporation of the derivate terms allow for variations in subject-to-subject and voxel-to-voxel responses. The time derivative allows the peak response to vary by plus or minus a second and the dispersion derivative allows the width of the response to vary.'
'The Fourier set consists of a constant and KF sine and KF cosine functions of harmonic periods T, T/2,T/KF seconds(i.e. K = 2KF + 1 basis functions). Linear combinations of the (orthonormal) FIR or Fourier basis functions can capture any shape of response up to a specified frequency (KF /T in the case of the Fourier set).'
'The HRF is assumed to be bounded at zero for t<0 and t>T , the Fourier basis functions can also be windowed (e.g. by a Hanning window) within this range.'
'A set of gamma functions of increasing dispersions can be obtained by increasing p (p is an integer phase-delay, the peak delay is given by pd, and the dispersion by pd^2, d is the time-scaling). In SPM, these functions (as with all basis functions) are orthogonalized with respect to one another.'
'Impulse Response (FIR) set captures any shape of response up to a given frequency limit.'
'Smooth FIR: add a gaussian prior on the filter parameter alpha - It filtered out some noise of the standard FIR.'
};
% ---------------------------------------------------------------------
% length of HRF {seconds}
% ---------------------------------------------------------------------
hrflen = cfg_entry;
hrflen.tag = 'hrflen';
hrflen.name = 'Length of HRF (seconds)';
hrflen.help = {'Enter the length/duration of HRF {seconds}, i.e. Post-stimulus window length (in seconds).'};
hrflen.strtype = 'r';
hrflen.num = [Inf 1];
hrflen.val = {32};
% ---------------------------------------------------------------------
% Number of basis functions
% ---------------------------------------------------------------------
num_basis = cfg_entry;
num_basis.tag = 'num_basis';
num_basis.name = 'Number of basis functions (k)';
num_basis.help = {'Only setting for ''Gamma Functions'' (k), ''Fourier Set'' (2k+1), ''Fourier Set (Hanning)'' (2k+1)'};
num_basis.strtype = 'n';
num_basis.num = [1 1];
num_basis.val = {nan};
% ---------------------------------------------------------------------
% Minimum & Maximum delay
% ---------------------------------------------------------------------
mdelay = cfg_entry;
mdelay.tag = 'mdelay';
mdelay.name = 'Minimum & Maximum delay (seconds)';
mdelay.help = {'4 ~ 8 s'};
mdelay.strtype = 'e';
mdelay.val = {[4, 8]};
mdelay.num = [1 2];
% ---------------------------------------------------------------------
% Threshold for event detection
% ---------------------------------------------------------------------
thr = cfg_entry;
thr.tag = 'thr';
thr.name = 'Threshold (SD) for event detection';
thr.help = {'default Threshold = 1, i.e. local peaks and ( amplitude > mean + Threshold*standard deviation threshold) were selected as the candicate events'};
thr.strtype = 'r';
thr.val = {1};
thr.num = [1 1];
% ---------------------------------------------------------------------
% local spontaneou event definition
% ---------------------------------------------------------------------
localK = cfg_entry;
localK.tag = 'localK';
localK.name = 'K (local peak f([-K:K]+t)<=f(t) )';
localK.help = {'default K = 2, i.e. local peaks definition f([-2: 2]+t) <= f(t)'};
localK.strtype = 'r';
localK.val = {2};% local peak, f([-2: 2]+t) <= f(t)
localK.num = [1 1];
% ---------------------------------------------------------------------
% Temporal mask
% ---------------------------------------------------------------------
tmask = cfg_entry;
tmask.tag = 'tmask';
tmask.name = 'Temporal mask for event detection';
tmask.help = {'default no mask for BOLD event detect (using nan). 0(exclude) / 1(include) for point process.'
'e.g. [0 1 0 0 1 1 1 1], ssame length with BOLD signal'};
tmask.strtype = 'r';
tmask.val = {nan};
tmask.num = [1 inf];
% ---------------------------------------------------------------------
% cvi Serial correlations
% ---------------------------------------------------------------------
cvi = cfg_menu;
cvi.tag = 'cvi';
cvi.name = 'Serial correlations';
cvi.help = {
'Serial correlations in fMRI time series due to aliased biorhythms and unmodelled neuronal activity can be accounted for using an autoregressive AR(1) model during parameter estimation. '
% 'This estimate assumes the same correlation structure for each voxel, within each session. ReML estimates are then used to correct for non-sphericity during inference by adjusting the statistics and degrees of freedom appropriately. The discrepancy between estimated and actual intrinsic (i.e. prior to filtering) correlations are greatest at low frequencies. Therefore specification of the high-pass filter is particularly important. '
% 'Serial correlation can be ignored if you choose the ''none'' option. Note that the above options only apply if you later specify that your model will be estimated using the Classical (ReML) approach. If you choose Bayesian estimation these options will be ignored. For Bayesian estimation, the choice of noisemodel (AR model order) is made under the estimation options. '
}';
cvi.labels = {'none', 'AR(1)', 'AR(2)','AR(3)'};
cvi.values = {0,1,2,3};
cvi.val = {0};
% ---------------------------------------------------------------------
% fmri_t Microtime resolution
% ---------------------------------------------------------------------
fmri_t = cfg_entry;
fmri_t.tag = 'fmri_t';
fmri_t.name = 'Microtime resolution';
fmri_t.help = {
'value >1 does not work for FIR or sFIR'
''
'The microtime resolution, t, is the number of time-bins per scan used when building regressors. '
'If you have performed slice-timing correction, change this parameter to match the number of slices specified there; otherwise, you would typically not need to change this.'
''
}';
fmri_t.strtype = 'n';
fmri_t.num = [1 1];
fmri_t.val = {1};
% ---------------------------------------------------------------------
% fmri_t0 Microtime onset
% ---------------------------------------------------------------------
fmri_t0 = cfg_entry;
fmri_t0.tag = 'fmri_t0';
fmri_t0.name = 'Microtime onset';
fmri_t0.help = {
'value >1 works for Canon2DD or CanonTD'
''
'The microtime onset, t0, is the reference time-bin at which the regressors are resampled to coincide with data acquisition.'
'If you have performed slice-timing correction, you must change this parameter to match the reference slice specified there.'
'Otherwise, you might still want to change this if you have non-interleaved acquisition and you wish to sample the regressors so that they are appropriate for a slice in a particular part of the brain.'
'For example, if t0 = 1, then the regressors will be appropriate for the first slice; if t0=t, then the regressors will be appropriate for the last slice.'
'Setting t0 = t/2 is a good compromise if you are interested in slices at the beginning and end of the acquisition, or if you have interleaved data, or if you have 3D EPI data.'
''
}';
fmri_t0.strtype = 'n';
fmri_t0.num = [1 1];
fmri_t0.val = {1};
% HRF deconvolution
%--------------------------------------------------------------------------
HRFdeconv = cfg_menu;
HRFdeconv.tag = 'hrfdeconv';
HRFdeconv.name = 'HRF Deconvolution';
HRFdeconv.labels = {
'HRF Deconvolution on Unfiltered Data'
'HRF Deconvolution on Filtered Data'
'DO NOT Perform HRF Deconvolution'
}';
HRFdeconv.values = {1,2,3};
HRFdeconv.val = {1};
HRFdeconv.help = {'HRF deconvolution on filtered or unfiltered data'};
% ---------------------------------------------------------------------
% HRF estimation
% ---------------------------------------------------------------------
HRFE = cfg_branch;
HRFE.tag = 'HRFE';
HRFE.name = 'HRF estimation';
HRFE.val = {hrfm, TR, hrflen, num_basis, mdelay, cvi, fmri_t, fmri_t0,thr,localK, tmask, HRFdeconv};
HRFE.help = {'HRF estimation.'};
% ---------------------------------------------------------------------
% save deconvolved signal
% ---------------------------------------------------------------------
deconv_save = cfg_menu;
deconv_save.tag = 'deconv_save';
deconv_save.name = 'Save Deconvolved Data';
deconv_save.labels = {'No', 'Yes'};
deconv_save.values = {0,1};
deconv_save.val = {1};
deconv_save.help = {'...'};
% ---------------------------------------------------------------------
% save HRF in mat-file
% ---------------------------------------------------------------------
hrfmat_save = deconv_save;
hrfmat_save.tag = 'hrfmat_save';
hrfmat_save.name = 'Save HRF mat-file';
% ---------------------------------------------------------------------
% save HRF in NIfTI-file
% ---------------------------------------------------------------------
hrfnii_save = deconv_save;
hrfnii_save.tag = 'hrfnii_save';
hrfnii_save.name = 'Save HRF NIfTI/GIfTI-file';
% ---------------------------------------------------------------------
% save Job parameters in mat-file
% ---------------------------------------------------------------------
job_save = deconv_save;
job_save.tag = 'job_save';
job_save.name = 'Save job parameters';
% ---------------------------------------------------------------------
% Save files
% ---------------------------------------------------------------------
Datasave = cfg_branch;
Datasave.tag = 'savedata';
Datasave.name = 'Save Data';
Datasave.val = {deconv_save,hrfmat_save,hrfnii_save, job_save};
Datasave.help = {'Save files.'};
DatasaveROI = Datasave;
DatasaveROI.val = {deconv_save,hrfmat_save, job_save};
% ---------------------------------------------------------------------
% seed to voxels or ROI2ROI
% ---------------------------------------------------------------------
seedROI = cfg_menu;
seedROI.tag = 'Seed_ROI';
seedROI.name = 'Seed or ROI';
seedROI.help = {'Seed: 1 to n'; ' ROI: n to n'};
seedROI.labels = {'Seed to voxels', 'ROI to ROI'};
seedROI.values = {0,1};
seedROI.val = {0};
seedROIsurf = seedROI;
seedROIsurf.labels = {'Seed to vertices', 'ROI to ROI'};
% ---------------------------------------------------------------------
% connectivity method FC
% ---------------------------------------------------------------------
FCM = cfg_menu;
FCM.tag = 'method';
FCM.name = 'Method';
FCM.help = {'...'};
FCM.labels = {'Pearson Correlation', 'Pearson Partial Correlation (only for ROIs)', 'Spearman Correlation', 'Spearman Partial Correlation (only for ROIs)'};
FCM.values = {4,5,6,7};
FCM.val = {4};
% ---------------------------------------------------------------------
% connectivity method GC
% ---------------------------------------------------------------------
GCM = FCM;
GCM.labels = {'Pairwise GC(Granger causality)', 'Conditional GC (only for ROIs)', 'Partially Conditioned GC (only for ROIs)'};
GCM.values = {1,2,3};
GCM.val = {1};
% ---------------------------------------------------------------------
% data for connectivity
% ---------------------------------------------------------------------
CONNData = cfg_menu;
CONNData.tag = 'data4conn';
CONNData.name = 'Data for Connectivity';
CONNData.help = {'Select BOLD or/and Deconvolved BOLD'};
CONNData.labels = {'BOLD', 'Deconvolved BOLD', 'BOLD and Deconvolved BOLD'};
CONNData.values = {1,2,3};
CONNData.val = {2};
% ---------------------------------------------------------------------
% Model order for GC
% ---------------------------------------------------------------------
Morder = cfg_entry;
Morder.tag = 'morder';
Morder.name = 'Model order for GC';
Morder.help = {'default model order = 1, input only for Granger causality analysis'};
Morder.strtype = 'r';
Morder.val = {1};
Morder.num = [1 1];
% ---------------------------------------------------------------------
% Information for PCGC
% ---------------------------------------------------------------------
ndinfo = cfg_entry;
ndinfo.tag = 'ndinfo';
ndinfo.name = 'Parameters for PCGC';
ndinfo.help = {'Number of conditional variable (nd), Maximum nd'
'Parameters for Partially Conditioned Granger Causality Analysis'
'Recommended value: nd = 6, maximum nd = nd+1'};
ndinfo.strtype = 'r';
ndinfo.val = {[nan nan]};
ndinfo.num = [1 2];
%--------------------------------------------------------------------------
% prefix Connectivity Prefix
%--------------------------------------------------------------------------
conname = prefix;
conname.val = {'Conn_'};
conname.num = [1 Inf];
conname.help ={'String to be prepended to the filenames of the connectivity file(s). Default prefix is "Conn_".'};
% ---------------------------------------------------------------------
% Connectivity Analysis FC
% ---------------------------------------------------------------------
FCA = cfg_branch;
FCA.tag = 'conn';
FCA.name = 'FC';
FCA.val = {CONNData, seedROI, genericROI, FCM, conname};
FCA.help = {'Functional connectivity analysis.'};
FCA2 = FCA;
FCA2.val = {seedROI, genericROI, FCM, conname};
FCAsurf = FCA;
FCAsurf.val = {CONNData, seedROIsurf, genericSurfROI, FCM, conname};
FCAsurf2 = FCA;
FCAsurf2.val = {seedROIsurf, genericSurfROI, FCM, conname};
FCAROI = FCA;
FCAROI.val = {CONNData, FCM, conname};
FCAROI2 = FCAROI;
FCAROI2.val = {FCM, conname};
% ---------------------------------------------------------------------
% Connectivity Analysis GC
% ---------------------------------------------------------------------
GCA = cfg_branch;
GCA.tag = 'connG';
GCA.name = 'GC';
GCA.val = {CONNData, seedROI, genericROI, GCM, Morder, ndinfo, conname};
GCA.help = {'Granger causality analysis.'};
GCA2 = GCA;
GCA2.val = {seedROI, genericROI, GCM, Morder, ndinfo, conname};
GCAsurf = GCA;
GCAsurf.val = {CONNData, seedROIsurf, genericSurfROI, GCM, Morder, ndinfo, conname};
GCAsurf2 = GCA;
GCAsurf2.val = {seedROIsurf, genericSurfROI, GCM, Morder, ndinfo, conname};
GCAROI = GCA;
GCAROI.val = {CONNData, GCM, Morder, ndinfo, conname};
GCAROI2 = GCAROI;
GCAROI2.val = {GCM, Morder, ndinfo,conname};
% connectivity
% ---------------------------------------------------------------------
cona = cfg_repeat;
cona.tag = 'connectivity';
cona.name = 'Connectivity Analysis';
cona.help = {'Granger causality or Functional connectivity analysis.'};
cona.values = {FCA,GCA};
cona.num = [0 inf];
cona2 = cona;
cona2.values = {FCA2,GCA2};
conaSurf = cona;
conaSurf.values = {FCAsurf,GCAsurf};
conaSurf2= cona;
conaSurf2.values = {FCAsurf2,GCAsurf2};
connROI = cona;
connROI.values = {FCAROI, GCAROI};
connROI2 = cona;
connROI2.values = {FCAROI2, GCAROI2};
% ---------------------------------------------------------------------
% ROI-wise HRF deconvolution
% ---------------------------------------------------------------------
ROI_rsHRF = cfg_exbranch;
ROI_rsHRF.tag = 'ROI_rsHRF';
ROI_rsHRF.name = 'ROI-wise HRF deconvolution';
ROI_rsHRF.val = {GNIfTI_Data, Denoising, genericROI, HRFE, brainmask, connROI, Outdir, DatasaveROI, prefix};
ROI_rsHRF.prog = @wgr_vox_ROI_rsHRF_conn;
ROI_rsHRF.help = {'NIfTI data'};
% ---------------------------------------------------------------------
% (Surface) ROI-wise HRF deconvolution
% ---------------------------------------------------------------------
SurfROI_rsHRF = cfg_exbranch;
SurfROI_rsHRF.tag = 'SurfROI_rsHRF';
SurfROI_rsHRF.name = '(Surface)ROI-wise HRF deconvolution';
SurfROI_rsHRF.val = {GNIfTI_Data, Denoising_surf, genericSurfROI, HRFE, brainmask, connROI, Outdir, DatasaveROI, prefix};
SurfROI_rsHRF.prog = @wgr_vertex_ROI_rsHRF_conn;
% ---------------------------------------------------------------------
% ROI-wise CONN
% ---------------------------------------------------------------------
ROI_conn = cfg_exbranch;
ROI_conn.tag = 'ROI_conn';
ROI_conn.name = 'ROI-wise Connectivity Analysis';
ROI_conn.val = {GNIfTI_Data, Denoising, genericROI, brainmask, connROI2, Outdir,job_save};
ROI_conn.prog = @wgr_vox_ROI_rsHRF_conn;
ROI_conn.help = {'NIfTI data'};
% ---------------------------------------------------------------------
% (Surface) ROI-wise CONN
% ---------------------------------------------------------------------
SurfROI_conn = cfg_exbranch;
SurfROI_conn.tag = 'SurfROI_conn';
SurfROI_conn.name = '(Surface)ROI-wise Connectivity Analysis';
SurfROI_conn.val = {GNIfTI_Data, Denoising, genericSurfROI, brainmask, connROI2, Outdir,job_save};
SurfROI_conn.prog = @wgr_vertex_ROI_rsHRF_conn;
SurfROI_conn.help = {'GIfTI data'};
% ---------------------------------------------------------------------
% voxel-wise HRF deconvolution
% ---------------------------------------------------------------------
vox_rsHRF = cfg_exbranch;
vox_rsHRF.tag = 'vox_rsHRF';
vox_rsHRF.name = 'Voxel-wise HRF deconvolution';
vox_rsHRF.val = {GNIfTI_Data, Denoising, HRFE, rmoutlier,brainmask, cona, Outdir, Datasave, prefix};
vox_rsHRF.prog = @wgr_vox_ROI_rsHRF_conn;
vox_rsHRF.help = {'NIfTI data'}; %{'Voxel-wise HRF deconvolution'};
% ---------------------------------------------------------------------
% vertex-wise HRF deconvolution
% ---------------------------------------------------------------------
mesh_rsHRF = cfg_exbranch;
mesh_rsHRF.tag = 'mesh_rsHRF';
mesh_rsHRF.name = 'Vertex-wise HRF deconvolution';
mesh_rsHRF.val = {GNIfTI_Data, Denoising, HRFE, brainmask, conaSurf, Outdir, Datasave, prefix};
mesh_rsHRF.prog = @wgr_vertex_ROI_rsHRF_conn;
mesh_rsHRF.help = {'GIfTI data'}; %{'Vertex-wise HRF deconvolution'};
% ---------------------------------------------------------------------
% voxel-wise CONN
% ---------------------------------------------------------------------
vox_conn = cfg_exbranch;
vox_conn.tag = 'vox_conn';
vox_conn.name = 'Voxel-wise Connectivity Analysis';
vox_conn.val = {GNIfTI_Data, Denoising, brainmask, cona2, Outdir, job_save};
vox_conn.prog = @wgr_vox_ROI_rsHRF_conn;
vox_conn.help = {'NIfTI data'};
% ---------------------------------------------------------------------
% vertex-wise CONN
% ---------------------------------------------------------------------
mesh_conn = cfg_exbranch;
mesh_conn.tag = 'mesh_conn';
mesh_conn.name = 'Vertex-wise Connectivity Analysis';
mesh_conn.val = {GNIfTI_Data, Denoising, brainmask, conaSurf2, Outdir, job_save};
mesh_conn.prog = @wgr_vertex_ROI_rsHRF_conn;
mesh_conn.help = {'NIfTI data'};
% ---------------------------------------------------------------------
% ROI-signal HRF deconvolution
% ---------------------------------------------------------------------
sig_rsHRF = cfg_exbranch;
sig_rsHRF.tag = 'sig_rsHRF';
sig_rsHRF.name = 'ROI signal HRF deconvolution';
sig_rsHRF.val = {Signal_Data, Denoising2, HRFE, connROI, Outdir, DatasaveROI, prefix};
sig_rsHRF.help = {'..'};
sig_rsHRF.prog = @wgr_sig_rsHRF_conn;
sig_rsHRF.help = {'Please DO NOT select NIFTI files in Nuisance Covariates!'}; %{'ROI-signal HRF deconvolution'
%'Please DO NOT select NIFTI files in Nuisance Covariates!'
% ---------------------------------------------------------------------
% ROI-signal CONN
% ---------------------------------------------------------------------
sig_conn = cfg_exbranch;
sig_conn.tag = 'sig_conn';
sig_conn.name = 'ROI-signal Connectivity Analysis';
sig_conn.val = {Signal_Data, Denoising2, connROI2, Outdir,job_save};
sig_conn.help = {'..'};
sig_conn.prog = @wgr_sig_rsHRF_conn;
sig_conn.help = {'Please DO NOT select NIFTI files in Nuisance Covariates!'};
% ---------------------------------------------------------------------
% HRF Mat-files
% ---------------------------------------------------------------------
HRF_mat = cfg_files;
HRF_mat.tag = 'HRF_mat';
HRF_mat.name = 'HRF Mat-files';
HRF_mat.val = {{''}};
HRF_mat.help = {
'Select individual *.mat file(s) containing HRF shapes (generate by rsHRF toolbox). '
'Add a new ''HRF Mat-files'' for different groups (Plot each group HRF shapes seperately)'
}';
HRF_mat.filter = 'mat';
HRF_mat.ufilter = '.*';
HRF_mat.num = [0 Inf];
% ---------------------------------------------------------------------
% Statistical NIfTI file
% ---------------------------------------------------------------------
snifti = cfg_files;
snifti.tag = 'stat_nii';
snifti.name = 'Statistical Image';
snifti.filter = {'image'};
snifti.ufilter = '.*';
snifti.num = [1 1];
snifti.help = {'Select the statistical image (NIfTI).'
'a statistical image for voxel location.'};
% ---------------------------------------------------------------------
% Statistical NIfTI file
% ---------------------------------------------------------------------
unifti = cfg_files;
unifti.tag = 'underlay_nii';
unifti.name = 'Underlay Image';
unifti.filter = {'image'};
unifti.ufilter = '.*';
unifti.num = [1 1];
unifti.help = {'Select the underlay image (NIfTI).'};
% default_nii = fullfile(spm('Dir'),'canonical','avg152T1.nii');
% ---------------------------------------------------------------------
% GroupID
% ---------------------------------------------------------------------
GroupID = cfg_entry;
GroupID.tag = 'GroupID';
GroupID.name = 'Group ID';
GroupID.help = {'Add a Group ID if you include all different group file together in one ''HRF Mat-files'' ,'
'e.g. 1 1 2 2 3 3'};
GroupID.strtype = 'e';
GroupID.val = {[]};
GroupID.num = [1 inf];
% ---------------------------------------------------------------------
% Group HRF files
% ---------------------------------------------------------------------
HRF_mats = cfg_repeat;
HRF_mats.tag = 'display_mat';
HRF_mats.name = 'HRF mat-files';
HRF_mats.help = {'Select individual Mat-files for HRF shape plotting.'};
HRF_mats.values = {HRF_mat};
HRF_mats.num = [0 Inf];
% ---------------------------------------------------------------------
% Display HRF file
% ---------------------------------------------------------------------
HRF_Display = cfg_exbranch;
HRF_Display.tag = 'display_HRF';
HRF_Display.name = 'HRF Viewer';
HRF_Display.val = {unifti, snifti, HRF_mats};
HRF_Display.prog = @wgr_vox_rsHRF_display;
HRF_Display.help = {'Select the NIfTI files and HRF Mat-files(grouped according to the statistical maps)'};
% ---------------------------------------------------------------------
% rsHRF deconvolution & connectivity analysis
% ---------------------------------------------------------------------
HRFrs = cfg_choice;
HRFrs.tag = 'rsHRF';
HRFrs.name = 'rsHRF';
HRFrs.help = {'resting state HRF deconvolution and connectivity analysis.'};
HRFrs.values = {vox_rsHRF, mesh_rsHRF, ROI_rsHRF, SurfROI_rsHRF, sig_rsHRF, vox_conn, mesh_conn, ROI_conn, SurfROI_conn, sig_conn, HRF_Display};
%======================================================================
function wgr_vox_ROI_rsHRF_conn(job)
rsHRF(job,'volume');
%======================================================================
function wgr_vertex_ROI_rsHRF_conn(job)
rsHRF(job,'mesh')
%======================================================================
function wgr_sig_rsHRF_conn(job)
rsHRF(job,'sig')
%======================================================================
function wgr_vox_rsHRF_display(job)
rsHRF(job,'display')