-
Notifications
You must be signed in to change notification settings - Fork 0
/
processFov.m
85 lines (77 loc) · 3.02 KB
/
processFov.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
function processFov(p,doWhat)
disp('------------')
disp('processFov.m')
p.fov.eccLim = [0.75 7];
outFile = fullfile(p.dataPath.V1,'fov.mat');
switch doWhat
case {'run' 'run_forced'}
if ~exist(outFile,'file') || strcmp(doWhat,'run_forced')
[d,info] = loadData(p);
disp('empiricalFov: Computing')
[areaAndFov,cont,voxProp,pEmpirical,fAll,f] = empiricalFov(d,p);
disp('empiricalFov: Saving')
save(outFile,'areaAndFov','cont','voxProp','pEmpirical','fAll','f')
disp(['empiricalFov: Saved to: ' outFile])
else
disp('empiricalFov: loading data previously saved locally')
load(outFile)
end
case {'download' 'download_forced'}
if ~exist(outFile,'file') || strcmp(doWhat,'download_forced')
disp('empiricalFov: Downloading from repo')
curLink = 'https://zenodo.org/record/5192849/files/fov.mat?download=1';
websave(outFile,curLink);
disp(['empiricalFov: Downloaded to ' outFile])
disp('empiricalFov: Loading')
else
disp('empiricalFov: Loading data previously saved locally')
end
load(outFile)
disp('empiricalFov: Loaded')
end
%% Figures
% in main paper
figDir = fullfile(p.figOption.outDir); if ~exist(figDir,'dir'); mkdir(figDir); end
disp('empiricalFov: Saving figures')
figInd = 10;
f.L{p.figOption.subjInd,p.figOption.sessInd}(figInd).Visible = 'on';
f.R{p.figOption.subjInd,p.figOption.sessInd}(figInd).Visible = 'on';
figFile = 'Fig3Aleft';
saveas(f.L{p.figOption.subjInd,p.figOption.sessInd}(figInd),[fullfile(figDir,figFile) '.fig'])
saveas(f.L{p.figOption.subjInd,p.figOption.sessInd}(figInd),[fullfile(figDir,figFile) '.jpg'])
figFile = 'Fig3Aright';
saveas(f.R{p.figOption.subjInd,p.figOption.sessInd}(figInd),[fullfile(figDir,figFile) '.fig'])
saveas(f.R{p.figOption.subjInd,p.figOption.sessInd}(figInd),[fullfile(figDir,figFile) '.jpg'])
% in supplement
fAll{end}.Visible = 'on';
figFile = 'SuppFig1';
saveas(fAll{end},[fullfile(figDir,figFile) '.fig'])
saveas(fAll{end},[fullfile(figDir,figFile) '.jpg'])
disp(['empiricalFov: Saved to ' figDir])
disp(['empiricalFov: Cleaning up'])
close(findall(groot,'Type','figure','visible','off'))
disp(['empiricalFov: Done'])
function [d,info] = loadData(p)
dataIn = fullfile(p.dataPath.V1,'resp');
dAll = cell(length(p.meta.subjList),1);
for subjInd = 1:length(p.meta.subjList)
curFile = fullfile(dataIn,[p.meta.subjList{subjInd} '.mat']);
disp([p.meta.subjList{subjInd} ': loading responses']);
load(curFile,'resp');
dAll{subjInd} = resp;
end
disp('responses loaded')
d = dAll; clear dAll
sessList = fields(d{1});
dP = cell(size(d,2),length(sessList));
for subjInd = 1:length(d)
for sessInd = 1:length(sessList)
sess = ['sess' num2str(sessInd)];
dP{subjInd,sessInd} = d{subjInd}.(sessList{sessInd});
d{subjInd}.(sessList{sessInd}) = [];
end
end
d = dP; clear dP
info.info = 'subj x sess';
info.sessList = sessList';
info.subjList = p.meta.subjList;