-
Notifications
You must be signed in to change notification settings - Fork 6
/
samplePreprocessingScriptForWaveletAnalysis.m
75 lines (63 loc) · 2.4 KB
/
samplePreprocessingScriptForWaveletAnalysis.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
clear all;
close all;
clc;
% load a data set for analysis into EEGLAB format
[EEG] = doLoadBVData('/Users/krigolson/Documents/GitHub/MATLAB-EEG-sampleData','Cognitive_Assessment_01.vhdr');
% rereference the data
[EEG] = doRereference(EEG,{'TP9','TP10'},{'ALL'});
filterParameters.low = 0.1;
filterParameters.high = 30;
filterParameters.notch = 60;
% filter the data, note the higher top end to get at high gamma range
[EEG] = doFilter(EEG,filterParameters);
% epoch the data
[EEG] = doSegmentData(EEG,{'S202','S203'},[-500 1000]);
% implement a baseline correction
[EEG] = doBaseline(EEG,[-200,0]);
% check for difference artifacts
[EEG] = doArtifactRejection(EEG,'Difference',150);
% remove artifact trials
[EEG] = doRemoveEpochs(EEG,EEG.artifact.badSegments,0);
% run the FFT transform on each condition
[WAV] = doWAV(EEG,{'S202','S203'},[-500 -300],1,30,120,7);
% plot the Wavelets for both conditions side by size for channel 52
condition1WaveletData = squeeze(WAV.data(52,:,:,1));
condition2WaveletData = squeeze(WAV.data(52,:,:,2));
condition1PercentData = squeeze(WAV.percent(52,:,:,1));
condition2PercentData = squeeze(WAV.percent(52,:,:,2));
subplot(2,2,1);
imagesc(condition1WaveletData);
title('Channel Pz: Condition One');
xlabel('Time (ms)');
ylabel('Frequency (Hz)');
set(gca,'YDir','normal');
xticklabels = EEG.times(1):100:EEG.times(end);
xticks = linspace(1,size(condition1WaveletData,2),numel(xticklabels));
set(gca,'XTick',xticks,'XTickLabel',xticklabels);
subplot(2,2,2);
imagesc(condition2WaveletData);
title('Channel Pz: Condition Two');
xlabel('Time (ms)');
set(gca,'YDir','normal');
ylabel('Frequency (Hz)');
xticklabels = EEG.times(1):100:EEG.times(end);
xticks = linspace(1,size(condition2WaveletData,2),numel(xticklabels));
set(gca,'XTick',xticks,'XTickLabel',xticklabels);
subplot(2,2,3);
imagesc(condition1PercentData);
title('Channel Pz: Condition One');
xlabel('Time (ms)');
ylabel('Frequency (Hz)');
set(gca,'YDir','normal');
xticklabels = EEG.times(1):100:EEG.times(end);
xticks = linspace(1,size(condition1WaveletData,2),numel(xticklabels));
set(gca,'XTick',xticks,'XTickLabel',xticklabels);
subplot(2,2,4);
imagesc(condition2PercentData);
title('Channel Pz: Condition Two');
xlabel('Time (ms)');
set(gca,'YDir','normal');
ylabel('Frequency (Hz)');
xticklabels = EEG.times(1):100:EEG.times(end);
xticks = linspace(1,size(condition2WaveletData,2),numel(xticklabels));
set(gca,'XTick',xticks,'XTickLabel',xticklabels);