cpp-lln-lab / CPP_BIDS

a set of matlab / octave function to create BIDS comptible folder structure and filenames
https://cpp-bids.readthedocs.io/en/dev/index.html
MIT License
1 stars 9 forks source link

suppress warnings when verbose==0 #150

Closed TomasLenc closed 3 years ago

TomasLenc commented 3 years ago

Often, events are saved one-by-one during acquisition. This produces lots of warnings because all the events before the one current one are empty in the logFile. One would expect that these warnings can be suppressed by setting cfg.verbose to 0. Simply adding this condition to the saveEventsFile does the job.

codecov[bot] commented 3 years ago

Codecov Report

Merging #150 (bddedd2) into dev (abbfc2d) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##              dev     #150   +/-   ##
=======================================
  Coverage   79.90%   79.90%           
=======================================
  Files          30       30           
  Lines         652      652           
=======================================
  Hits          521      521           
  Misses        131      131           
Flag Coverage Δ
unittests 79.90% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/saveEventsFile.m 86.57% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update dfa4bc8...bddedd2. Read the comment docs.

marcobarilari commented 3 years ago

Hey Tomas,

not sure I understand the situation you are describing. Do you have an example?

Your edits regard the extra columns so I guess that sometimes have not any entry for the extra column and so you receive a warning.

Is it correct?

If so, from your edits you will not receive any warning and that 'row' will not be printed on the command window but it will be printed in the tsv file.

Is it correct?

TomasLenc commented 3 years ago

Hey Tomas,

not sure I understand the situation you are describing. Do you have an example?

Your edits regard the extra columns so I guess that sometimes have not any entry for the extra column and so you receive a warning.

Is it correct?

If so, from your edits you will not receive any warning and that 'row' will not be printed on the command window but it will be printed in the tsv file.

Is it correct?

Hi Marco, In fact, this has nothing to do with extra columns. Just run this simple script using CPP_BIDS at the current dev branch and see the warnings yourself:

cfg = []; 

cfg.testingDevice = 'eeg'; 
cfg.task.name =  'someTask';    
cfg.dir.output = 'output'; 
cfg.subject.askGrpSess = [0 0]; 
cfg.subject.subjectGrp = ''; 
cfg.subject.subjectNb = 999; 
cfg.subject.sessionNb = 1; 
cfg.subject.runNb = 1; 

% setting this to 0, so I don't want to hear anything from CPP_BIDS
cfg.verbose = 0; 

cfg = checkCFG(cfg); 
cfg = createFilename(cfg);

%% 

logFile = []; 
logFile = saveEventsFile('init',cfg,logFile); 

% change info about trial_type
logFile.columns.trial_type.Levels = containers.Map({'listen','tap'}, ...
                                                   {'listen without movement', ...
                                                    'tap finger with the pulse'});

% open tsv and write json for events
logFile = saveEventsFile('open',cfg,logFile); 

%%

% let's run experiment with 10 trials, and save log for each trial after we
% execute it

nTrials = 10; 

for iTrial=1:nTrials

    logFile(iTrial,1).onset = rand(1); 
    logFile(iTrial,1).duration = rand(1);  
    logFile(iTrial,1).trial_type = 'dummy'; 

    logFile = saveEventsFile('save', cfg, logFile);

end

logFile = saveEventsFile('close', cfg, logFile); 

My edits suppress this when you select cfg.verbose=0.

This may perhaps be a nice thing to do, considering we have 3 levels of verbose. In other words cfg.verbose=0 could mean "I don't want to hear anything from CPP_BIDS", cfg.verbose=1 could mean "I want to get my warnings", cfg.verbose=2 could mean "tell me everything".

marcobarilari commented 3 years ago

Thanks! I will have a look.