|
14 | 14 | % :param columnName: the header of the column where the content of interest is stored
|
15 | 15 | % (for example for ``trigger`` will be ``trial type``)
|
16 | 16 | % :type columnName: string
|
| 17 | + % |
17 | 18 | % :param filterBy: the content of the column you want to filter out. It can take just
|
18 | 19 | % part of the content name (for example, if you want to display the triggers
|
19 | 20 | % and you have ``trigger_motion`` and ``trigger_static``,
|
20 | 21 | % ``trigger`` as input will do)
|
21 | 22 | % :type filterBy: string
|
| 23 | + % |
22 | 24 | % :param saveOutputTsv: flag to save the filtered output in a tsv file
|
23 | 25 | % :type saveOutputTsv: boolean
|
| 26 | + % |
24 | 27 | % :param tsvFile: TSV file to filter
|
25 | 28 | % :type tsvFile: string
|
| 29 | + % |
26 | 30 | % :param cfg: Configuration. See ``checkCFG()``. If ``cfg`` is given as input the name
|
27 | 31 | % of the TSV file to read will be infered from there.
|
28 | 32 | % :type cfg: structure
|
|
67 | 71 | output = bids.util.tsvread(tsvFile);
|
68 | 72 | end
|
69 | 73 |
|
70 |
| - % Get the index of the target contentent to filter and display |
| 74 | + % Get the index of the target content to filter and display |
71 | 75 | filterIdx = strncmp(output.(columnName), filterBy, length(filterBy));
|
72 | 76 |
|
73 | 77 | % apply the filter
|
|
76 | 80 | output.(listFields{iField})(~filterIdx) = [];
|
77 | 81 | end
|
78 | 82 |
|
79 |
| - output = convertStruct(output); |
80 |
| - |
81 | 83 | % Convert the structure to dataset
|
82 | 84 | try
|
83 | 85 | outputFiltered = struct2dataset(output);
|
|
93 | 95 | end
|
94 | 96 |
|
95 | 97 | end
|
96 |
| - |
97 |
| -function structure = convertStruct(structure) |
98 |
| - % changes the structure |
99 |
| - % |
100 |
| - % from struct.field(i,1) to struct(i,1).field(1) |
101 |
| - |
102 |
| - fieldsList = fieldnames(structure); |
103 |
| - tmp = struct(); |
104 |
| - |
105 |
| - for iField = 1:numel(fieldsList) |
106 |
| - for i = 1:numel(structure.(fieldsList{iField})) |
107 |
| - tmp(i, 1).(fieldsList{iField}) = structure.(fieldsList{iField})(i, 1); |
108 |
| - end |
109 |
| - end |
110 |
| - |
111 |
| - structure = tmp; |
112 |
| - |
113 |
| -end |
0 commit comments