Skip to content

[FIX] fix tests on master branch #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 5 additions & 21 deletions src/readAndFilterLogfile.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@
% :param columnName: the header of the column where the content of interest is stored
% (for example for ``trigger`` will be ``trial type``)
% :type columnName: string
%
% :param filterBy: the content of the column you want to filter out. It can take just
% part of the content name (for example, if you want to display the triggers
% and you have ``trigger_motion`` and ``trigger_static``,
% ``trigger`` as input will do)
% :type filterBy: string
%
% :param saveOutputTsv: flag to save the filtered output in a tsv file
% :type saveOutputTsv: boolean
%
% :param tsvFile: TSV file to filter
% :type tsvFile: string
%
% :param cfg: Configuration. See ``checkCFG()``. If ``cfg`` is given as input the name
% of the TSV file to read will be infered from there.
% :type cfg: structure
Expand Down Expand Up @@ -67,7 +71,7 @@
output = bids.util.tsvread(tsvFile);
end

% Get the index of the target contentent to filter and display
% Get the index of the target content to filter and display
filterIdx = strncmp(output.(columnName), filterBy, length(filterBy));

% apply the filter
Expand All @@ -76,8 +80,6 @@
output.(listFields{iField})(~filterIdx) = [];
end

output = convertStruct(output);

% Convert the structure to dataset
try
outputFiltered = struct2dataset(output);
Expand All @@ -93,21 +95,3 @@
end

end

function structure = convertStruct(structure)
% changes the structure
%
% from struct.field(i,1) to struct(i,1).field(1)

fieldsList = fieldnames(structure);
tmp = struct();

for iField = 1:numel(fieldsList)
for i = 1:numel(structure.(fieldsList{iField}))
tmp(i, 1).(fieldsList{iField}) = structure.(fieldsList{iField})(i, 1);
end
end

structure = tmp;

end