Understanding acquisition timing
Posted: 16 Apr 2024, 01:04
I'm trying to figure out, as precisely as I can, when samples were acquired during an experiment. I've read up on the state variables SourceTime and StimulusTime, but when I look into these states in my recorded data I still have some questions.
In the past, I have simply constructed a timing vector spaced according to the ratio of SampleBlockSize to SamplingRate, i.e., assuming uniform spacing of samples. Indeed, that approach is recommended here (viewtopic.php?t=63&sid=4e0a1885e6fb172e2d0953f3e7c2e8db), as well as a related approach using regression (viewtopic.php?t=1278&sid=855f1dc1c85644 ... e5ee4c5eeb). What I am hoping to do right now is construct a more precise time-base, even if it is not uniformly spaced, but which accurately reflects when samples were acquired.
In an example file, I have SamplingRate of 2000 Hz, SampleBlockSize of 40, therefore the block duration is expected to be 20 ms. The data file is around 250s long, or about 12500 data blocks. The data blocks themselves almost universally consist of exactly 40 samples each (judging by the number of repetitions of the state variables like SourceTime in each block). Speaking of SourceTime: when I unwrap it, I see that most blocks of data have the expected duration. The second-most frequent phenomenon is that a block is 1 or 2 ms too long (or too short), but then the immediate subsequent data block "makes up" for this by compensating in the other direction. A third outcome is that the data block duration (according to SourceTime) is significantly longer than the expected 20ms, but only has the expected number of samples, and this is not compensated afterwards. In that case, I'm assuming data is lost. I'm willing to accept all of those scenarios without too much alarm.
The fourth scenario I'm seeing is that SourceTime reports a significantly *shorter* duration than expected, by as much as 10ms or more, but the *reported number of samples is still 40*. If that is what's actually happening, then the samplingRate is being violated somehow? This possibility was brought up in a prior thread (viewtopic.php?t=1349&sid=47daf3fe8cf1ea ... ed4dfdeded), but not explicitly addressed. It does say in that thread that "BCI2000 will never duplicate samples", which eliminates my first guess as to what's going on with the too-short data block times.
Can the samplingRate effectively (or literally) vary from one block to another? Or, am I expecting too much accuracy from the SoureTime state? Or is there some other explanation? I'd appreciate any insight you can share. My example data was recorded using the Blackrock signalSource module.
Thanks!
In the past, I have simply constructed a timing vector spaced according to the ratio of SampleBlockSize to SamplingRate, i.e., assuming uniform spacing of samples. Indeed, that approach is recommended here (viewtopic.php?t=63&sid=4e0a1885e6fb172e2d0953f3e7c2e8db), as well as a related approach using regression (viewtopic.php?t=1278&sid=855f1dc1c85644 ... e5ee4c5eeb). What I am hoping to do right now is construct a more precise time-base, even if it is not uniformly spaced, but which accurately reflects when samples were acquired.
In an example file, I have SamplingRate of 2000 Hz, SampleBlockSize of 40, therefore the block duration is expected to be 20 ms. The data file is around 250s long, or about 12500 data blocks. The data blocks themselves almost universally consist of exactly 40 samples each (judging by the number of repetitions of the state variables like SourceTime in each block). Speaking of SourceTime: when I unwrap it, I see that most blocks of data have the expected duration. The second-most frequent phenomenon is that a block is 1 or 2 ms too long (or too short), but then the immediate subsequent data block "makes up" for this by compensating in the other direction. A third outcome is that the data block duration (according to SourceTime) is significantly longer than the expected 20ms, but only has the expected number of samples, and this is not compensated afterwards. In that case, I'm assuming data is lost. I'm willing to accept all of those scenarios without too much alarm.
The fourth scenario I'm seeing is that SourceTime reports a significantly *shorter* duration than expected, by as much as 10ms or more, but the *reported number of samples is still 40*. If that is what's actually happening, then the samplingRate is being violated somehow? This possibility was brought up in a prior thread (viewtopic.php?t=1349&sid=47daf3fe8cf1ea ... ed4dfdeded), but not explicitly addressed. It does say in that thread that "BCI2000 will never duplicate samples", which eliminates my first guess as to what's going on with the too-short data block times.
Can the samplingRate effectively (or literally) vary from one block to another? Or, am I expecting too much accuracy from the SoureTime state? Or is there some other explanation? I'd appreciate any insight you can share. My example data was recorded using the Blackrock signalSource module.
Thanks!