File size: 1,397 Bytes
03a0748
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
function blink_removal_only(startDir,blink_chans)
[paths names]=extsearchc(startDir,'.bdf');
prefix = 'EOG_removal_';

for u=1:length(paths)
    try
        EEG = pop_loadset('filename',['6_pre_comp_rej_' names{u}(1:end-4) '.set'],'filepath',[paths{u} filesep 'Intermediate']);
        
        for w=1:size(EEG.icaact,1)
            for v=1:length(blink_chans)
                x=zeros(1,length(blink_chans));
                if ~(max(EEG.data(blink_chans(v),:))==0 && min(EEG.data(blink_chans(v),:))==0);
                    f = corrcoef(EEG.icaact(w,:),EEG.data(blink_chans(v),:));
                    x(v) = abs(f(1,2));
                else
                    x(v) = 0;
                end
            end
            list_properties(w,1)=max(x);
        end

        [lengths] = min_z(list_properties);
        EEG = pop_subcomp(EEG, find(lengths >= 1), 0);
        EEG = eeg_checkset(EEG);

        lengths_ep=cell(1,size(EEG.data,3));
        for v=1:size(EEG.data,3)
            list_properties = single_epoch_channel_properties(EEG,v,64);
            lengths_ep{v}=find(min_z(list_properties));
        end

        EEG=h_epoch_interp_spl(EEG,lengths_ep,65:72);

        pop_saveset(EEG,'filename',[prefix names{u}(1:end-4) '.set'],'filepath',[paths{u}]);
    catch
        fprintf('\nSkipped file %s%s%s.\n\n',paths{u},filesep,names{u});
    end
end