klabhub / neurostim

Design and run visual neuroscience experiments using Matlab and the Psychophysics Toolbox.
MIT License
5 stars 4 forks source link

Bug fix for rsvp logging (breaking change) #221

Open adammorrissirrommada opened 2 months ago

adammorrissirrommada commented 2 months ago

Fixes multiple bugs with the logging of rsvp stimulus onsets, i.e. addRSVP(...,'log',true)

  1. a fatal error because startIsiFrame does not exist (a relic of some previous version of this code)
  2. with that fixed, rsvpISI value was being logged every frame because neurostim.parameter checks for a value change only for numeric and string types, not for logical. I have fixed this logical logging problem in a separate pull request because I am not sure whether perhaps it was intentional that logicals would always be logged. Fixed here in a different way by making rsvpISI an integer, initialised with -1 and then values of 0 and 1.
  3. Related to above, the original logical value was initialised to false, so the onset of the first rsvp frame was not logged. This was probably intentional because it is already logged as startTime, but maybe there is value in being able to use rsvpISI alone to get all the on and off times? if you disagree, initialising rsvpIsi to 0 should restore the previous behaviour. Happy to do that if it is preferred.

This is a potentially breaking change for analysis code that uses rsvpISI (because values are now 0 and 1 rather than false and true), but given there has been a fatal bug since 2021, I am guessing not many people have used this in their experiment or analysis.

adammorrissirrommada commented 2 months ago

btw, I wish we had unit tests for neurostim!

adammorrissirrommada commented 2 months ago

My current fix is bad because it goes into some logging logic every frame. will push another commit to fix.