Skip to content

Commit

Permalink
IO: AnyWave events file .mrk: add duration
Browse files Browse the repository at this point in the history
  • Loading branch information
ftadel committed Nov 20, 2020
1 parent ee01151 commit 6edf843
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions toolbox/io/in_events_anywave.m
Expand Up @@ -57,7 +57,7 @@
% Converts text in the input cell array to numbers. Replaced non-numeric
% text with NaN.
rawData = dataArray{col};
for row=1:size(rawData, 1);
for row=1:size(rawData, 1)
% Create a regular expression to detect and remove non-numeric prefixes and
% suffixes.
regexstr = '(?<prefix>.*?)(?<numbers>([-]*(\d+[\,]*)+[\.]{0,1}\d*[eEdD]{0,1}[-+]*\d*[i]{0,1})|([-]*(\d+[\,]*)*[\.]{1,1}\d+[eEdD]{0,1}[-+]*\d*[i]{0,1}))(?<suffix>.*)';
Expand All @@ -67,7 +67,7 @@

% Detected commas in non-thousand locations.
invalidThousandsSeparator = false;
if any(numbers==',');
if any(numbers==',')
thousandsRegExp = '^\d+?(\,\d{3})*\.{0,1}\d*$';
if isempty(regexp(numbers, thousandsRegExp, 'once'));
numbers = NaN;
Expand Down Expand Up @@ -99,7 +99,7 @@
Label = rawCellColumns(:, 1);
frequencies = cell2mat(rawNumericColumns(:, 1));
times = cell2mat(rawNumericColumns(:, 2));
VarName13 = cell2mat(rawNumericColumns(:, 3));
duration = cell2mat(rawNumericColumns(:, 3));
Electrode_label = rawCellColumns(:, 2);
VarName15 = cell2mat(rawNumericColumns(:, 4));

Expand Down Expand Up @@ -134,7 +134,12 @@
% Add event structure
events(iEvt).label = uniqueLabels{i};
events(iEvt).epochs = ones(1,sum(iAssignmentOnUniqueLabels == i));
events(iEvt).times = times(iAssignmentOnUniqueLabels == i)';
% Extended events
if all(duration(iAssignmentOnUniqueLabels == i) == 0)
events(iEvt).times = times(iAssignmentOnUniqueLabels == i)';
else
events(iEvt).times = [times(iAssignmentOnUniqueLabels == i)'; duration(iAssignmentOnUniqueLabels == i)'];
end
events(iEvt).reactTimes = [];
events(iEvt).select = 1;
events(iEvt).color = rand(1,3);
Expand Down

0 comments on commit 6edf843

Please sign in to comment.