-
Notifications
You must be signed in to change notification settings - Fork 2
/
gk_getTunedROIsDirect.m
executable file
·47 lines (41 loc) · 1.45 KB
/
gk_getTunedROIsDirect.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
function xpr = gk_getTunedROIsDirect(sig,iscell,stim,before,after,p_thr)
% USAGE: xpr = gk_getTunedROIsDirect(sig,iscell,stim,before,after,p_thr)
%
% Uses anova1 on the responses and if significant based on p_thr assigns
% the ROI as tuned
%
% INPUT:
% sig : loaded from SIG.npy (SIG: F, Fneu, spks)
% iscell: loaded from iscell.npy
% before: seconds before stim onset
% after: seconds after stim offset
% pthr: p-value to select ROIs as tuned
% Author: Georgios A. Keliris
sig = sig(logical(iscell(:,1)),:);
xpr = gk_getSigAllTrials(sig,stim,before,after);
xpr.cellIDs=find(iscell(:,1));
if isfield(xpr,'stimAngles')
nGrps=numel(unique(xpr.stimAngles));
else
nGrps=1;
end
for g=1:nGrps
for r=1:size(xpr.cellIDs,1)
roi=gk_getCellTrials(xpr,r);
grp=roi.responses(roi.responses.grpID==g,1:2);
pON(r,g)=anova1(grp.ONresp, grp.stimID,"off");
end
xpr.grp(g).pON=pON(:,g);
xpr.grp(g).isOnTuned=xpr.grp(g).pON<p_thr;
xpr.grp(g).onTunedIDs = find(xpr.grp(g).isOnTuned);
xpr.grp(g).pThr=p_thr;
[~, xpr.grp(g).sortedOnTunedIDs]= sort(xpr.grp(g).pON(xpr.grp(g).onTunedIDs));
end
xpr.pON=pON;
xpr.pONmin=min(pON,[],2);
xpr.pThr=p_thr;
xpr.isOnTuned_allGrp=xpr.pONmin<p_thr;
xpr.onTunedIDs_allGrp = find(xpr.isOnTuned_allGrp);
[~, xpr.sortedOnTunedIDs_allGrp]= sort(xpr.pONmin(xpr.onTunedIDs_allGrp));
xpr.tunedGlobalIDs=xpr.cellIDs(xpr.onTunedIDs_allGrp(xpr.sortedOnTunedIDs_allGrp));
end