@@ -30,14 +30,16 @@ Neuropixels2e::Neuropixels2e(std::string name, std::string hubName, const oni_de
3030 INeuropixel(NeuropixelsV2eValues::numberOfSettings, NeuropixelsV2eValues::numberOfShanks)
3131{
3232 probeSN.fill (0 );
33+ frameCount.fill (0 );
34+ sampleNumber.fill (0 );
3335
3436 for (int i = 0 ; i < NeuropixelsV2eValues::numberOfSettings; i++)
3537 {
3638 defineMetadata (settings[i].get (), NeuropixelsV2eValues::numberOfShanks);
3739 }
3840
39- for (int i = 0 ; i < numFrames ; i++)
40- eventCodes[i] = 0 ;
41+ for (int i = 0 ; i < NumberOfProbes ; i++)
42+ eventCodes[i]. fill ( 0 ) ;
4143}
4244
4345Neuropixels2e::~Neuropixels2e ()
@@ -491,8 +493,8 @@ uint64_t Neuropixels2e::getProbeSN(uint8_t probeSelect)
491493
492494void Neuropixels2e::startAcquisition ()
493495{
494- sampleNumber = 0 ;
495- frameCount = 0 ;
496+ frameCount. fill ( 0 ) ;
497+ sampleNumber. fill ( 0 ) ;
496498}
497499
498500void Neuropixels2e::stopAcquisition ()
@@ -531,8 +533,8 @@ void Neuropixels2e::processFrames()
531533 uint16_t probeIndex = *(dataPtr + 4 );
532534 uint16_t * amplifierData = dataPtr + 9 ;
533535
534- sampleNumbers[frameCount] = sampleNumber;
535- timestamps[frameCount] = deviceContext->convertTimestampToSeconds (frame->time );
536+ sampleNumbers[probeIndex][ frameCount[probeIndex]] = sampleNumber[probeIndex]++ ;
537+ timestamps[probeIndex][ frameCount[probeIndex] ] = deviceContext->convertTimestampToSeconds (frame->time );
536538
537539 for (int i = 0 ; i < FramesPerSuperFrame; i++)
538540 {
@@ -542,18 +544,17 @@ void Neuropixels2e::processFrames()
542544 {
543545 const size_t channelIndex = rawToChannel[j][i];
544546
545- samples[channelIndex * numFrames + frameCount] =
546- (float )(*(amplifierData + adcIndices[j] + adcDataOffset)) * gainCorrection[probeIndex];
547+ samples[probeIndex][ channelIndex * numFrames + frameCount[probeIndex] ] =
548+ (float )(*(amplifierData + adcIndices[j] + adcDataOffset)) * gainCorrection[probeIndex] + DataMidpoint ;
547549 }
548550 }
549551
550- frameCount++;
551- sampleNumber++;
552+ frameCount[probeIndex]++;
552553
553- if (frameCount >= numFrames)
554+ if (frameCount[probeIndex] >= numFrames)
554555 {
555- amplifierBuffer[probeIndex]->addToBuffer (samples.data (), sampleNumbers, timestamps, eventCodes, numFrames);
556- frameCount = 0 ;
556+ amplifierBuffer[probeIndex]->addToBuffer (samples[probeIndex] .data (), sampleNumbers[probeIndex]. data () , timestamps[probeIndex]. data () , eventCodes[probeIndex]. data () , numFrames);
557+ frameCount[probeIndex] = 0 ;
557558 }
558559
559560 oni_destroy_frame (frame);
0 commit comments