|
| 1 | +function outputFiltered = readOutputFilter(cfg, filterHeader, filterContent) |
| 2 | + % outputFiltered = readOutputFilter(cfg, filterHeader, filterContent) |
| 3 | + % |
| 4 | + % It will display in the command window the content of the `output.tsv' filtered by one element |
| 5 | + % of a target column. At the moment it works only for string content and can retrieve the tsv |
| 6 | + % path form `cfg`. |
| 7 | + % |
| 8 | + % DEPENDENCIES: |
| 9 | + % - bids_matlab (from CPP_BIDS) |
| 10 | + % |
| 11 | + % INPUT: |
| 12 | + % |
| 13 | + % - cfg: the main experiment structure |
| 14 | + % - filterHeader: string, the column header where the ctarget content is stored (e.g., for |
| 15 | + % 'condition name' will be 'trial type') |
| 16 | + % - filterContent: string, the content of the column you want to filter out. It can take just |
| 17 | + % part of the content name (e.g., you want to display the triggers and you have 'trigger_motion' |
| 18 | + % and 'trigger_static', 'trigger' as input will do) |
| 19 | + |
| 20 | + % Get the outputfile path |
| 21 | + tsvFile = fullfile(cfg.dir.outputSubject, ... |
| 22 | + cfg.fileName.modality, ... |
| 23 | + cfg.fileName.events); |
| 24 | + |
| 25 | + % Read the the tsv file and store each column in a field of `output` structure |
| 26 | + output = bids.util.tsvread(tsvFile); |
| 27 | + |
| 28 | + % Get the index of the target contentent to filter and display |
| 29 | + filterIdx = find(strncmp(output.(filterHeader), filterContent, length(filterContent))); |
| 30 | + |
| 31 | + % Convert the structure to dataset |
| 32 | + outputDataset = struct2dataset(output); |
| 33 | + |
| 34 | + % Get the dataset with the content of intereset |
| 35 | + outputFiltered = outputDataset(filterIdx,:); |
| 36 | + |
| 37 | +end |
| 38 | + |
0 commit comments