diff --git a/src/readAndFilterLogfile.m b/src/readAndFilterLogfile.m index 52bd1f2..5162300 100644 --- a/src/readAndFilterLogfile.m +++ b/src/readAndFilterLogfile.m @@ -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 @@ -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 @@ -76,8 +80,6 @@ output.(listFields{iField})(~filterIdx) = []; end - output = convertStruct(output); - % Convert the structure to dataset try outputFiltered = struct2dataset(output); @@ -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