-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinitAnalysis.m
124 lines (103 loc) · 5.06 KB
/
initAnalysis.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
disp('--------------')
disp('initAnalysis.m')
p.wd = pwd;
p.anaID = 'myAnalysis'; %an ID for your output folder. Potentially useful if you make tweaks
%% Dependencies
addpath(genpath(fullfile(p.wd,'fun')));
% Matlab proprietary toolboxes:
% ->Statistics and Machine Learning (fcdf.m for computing significant voxel activation)
% Only if you want to recompute the empiricalFov
% ->Curve Fitting (only for processFov.m with doWhat='run_forced';)
% ->Image Processing (only for processFov.m with doWhat='run_forced';)
% Matlab community toolboxes
matDependencyPath = fullfile(p.wd,'matlabFileExchange'); if ~exist(matDependencyPath,'dir'); mkdir(matDependencyPath); end
matDependencyNameList = {
'https://www.mathworks.com/matlabcentral/fileexchange/25536-red-blue-colormap'
'https://www.mathworks.com/matlabcentral/fileexchange/27418-fdr_bh'
'https://www.mathworks.com/matlabcentral/fileexchange/41961-nanconv'
'https://www.mathworks.com/matlabcentral/fileexchange/27991-tight_subplot-nh-nw-gap-marg_h-marg_w'
};
matDependencyUrlList = {
'https://www.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/25536/versions/1/download/zip'
'https://www.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/27418/versions/10/download/zip'
'https://www.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/41961/versions/2/download/zip'
'https://www.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/27991/versions/2/download/zip'
};
for i = 1:length(matDependencyNameList)
curLink = matDependencyUrlList{i};
curZip = fullfile(matDependencyPath,'x.zip');
websave(curZip,curLink,weboptions('timeout',15));
[~,b,~] = fileparts(matDependencyNameList{i});
curFolder = fullfile(matDependencyPath,b);
unzip(curZip,curFolder)
delete(curZip)
addpath(genpath(curFolder))
end
% Github repositories (make sure git is installed and available in your system path: https://git-scm.com/downloads)
gitDependencyPath = fullfile(p.wd,'..');
% libsvm
curRepo = 'libsvm';
curRepoURL = 'https://github.com/cjlin1/libsvm.git';
curRepoPath = fullfile(gitDependencyPath,curRepo);
disp(curRepoURL)
if exist(fullfile(curRepoPath,'.git'),'dir'); disp(['already in ' curRepoPath]); else, eval(['!git clone ' curRepoURL ' ' curRepoPath]); end
if ispc; addpath(genpath(fullfile(curRepoPath,'windows'))); else, error('you need to fix paths to libsvm githu repo for non-windows machines'); end
% shadedErrorBar
curRepo = 'shadedErrorBar';
curRepoURL = 'https://github.com/raacampbell/shadedErrorBar.git';
curRepoPath = fullfile(gitDependencyPath,curRepo);
disp(curRepoURL)
if exist(fullfile(curRepoPath,'.git'),'dir'); disp(['already in ' curRepoPath]); else, eval(['!git clone ' curRepoURL ' ' curRepoPath]); end
addpath(genpath(curRepoPath));
%% Parameters for feature selection
% Within visual field region of the stimulus
p.featSel.fov.doIt = 1;
p.featSel.fov.threshMethod = 'empirical'; % 'empirical' 'ecc'
p.featSel.fov.areaLabel = 'v1';
p.featSel.fov.threshVal = [0.75 7]; % threshMethod='ecc'
p.featSel.fov.percentile = 20; % threshMethod='ecc'
% Activated voxels (random-effect)
p.featSel.respVecSig.doIt = 1;
p.featSel.respVecSig.threshMethod = 'p'; % '%ile' 'p' 'fdr'
p.featSel.respVecSig.threshVal = 0.05; % threshMethod='p' or 'fdr'
p.featSel.respVecSig.percentile = 20; % threshMethod='%ile'
% Less likely-to-be-vein voxels
p.featSel.vein.doIt = 1;
p.featSel.vein.threshMethod = '%ile'; % '%ile'
p.featSel.vein.threshVal = 0.01; % not used
p.featSel.vein.percentile = 20; % threshMethod='%ile'
% Most discriminant voxels
p.featSel.respVecDiff.doIt = 1;
p.featSel.respVecDiff.threshMethod = '%ile'; % '%ile' 'p' 'fdr'
p.featSel.respVecDiff.threshVal = 0.5; % threshMethod='p' or 'fdr'
p.featSel.respVecDiff.percentile = 20; % threshMethod='%ile'
% Feature Combination
p.featSel.global.doIt = 1;
p.featSel.global.method = 'allData';
% 'allData'-> featSel uses all three conditions, irrespective of the condition pairs to be decoded
% 'custom1'-> featSel of active voxels uses all three conditions but featSel of discriminant voxels uses only the conditions to be decoded
% 'custom2'-> featSel of active and most discriminant voxels uses only the conditions to be decoded
%% SVM parameters
p.svm.kernel.type = 'lin';
p.svm.complexSpace = 'bouboulisDeg1'; % 'bouboulisDeg1' 'bouboulisDeg2'
p.svm.doWithin = 0;
p.svm.condPairList = {'grat1VSgrat2' 'grat1VSplaid' 'grat2VSplaid'};
p.svm.respFeatList = {'delay' 'cartNoDelay' 'cart'};
%% Meta data
p.meta.subjList = {'02jp' '03sk' '04sp' '05bm' '06sb' '07bj'}';
%% Paths
p.figOption.outDir = fullfile(p.wd,'figures',p.anaID); if ~exist(p.figOption.outDir,'dir'); mkdir(p.figOption.outDir); end
p.termOption.outDir = fullfile(p.wd,'terminalOutputs',p.anaID); if ~exist(p.termOption.outDir,'dir'); mkdir(p.termOption.outDir); end
p.dataPath.V1 = fullfile(p.wd,'data','V1');
%% Logging
diaryON(p)
%% Parameters for single-subject example
p.figOption.subjInd = 2;
p.figOption.sessInd = 1;
p.figOption.condInd = 1;
p.figOption.sliceInd = 7;
%% Permutations
p.perm.doIt = 1;
p.perm.n = 2^13;
%% Bootstrapping
p.boot.n = 2^13;