-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfindData.m
More file actions
43 lines (39 loc) · 1.78 KB
/
findData.m
File metadata and controls
43 lines (39 loc) · 1.78 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
function findData(obj)
% Actually find the data within the binary file
fseek(obj.fid, obj.headerEnd, 'bof');
switch obj.metaTags.FileTypeID
case 'NEURALSG'
obj.dataStart = obj.headerEnd;
obj.dataEnd = obj.fileEnd;
obj.datapoints = (obj.dataEnd - obj.dataStart)/(obj.channels * 2);
case {'NEURALCD','BRSMPGRP'}
segmentCount = 0;
while double(ftell(obj.fid)) < obj.fileEnd
if fread(obj.fid, 1, 'uint8') ~= 1
% Blackrock need to fix this in the original
% NPMK/data structure...
disp([9 'Duration read issue after segment ' num2str(segmentCount) ', calculating full data points'])
disp([9 9 'Position was ' num2str(double(ftell(obj.fid)))])
disp([9 9 'End of file was ' num2str(obj.fileEnd)])
obj.datapoints = double(obj.fileEnd - obj.dataStart)/(obj.channels * 2);
break;
end
segmentCount = segmentCount + 1;
if strcmp(obj.metaTags.FileTypeID, 'BRSMPGRP')
startTimeStamp = fread(obj.fid, 1, 'uint64');
else
startTimeStamp = fread(obj.fid, 1, 'uint32');
end
obj.metaTags.Timestamp(segmentCount) = startTimeStamp;
obj.datapoints(segmentCount) = fread(obj.fid, 1, 'uint32');
obj.dataStart(segmentCount) = double(ftell(obj.fid));
fseek(obj.fid, obj.datapoints(segmentCount) * obj.channels * 2, 'cof');
obj.dataEnd(segmentCount) = double(ftell(obj.fid));
end
otherwise
error(['Don''t even know how you got here, but not sure what this file type is: ' obj.metaTags.FileTypeID])
end
obj.duration = obj.datapoints/obj.Fs;
if length(obj.datapoints) > 1
obj.isPaused = true;
end