-
Notifications
You must be signed in to change notification settings - Fork 6
/
doWAV.m
executable file
·71 lines (54 loc) · 2.69 KB
/
doWAV.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
function WAV = doWAV(inputData,markers,baselineWindow,minimumFrequency,maximumFrequency,frequencySteps,mortletParameter)
% written as a shell by Olav Krigolson
% runs FFT analysis byu conditions on EEG data structure
disp('Starting Wavelet analysis...');
if ~isempty(baselineWindow)
x = find(inputData.times >= baselineWindow(1));
y = find(inputData.times >= baselineWindow(2));
baselinePoints(1) = x(1);
baselinePoints(2) = y(1);
end
numberOfConditions = size(markers,2);
numberOfEpochs = size(inputData.data,3);
for conditionCounter = 1:numberOfConditions
tempData = [];
tempDataCounter = 1;
for epochCounter = 1:numberOfEpochs
if strcmp(markers(conditionCounter),inputData.epoch(epochCounter).eventtype)
tempData(:,:,tempDataCounter) = inputData.data(:,:,epochCounter);
tempDataCounter = tempDataCounter + 1;
end
end
if ~isempty(baselineWindow)
[waveletData,waveletDataPercent,WAVFrequencies] = doWavelet(tempData,inputData.times,baselinePoints,minimumFrequency,maximumFrequency,frequencySteps,mortletParameter,inputData.srate);
else
if isempty(tempData)
waveletData = NaN(size(inputData.data,1),frequencySteps,size(inputData.data,2));
waveletDataPercent = NaN(size(inputData.data,1),frequencySteps,size(inputData.data,2));
WAVFrequencies = linspace(minimumFrequency,maximumFrequency,frequencySteps);
else
ERP.data(:,:,conditionCounter) = nanmean(tempData,3);
[waveletData,waveletDataPercent,WAVFrequencies] = doWavelet(tempData,inputData.times,[],minimumFrequency,maximumFrequency,frequencySteps,mortletParameter,inputData.srate);
end
end
WAV.data(:,:,:,conditionCounter) = waveletData;
WAV.percent(:,:,:,conditionCounter) = waveletDataPercent;
WAV.epochCount(conditionCounter) = tempDataCounter - 1;
end
WAV.frequencies = WAVFrequencies;
WAV.totalEpochs = numberOfEpochs;
WAV.chanlocs = inputData.chanlocs;
WAV.srate = inputData.srate;
WAV.epochTime(1) = inputData.xmin;
WAV.epochTime(2) = inputData.xmax;
WAV.times = inputData.times;
if ~isempty(baselineWindow)
WAV.baseline = baselineWindow;
else
WAV.baseline = [];
end
WAV.frequencyRange = [minimumFrequency maximumFrequency];
WAV.frequencySteps = frequencySteps;
WAV.mortletParameter = mortletParameter;
disp('Wavelets have now been created...');
end