-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadMeta.m
More file actions
32 lines (25 loc) · 997 Bytes
/
ReadMeta.m
File metadata and controls
32 lines (25 loc) · 997 Bytes
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
%% From ReadSGLXData - SpikeGLX
function [meta] = ReadMeta(binName, path)
% Create the matching metafile name
[dumPath,name,dumExt] = fileparts(binName);
metaName = strcat(name, '.meta');
% Parse ini file into cell entries C{1}{i} = C{2}{i}
fid = fopen(fullfile(path, metaName), 'r');
% -------------------------------------------------------------
% Need 'BufSize' adjustment for MATLAB earlier than 2014
% C = textscan(fid, '%[^=] = %[^\r\n]', 'BufSize', 32768);
C = textscan(fid, '%[^=] = %[^\r\n]');
% -------------------------------------------------------------
fclose(fid);
% New empty struct
meta = struct();
% Convert each cell entry into a struct entry
for i = 1:length(C{1})
tag = C{1}{i};
if tag(1) == '~'
% remake tag excluding first character
tag = sprintf('%s', tag(2:end));
end
meta = setfield(meta, tag, C{2}{i});
end
end % ReadMeta