-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfindBadChannels.m
187 lines (158 loc) · 4.64 KB
/
findBadChannels.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
% filename1 = 'datasets.csv';
% % Read the CSV as a table
% t2 = readtable(filename1);
% % Add a new column to the end of the table
% numOfColumn = size(t, 2);
% newCol = repmat({'None'}, size(t,1), 1); %num2str(NaN(1, size(t,1)))'; % Your new column
% t.(numOfColumn) = newCol;
% % Change column name if needed
% t.Properties.VariableNames{numOfColumn} = 'deadChan';
% % Write to CSV file
% writetable(t, filename1)
%
% %%
%
% filename1 = 'datasets.csv';
% % Read the CSV as a table
% t = readtable(filename1);
% % Add a new column to the end of the table
% numOfColumn = size(t, 2);
% newCol = NaN(1, size(t,1))'; % Your new column
% t.(numOfColumn+1) = newCol;
% % Change column name if needed
% t.Properties.VariableNames{numOfColumn+1} = 'deadChan';
% % Write to CSV file
% writetable(t, filename1)
%%
% filename1 = 'datasets.csv';
% % Read the CSV as a table
% t2 = readtable(filename1);
% % Add a new column to the end of the table
% numOfColumn = size(t, 2);
% newCol = repmat({'None'}, size(t,1), 1); %num2str(NaN(1, size(t,1)))'; % Your new column
% t.(numOfColumn) = newCol;
% % Change column name if needed
% t.Properties.VariableNames{numOfColumn} = 'deadChan';
% % Write to CSV file
% writetable(t, filename1)
%
% %%
%
% filename1 = 'datasets.csv';
% % Read the CSV as a table
% t = readtable(filename1);
% % Add a new column to the end of the table
% numOfColumn = size(t, 2);
% newCol = NaN(1, size(t,1))'; % Your new column
% t.(numOfColumn+1) = newCol;
% % Change column name if needed
% t.Properties.VariableNames{numOfColumn+1} = 'deadChan';
% % Write to CSV file
%%
writetable(t, filename1)
%% Add Channels to existing based on bandpower
startOver = false;
filename1 = 'C:\Users\Gabe\Documents\MitchellLab\datasets.csv';
%filename1 = 'C:\Users\Gabe\Documents\MitchellLab\V1FreeViewingCode\Data\datasets.csv';
t = readtable(filename1);
numSess = size(t,1);
% left off at 36
for i = [28 32 37 38 45 46]%[30 33:36 39:42 44 47:48 50:51] %numSess
disp('session: ')
disp(i)
csd.visualizeLayers(i)
%[Exp, ~, lfp] = io.dataFactoryGratingSubspace(i);
%p = csd.getLFPPower(lfp, [0 450], 'exclude', ~startOver, 'inds', [117000 118000]);
x = 1;
badChan = [];
while ~isempty(x)
prompt = 'Which values should you add? ';
x = input(prompt);
if ~isempty(x)
badChan = [badChan x];
end
end
badChan
if isempty(badChan)
%t(i, 29) = t(i, 29);
else
t(i, 29) = {num2str(sort(unique([str2num(t{i, 29}{:}) badChan])))};
end
end
%% Find bad channels and add them to CSV file
filename1 = 'datasets.csv';
t = readtable(filename1);
numSess = size(t,1);
startOver = true;
for i = [28]% 32 37 38 45 46 49 52 53] %numSess
disp('session: ')
disp(i)
[Exp, ~, lfp] = io.dataFactoryGratingSubspace(i);
p = csd.getLFPPower(lfp, [0 450], 'exclude', ~startOver, 'inds', [117000 118000]);
badChan = find(p < 0.2);
badChan
csd.plotLFP(lfp, [117000 118000], badChan)
x = 1;
if startOver == false
badChan = [];
end
while ~isempty(x)
if startOver
prompt = 'Which values should you delete? ';
x = input(prompt);
if x == 100
badChan = [];
break
end
if ~isempty(x)
badChan(badChan==x) = [];
end
elseif startOver == false
prompt = 'Which values should you add? ';
x = input(prompt);
if ~isempty(x)
badChan = [badChan x];
end
end
end
badChan
if startOver
if isempty(badChan)
t(i, 29) = {'[]'};
else
t(i, 29) = {num2str(badChan)};
end
elseif startOver == false
if isempty(badChan)
%t(i, 29) = t(i, 29);
else
t(i, 29) = {num2str(sort(unique([str2num(t{i, 29}{:}) badChan])))};
end
end
end
%% Find bad channels and add them to CSV file
if ~exist('t')
filename1 = 'datasets.csv';
t = readtable(filename1);
end
numSess = size(t,1);
startOver = true;
for i = [ 52 53] %numSess
disp('session: ')
disp(i)
[Exp, ~, lfp] = io.dataFactoryGratingSubspace(i);
p = csd.getLFPPower(lfp, [0 450], 'exclude', ~startOver, 'inds', [117000 118000]);
badChan = [];
badChan
csd.plotLFP(lfp, [117000 118000], badChan)
x = 1;
while ~isempty(x)
prompt = 'Which values should you add? ';
x = input(prompt);
if ~isempty(x)
badChan = [badChan x];
end
end
badChan
t(i, 29) = {num2str(sort(unique([str2num(t{i, 29}{:}) badChan])))};
end