-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathf_interpolate.m
More file actions
36 lines (29 loc) · 1.02 KB
/
f_interpolate.m
File metadata and controls
36 lines (29 loc) · 1.02 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
function [EEGout, lst_changes] = f_interpolate(EEGin, channel_types)
% EEG.chanlocs.description has been set to 'Noisy' for noisy channels in
% step 'Reject channels'
v_noiseChans = [];
for i_type = 1:numel(channel_types)
v_noiseChans = [v_noiseChans, ...
find(strcmp({EEGin.chanlocs.description}, channel_types(i_type)))];
end
if isempty(v_noiseChans)
EEGout = EEGin;
lst_changes = 'EEG = pop_interp(EE, "none required")';
return
end
% Check for correct indexing
for s_chan = 1 : numel(v_noiseChans)
if any(EEGin.data(v_noiseChans(s_chan)) ~= 0)
error('You were about to interpolate a non_empty channel')
% Noisy channels should be:
% 1. EEG.chanlocs.description = 'Noisy'
% 2. EEG.data = zeros
end
end
[EEGout] = pop_interp(EEGin, v_noiseChans, 'spherical');
lst_changes = strcat("EEG = pop_interp(EEG, [", ...
num2str(v_noiseChans), "], 'spherical'");
for s_chan = 1 : numel(v_noiseChans)
EEGout.chanlocs(v_noiseChans(s_chan)).description = 'Interpolated';
end
end