Commit ea6e484d authored by Bruno Colombet's avatar Bruno Colombet

added source file

parent 9297ae8f
Pipeline #2671 failed with stages
function infos = aw_read_ades(path)
%AW_READ_ADES read data from .ades file
% infos is a struct containing data and relative informations.
fid = fopen(path);
line = deblank(fgetl(fid));
if ~strcmpi(line, '#ADES HEADER FILE')
fclose(fid);
error('Invalid ADES header');
end
types = containers.Map;
channels = containers.Map;
electrodes = containers.List;
value = '';
while ~feof(fid)
line = fgetl(fid);
tokens = split(deblank(line), '=');
tokens = deblank(tokens);
key = tokens{1, 1};
if numel(tokens) == 2
value = tokens{2, 1};
end
if strcmpi(key, 'NUMBEROFSAMPLES') && ~isempty(value)
infos.n_samples = str2double(value);
elseif strcmpi(key, 'SAMPLINGRATE') && ~isempty(value)
infos.srate = str2double(value);
elseif strcmpi(key, 'UNIT') && ~isempty(value)
% get type
unit_tokens = deblank(split(value, ','));
if numel(unit_tokens) == 2
type = unit_tokens(1);
unit = unit_tokens(2);
types(type) = unit;
end
elseif strcmpi(key, 'DATE')
infos.date = value;
elseif strcmpi(key, 'TIME')
infos.time = value;
elseif strcmpi(key, 'LAYOUTS')
% do nothing, specific to C++ plugin
else % a channel
if isempty(value)
value = 'EEG';
end
channels(key) = value;
electrodes.append(key);
end
end
infos.labels = electrodes.values();
fclose(fid);
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment