-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuse_grating_qc.m
136 lines (104 loc) · 3.55 KB
/
use_grating_qc.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
function out = use_grating_qc (savepath,add_info)
%Loading the datafile with the information for the gratings
% We only load the datafiles that are needed based on what the user
% selected
if add_info.settings.Gratings.OTest || add_info.settings.Gratings.RTest
File = load(findfile_app(add_info.stim_idx,savepath,'Data_circular'));
Data_circular = File.Data_circular;
clear File
nr_cells = length(Data_circular);
end
if add_info.settings.Gratings.QI || add_info.settings.Gratings.FI
File = load(findfile_app(add_info.stim_idx,savepath,'Grating_QC'));
Grating_QC = File.Grating_QC;
clear File
nr_cells = length(Grating_QC);
end
%We have a unknown number of true if statements (depending on the user
%input) so lets use the variable a to count how many of the if statements
%are true. We can also use a as variable to index into an array which keeps
%information about which cells pass which quality criteria, in the end we
%just need to multiply all possible conditions to see which cells pass all
%criteria the user has selected.
a = 0;
true_Gratings = false(nr_cells,1);
%% Quality index
if add_info.settings.Gratings.QI
a = a+1;
%Check which cells cross the threshold given by the user
true_Gratings(:,a) = [Grating_QC.QC_pass]>= add_info.settings.Gratings.QI_thr;
end
%% Frequency index
if add_info.settings.Gratings.FI
a = a+1;
true_Gratings(:,a) = [Grating_QC.freq_pass];
end
%% RTest
if add_info.settings.Gratings.RTest
a = a+1;
%Checking which cells have passed the quality criteria
true_Gratings(:,a) = [Data_circular.circ_rtest_sig] == 1;
end
% RTest Window
%
% if add_info.settings.Gratings.RTest_window
%
% %Coming soon
%
% % %Checking which cells have passed the quality criteria
% % true_Gratings = [Data_circular. ] == 1;
% % Gratings_nr = nnz(true_Gratings);
% % %Put the name of those cells into a cell array
% % if Gratings_nr ~= 0
% % RTest_name_str = cell(1,Gratings_nr);
% % for ii = 1:Gratings_nr
% % RTest_name_str{ii} = ['Cell_', num2str(Data_circular(true_Gratings(ii)).cell_idx)];
% % end
% % end
%
%
%
%
% end
%% OTest
if add_info.settings.Gratings.OTest
a = a+1;
%Checking which cells have passed the quality criteria
true_Gratings(:,a) = [Data_circular.circ_otest_sig] == 1;
end
% OTest window
%
% if add_info.settings.Gratings.RTest_window
%
% %Coming soon
%
% % %Checking which cells have passed the quality criteria
% % true_Gratings = [Data_circular. ] == 1;
% % Gratings_nr = nnz(true_Gratings);
% % %Put the name of those cells into a cell array
% % if Gratings_nr ~= 0
% % RTest_name_str = cell(1,Gratings_nr);
% % for ii = 1:Gratings_nr
% % RTest_name_str{ii} = ['Cell_', num2str(Data_circular(true_Gratings(ii)).cell_idx)];
% % end
% % end
%
%
%
%
% end
%% Summary
%Here we check which cells pass all tests and construct their name for the
%Items list
true_Gratings = all(true_Gratings,2);
if nnz(true_Gratings) == 0
out = {}; %returns empty list
else
cell_idxs = [Grating_QC.cell_idx];
cell_idxs = cell_idxs(1,true_Gratings);
out = cell(1,length(cell_idxs));
for ii = 1:length(cell_idxs)
out{1,ii} = strcat('Cell_',num2str(cell_idxs(1,ii)));
end
end
end