klabhub / neurostim

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

Bug in cic.report() for frame drops around behavioural state changes #146

Closed adammorrissirrommada closed 4 years ago

adammorrissirrommada commented 4 years ago

https://github.com/klabhub/neurostim-ptb/blob/6acd245f98ca15f2d6eb38317c06fa4536158422/%2Bneurostim/cic.m#L2364

When c.profile is true, this line causes a terminal error sometimes . But looking at the code, it seems like it would be incorrect even when it doesn't raise an error. The indexing suggests it expects that "ti" is a [c.totalNrTrials x 1] vector of frame drop times (one drop per trial), but it's not; it's a list of all drop times from get(), with a corresponding "tr" carrying the trial numbers.

When I began trying to fix it, I came to the conclusion that I actually don't know what this report plot should look like. The previous plot shows frame drops relative to the startTime of stimuli, which happen only once per trial, so there is only one "relativeTime" per frame drop per stimulus. But behavioural state changes can happen many times per trial, so every frame drop is some distance to all occurrences of a given state change. What was the intention here @ktechvision ?

bartkrekelberg commented 4 years ago

I just committed a change that should fix this. Indeed the code was weird and broken. The goal is to align framedrops to state transitions to see if they cause them. I now limit this to the first transition into each state.

Please have a look if this fixes your intermittent terminal errors..