-
Notifications
You must be signed in to change notification settings - Fork 2
/
analyzePEERforFFT.m
90 lines (69 loc) · 2.37 KB
/
analyzePEERforFFT.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
clear all;
close all;
clc;
% analyze a single PEER subject and generates the average power for the
% recording for each channel
% VARIABLES
fileName = '002 Outdoor Post Ride 08-09-2019';
markers = {'N'};
% filter parameters
filterOrder = 2;
filterLow = 0.1; % always keep at 0.1
filterHigh = 30; % set to 15 for ERP analyses, set to 30 or higher for FFT
filterNotch = 60; % unless in Europe use 60
% artifact criteria
typeOfArtifactRejction = 'Difference'; % max - min difference
artifactCriteria = 60; % recommend maxmin of 75
individualChannelAveraging = 0; % set to one for individual channel averaging
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% COMMANDS
% load the data
EEG = doLoadPEER(fileName,markers);
% filter the data
EEG = doFilter(EEG,filterLow,filterHigh,filterOrder,filterNotch,EEG.srate);
% epoch data
[EEG] = doTemporalEpochs(EEG,1000,500);
% identify artifacts
EEG = doArtifactRejection(EEG,typeOfArtifactRejction,artifactCriteria);
% remove bad trials
EEG = doRemoveEpochs(EEG,EEG.artifactPresent,individualChannelAveraging);
% make FFTs
FFT = doFFT(EEG,{'1'});
% compute power in each band for each channel
powerDeltaAF7 = mean(FFT.data(1,1:3));
powerThetaAF7 = mean(FFT.data(1,4:7));
powerAlphaAF7 = mean(FFT.data(1,8:12));
powerBetaAF7 = mean(FFT.data(1,13:30));
powerDeltaAF8 = mean(FFT.data(2,1:3));
powerThetaAF8 = mean(FFT.data(2,4:7));
powerAlphaAF8 = mean(FFT.data(2,8:12));
powerBetaAF8 = mean(FFT.data(2,13:30));
powerDeltaTP9 = mean(FFT.data(3,1:3));
powerThetaTP9 = mean(FFT.data(3,4:7));
powerAlphaTP9 = mean(FFT.data(3,8:12));
powerBetaTP9 = mean(FFT.data(3,13:30));
powerDeltaTP10 = mean(FFT.data(4,1:3));
powerThetaTP10 = mean(FFT.data(4,4:7));
powerAlphaTP10 = mean(FFT.data(4,8:12));
powerBetaTP10 = mean(FFT.data(4,13:30));
% plot full power range for each channel
subplot(2,2,1);
bar(FFT.data(1,1:30));
ylabel('Power uV^2');
xlabel('Frequency (Hz)');
title('Channel AF7');
subplot(2,2,2);
bar(FFT.data(2,1:30));
ylabel('Power uV^2');
xlabel('Frequency (Hz)');
title('Channel AF8');
subplot(2,2,3);
bar(FFT.data(3,1:30));
ylabel('Power uV^2');
xlabel('Frequency (Hz)');
title('Channel TP9');
subplot(2,2,4);
bar(FFT.data(4,1:30));
ylabel('Power uV^2');
xlabel('Frequency (Hz)');
title('Channel TP10');