cpp-lln-lab / CPP_PTB

a set of function to make it easier to create behavioral, EEG, fMRI experiment with psychtoolbox
https://cpp-ptb.readthedocs.io/en/latest/index.html#
MIT License
12 stars 13 forks source link

add readOuputFilter function #75

Closed marcobarilari closed 3 years ago

marcobarilari commented 3 years ago

The function now can retrieve the the file path only from cfg (have no idea how to use a switch when you input either a var or a string) and can filter only string elements (no numbers at the moment).

Despite it has some limits, I think it is already at a good stage that can serve our purpose (display the triggers events at the end of the experiment).

I will open an issue with the possible improvements.

this will resolve cpp-lln-lab/localizer_visual_motion#29

LM

Remi-Gau commented 3 years ago

have no idea how to use a switch when you input either a var or a string

from the top of my head I would do something like this.

if isstring(varargin{1})
   tsvFile = varargin{1}
elseif isstruct(varargin{1})
   tsvFile = fullfile(varargin{1}.dir.outputSubject, ...
        varargin{1}.fileName.modality, ...
        varargin{1}.fileName.events);
end
Remi-Gau commented 3 years ago

@marcobarilari

Actually, if you want to try writing a unit test, this function is perfect for it.

function test_suite = test_readOutputFilter %#ok<*STOUT>
    try % assignment of 'localfunctions' is necessary in Matlab >= 2016
        test_functions = localfunctions(); %#ok<*NASGU>
    catch % no problem; early Matlab versions can use initTestSuite fine
    end
    initTestSuite;
end

function test_readOutputFilterBasic()

    %% set up
   cfg = ... % fill in
   filterHeader = ... % fill in
   filterContent  = ... % fill in

   outputFiltered = readOutputFilter(cfg, filterHeader, filterContent)

   %% test data
   expectedOutput = ... % create a structure that describes what output you expect

    %% test
    assertEqual(expectedOutput, outputFiltered); % make sure they match

end
marcobarilari commented 3 years ago

I have addressed (attempt to) all the suggestions, thank :)

last commits will resolve #76