-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_corr.m
More file actions
64 lines (53 loc) · 2.09 KB
/
Copy pathplot_corr.m
File metadata and controls
64 lines (53 loc) · 2.09 KB
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
function plot_corr(res, mod, modtype, split, func, corrVal, varargin)
%WARNING: THIS FUNCTION *DOES NOT* TAKE SPLIT INFORMATION INTO ACCOUNT - IS
%ONLY FOR THE "FAIR" FRAMEWORK. CHANGE ACCORDINGLY FOR OTHER FRAMEWORKS.
cfg = loadmat(res, fullfile(res.dir.frwork, 'cfg.mat'), 'cfg');
% Parse input and add default settings
res = res_defaults(res, modtype, varargin{:});
% Add SPM if needed
if strcmp(res.gen.selectfile, 'interactive') || strcmp(modtype, 'vbm')
set_path('spm');
end
%----- Get weight vectors
% Load weights
% weight = loadmat(res, fullfile(res.dir.res, 'model.mat'), ['w' mod]);
weight = load(fullfile(res.dir.res, 'corrCell.mat'));
if contains(modtype, 'behav')
weight = (weight.corrCell{1,2})';
else if contains(modtype, 'vbm')
weight = (weight.corrCell{1,1})';
end
end
% Compute strength by modifying weight by population mean data
if isfield(res.(modtype), 'weight') && isfield(res.(modtype).weight, 'type') ...
&& strcmp(res.(modtype).weight.type, 'strength')
data = load(res.data.(mod).fname); % load original data
weight = weight .* reshape(sign(nanmean(data.(mod))), [], 1);
end
weight(isnan(weight)) = 0;
% Flip weights
if res.gen.weight.flip
weight = -weight;
end
if strcmp(modtype, 'behav') % workaround for reversed-scored questionnaires
labelfname = select_file(res, fullfile(res.dir.project, 'data'), ...
'Select delimited label file for behaviour...', 'any', res.behav.file.label);
T = readtable(labelfname);
if ismember('Flip', T.Properties.VariableNames)
weight(T.Flip==1) = -weight(T.Flip==1);
end
end
% Postprocess weights (sorting, filtering etc.)
if isfield(res.(modtype), 'weight')
[weight, iweight] = postproc_corr(res, weight, modtype, corrVal);
end
if contains(modtype, 'behav')
wfname = fullfile(res.dir.res, 'behav_corr');
func = str2func(['plot_weight_behav_horz']);
func(res, weight, iweight, wfname);
else if contains(modtype, 'vbm')
wfname = fullfile(res.dir.res, 'brain_corr');
func = str2func(['plot_weight_brain_cortex']);
func(res, weight, wfname);
end
end