Menu

[09bd5b]: / matlab / read_raw.m  Maximize  Restore  History

Download this file

47 lines (39 with data), 1.3 kB

 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
function [data, times, markers] = read_raw(filename);
% read_raw(filename)
% filename - string giving name of input file
%
% NOTE:
% *
%
% Input file-format (binary):
% (each segment in the table is a 64 bits double):
% 1) number of channels
% 2) number of trials
% 3) number of samples per trial segment
% 4) number of markers per trial
% 5) n-doubles giving the times-array (for each sample from 1...n this array
% gives the corresponding time in ms)
% 6) num_markers*num_trials-doubles giving markers in sampling-point
% units [1,...,n]
% 7) raw EEG-data in the format of:
% - channels x trial x samples
% - i.e. first all trials of the first channel one after the other, than
% the 2nd and so on
fid = fopen(filename, 'rb');
nbchan = fread(fid, 1, 'double');
trials = fread(fid, 1, 'double');
pnts = fread(fid, 1, 'double');
num_markers= fread(fid, 1, 'double');
times = fread(fid, pnts, 'double');
times = reshape( times, size(times, 2), size(times, 1));
% markers
markers = fread(fid, num_markers*trials, 'double');
markers = reshape( markers, [num_markers, trials] );
% data
for c=1:nbchan
for t=1:trials
data(c,:,t) = fread(fid, pnts, 'double');
end;
end;
fclose(fid);
return;
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.