forked from yuty2009/groupard-code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
readTestData1.m
43 lines (36 loc) · 1.16 KB
/
readTestData1.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
function [data target] = readTestData1(datafile, targetfile, hdfilter)
disp('Loading test dataset');
load(datafile);
fp = fopen(targetfile, 'rt');
line = fgetl(fp);
fclose(fp);
TargetChar = line;
% convert to double precision
Signal = double(Signal);
Flashing = double(Flashing);
StimulusCode = double(StimulusCode);
numTrials = size(Signal, 1);
numChars = 12;
numRepeats = 15;
numSamples = 240;
numChannels = size(Signal, 3);
Signal_filtered = zeros(size(Signal));
for i = 1:numTrials
Signal_trial = squeeze(Signal(i,:,:));
Signal_filtered(i,:,:) = reshape(filter(hdfilter, Signal_trial), 1, size(Signal_trial,1), size(Signal_trial,2));
end
data = cell(numTrials, 1);
target = zeros(numTrials, 1);
for i = 1:numTrials
repeat = zeros(1, numChars);
signalTrial = zeros(numChars, numRepeats, numSamples, numChannels);
for n = 2:size(Signal, 2)
if Flashing(i, n-1)==0 && Flashing(i, n)==1
event = StimulusCode(i, n);
repeat(event) = repeat(event) + 1;
signalTrial(event, repeat(event), :, :) = Signal_filtered(i, n:n+numSamples-1, :);
end
end
data{i} = signalTrial;
target(i) = TargetChar(i);
end