klabhub / neurostim

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

Timed end #197

Closed bartkrekelberg closed 2 years ago

bartkrekelberg commented 2 years ago

On the current master calling endExperiment (or error('STOPEXPERIMENT') will process afterTrial () but not afterBlock(). In this PR, afterBlock is processed too. This, for instance, allows afterBlock messages to be shown.

The downside is that the afterBlock code in plugins will now be run whereas it wasn't before. For some errors, this could cause a problem, (but so could afterTrial code...)

The underlying issue is that endExperiment can be used to force a stop (i.e. on error); then a quick exit is probably what is needed, Or it can be used to gracefully end the experiment while still finalizing the current trial and block.

Ideally, there would be two separate functions for this, but in the current setup of blocks/trials/designs that is not trivial.

Hence this simple solution to always process afterTrial and afterBlock.