@@ -51,17 +51,21 @@ public unsafe override IObservable<NeuropixelsV2eBetaDataFrame> Generate()
5151 return DeviceManager . GetDevice ( DeviceName ) . SelectMany ( deviceInfo =>
5252 {
5353 var info = ( NeuropixelsV2eDeviceInfo ) deviceInfo ;
54- var metadata = ProbeIndex switch
54+ var ( metadata , gainCorrection ) = ProbeIndex switch
5555 {
56- NeuropixelsV2Probe . ProbeA => info . ProbeMetadataA ,
57- NeuropixelsV2Probe . ProbeB => info . ProbeMetadataB ,
56+ NeuropixelsV2Probe . ProbeA => ( info . ProbeMetadataA , info . GainCorrectionA ) ,
57+ NeuropixelsV2Probe . ProbeB => ( info . ProbeMetadataB , info . GainCorrectionB ) ,
5858 _ => throw new InvalidEnumArgumentException ( $ "Unexpected { nameof ( ProbeIndex ) } value: { ProbeIndex } ")
5959 } ;
6060
6161 if ( metadata . ProbeSerialNumber == null )
6262 {
6363 throw new InvalidOperationException ( $ "{ ProbeIndex } is not detected. Ensure that the flex connection is properly seated.") ;
6464 }
65+ else if ( gainCorrection == null )
66+ {
67+ throw new NullReferenceException ( $ "Gain correction value is null for { ProbeIndex } .") ;
68+ }
6569
6670 var device = info . GetDeviceContext ( typeof ( NeuropixelsV2eBeta ) ) ;
6771 var passthrough = device . GetPassthroughDeviceContext ( typeof ( DS90UB9x ) ) ;
@@ -70,13 +74,6 @@ public unsafe override IObservable<NeuropixelsV2eBetaDataFrame> Generate()
7074 . Where ( frame => NeuropixelsV2eBetaDataFrame . GetProbeIndex ( frame ) == ( int ) ProbeIndex ) ;
7175 var invertPolarity = info . InvertPolarity ;
7276
73- var gainCorrection = ProbeIndex switch
74- {
75- NeuropixelsV2Probe . ProbeA => ( double ) info . GainCorrectionA ,
76- NeuropixelsV2Probe . ProbeB => ( double ) info . GainCorrectionB ,
77- _ => throw new InvalidEnumArgumentException ( $ "Unexpected { nameof ( ProbeIndex ) } value: { ProbeIndex } ")
78- } ;
79-
8077 return Observable . Create < NeuropixelsV2eBetaDataFrame > ( observer =>
8178 {
8279 var sampleIndex = 0 ;
@@ -89,7 +86,7 @@ public unsafe override IObservable<NeuropixelsV2eBetaDataFrame> Generate()
8986 frame =>
9087 {
9188 var payload = ( NeuropixelsV2BetaPayload * ) frame . Data . ToPointer ( ) ;
92- NeuropixelsV2eBetaDataFrame . CopyAmplifierBuffer ( payload ->SuperFrame , amplifierBuffer , frameCounter , sampleIndex , gainCorrection , invertPolarity ) ;
89+ NeuropixelsV2eBetaDataFrame . CopyAmplifierBuffer ( payload ->SuperFrame , amplifierBuffer , frameCounter , sampleIndex , gainCorrection . Value , invertPolarity ) ;
9390 hubClockBuffer [ sampleIndex ] = payload ->HubClock ;
9491 clockBuffer [ sampleIndex ] = frame . Clock ;
9592 if ( ++ sampleIndex >= bufferSize )
0 commit comments