Skip to content

Commit 0b1197a

Browse files
authored
Merge pull request #535 from open-ephys/issue-505
Allow NeuropixelsV2 headstages to run without any probes
2 parents 7fb9332 + 9c9c37e commit 0b1197a

8 files changed

+51
-22
lines changed

OpenEphys.Onix1/ConfigureNeuropixelsV2e.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,6 @@ public override IObservable<ContextTask> Process(IObservable<ContextTask> source
114114
var probeAMetadata = ReadProbeMetadata(serializer, NeuropixelsV2e.ProbeASelected);
115115
var probeBMetadata = ReadProbeMetadata(serializer, NeuropixelsV2e.ProbeBSelected);
116116

117-
if (probeAMetadata.ProbeSerialNumber == null && probeBMetadata.ProbeSerialNumber == null)
118-
{
119-
throw new InvalidOperationException("No probes were detected. Ensure that the " +
120-
"flex connection is properly seated.");
121-
}
122-
123117
// issue full reset to both probes
124118
ResetProbes(serializer, gpo10Config);
125119

@@ -177,7 +171,7 @@ public override IObservable<ContextTask> Process(IObservable<ContextTask> source
177171
// disconnect i2c bus from both probes to prevent digital interference during acquisition
178172
SelectProbe(serializer, NeuropixelsV2e.NoProbeSelected);
179173

180-
var deviceInfo = new NeuropixelsV2eDeviceInfo(context, DeviceType, deviceAddress, gainCorrectionA, gainCorrectionB, invertPolarity);
174+
var deviceInfo = new NeuropixelsV2eDeviceInfo(context, DeviceType, deviceAddress, gainCorrectionA, gainCorrectionB, invertPolarity, probeAMetadata, probeBMetadata);
181175
var shutdown = Disposable.Create(() =>
182176
{
183177
serializer.WriteByte((uint)DS90UB933SerializerI2CRegister.Gpio10, NeuropixelsV2e.DefaultGPO10Config);

OpenEphys.Onix1/ConfigureNeuropixelsV2eBeta.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,6 @@ public override IObservable<ContextTask> Process(IObservable<ContextTask> source
131131
var probeAMetadata = ReadProbeMetadata(serializer, ref gpo32Config, NeuropixelsV2eBeta.SelectProbeA);
132132
var probeBMetadata = ReadProbeMetadata(serializer, ref gpo32Config, NeuropixelsV2eBeta.SelectProbeB);
133133

134-
if (probeAMetadata.ProbeSerialNumber == null && probeBMetadata.ProbeSerialNumber == null)
135-
{
136-
throw new InvalidOperationException("No probes were detected. Ensure that the " +
137-
"flex connection is properly seated.");
138-
}
139-
140134
// REC_NRESET and NRESET go high on both probes to take the ASIC out of reset
141135
// TODO: not sure if REC_NRESET and NRESET are tied together on flex
142136
gpo10Config |= NeuropixelsV2eBeta.GPO10ResetMask | NeuropixelsV2eBeta.GPO10NResetMask;
@@ -217,7 +211,7 @@ public override IObservable<ContextTask> Process(IObservable<ContextTask> source
217211
// Still its good to get them roughly (i.e. within 10 PCLKs) started at the same time.
218212
SyncProbes(serializer, gpo10Config);
219213

220-
var deviceInfo = new NeuropixelsV2eDeviceInfo(context, DeviceType, deviceAddress, gainCorrectionA, gainCorrectionB, invertPolarity);
214+
var deviceInfo = new NeuropixelsV2eDeviceInfo(context, DeviceType, deviceAddress, gainCorrectionA, gainCorrectionB, invertPolarity, probeAMetadata, probeBMetadata);
221215
var shutdown = Disposable.Create(() =>
222216
{
223217
serializer.WriteByte((uint)DS90UB933SerializerI2CRegister.Gpio10, NeuropixelsV2eBeta.DefaultGPO10Config);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace OpenEphys.Onix1
2+
{
3+
interface INeuropixelsV2eMetadata
4+
{
5+
public string ProbePartNumber { get; }
6+
7+
public ulong? ProbeSerialNumber { get; }
8+
9+
public string FlexPartNumber { get; }
10+
11+
public string FlexVersion { get; }
12+
}
13+
}

OpenEphys.Onix1/NeuropixelsV2eBetaData.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ public unsafe override IObservable<NeuropixelsV2eBetaDataFrame> Generate()
5151
return DeviceManager.GetDevice(DeviceName).SelectMany(deviceInfo =>
5252
{
5353
var info = (NeuropixelsV2eDeviceInfo)deviceInfo;
54+
var metadata = ProbeIndex switch
55+
{
56+
NeuropixelsV2Probe.ProbeA => info.ProbeMetadataA,
57+
NeuropixelsV2Probe.ProbeB => info.ProbeMetadataB,
58+
_ => throw new InvalidEnumArgumentException($"Unexpected {nameof(ProbeIndex)} value: {ProbeIndex}")
59+
};
60+
61+
if (metadata.ProbeSerialNumber == null)
62+
{
63+
throw new InvalidOperationException($"{ProbeIndex} is not detected. Ensure that the flex connection is properly seated.");
64+
}
65+
5466
var device = info.GetDeviceContext(typeof(NeuropixelsV2eBeta));
5567
var passthrough = device.GetPassthroughDeviceContext(typeof(DS90UB9x));
5668
var probeData = device.Context
@@ -62,7 +74,7 @@ public unsafe override IObservable<NeuropixelsV2eBetaDataFrame> Generate()
6274
{
6375
NeuropixelsV2Probe.ProbeA => (double)info.GainCorrectionA,
6476
NeuropixelsV2Probe.ProbeB => (double)info.GainCorrectionB,
65-
_ => throw new ArgumentOutOfRangeException(nameof(ProbeIndex), $"Unexpected {nameof(ProbeIndex)} value: {ProbeIndex}"),
77+
_ => throw new InvalidEnumArgumentException($"Unexpected {nameof(ProbeIndex)} value: {ProbeIndex}")
6678
};
6779

6880
return Observable.Create<NeuropixelsV2eBetaDataFrame>(observer =>

OpenEphys.Onix1/NeuropixelsV2eBetaMetadata.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace OpenEphys.Onix1
44
{
5-
class NeuropixelsV2eBetaMetadata
5+
class NeuropixelsV2eBetaMetadata : INeuropixelsV2eMetadata
66
{
77
const uint OFFSET_FLEX_VERSION = 0x00;
88
const uint OFFSET_FLEX_REVISION = 0x01;
@@ -39,6 +39,5 @@ public NeuropixelsV2eBetaMetadata(I2CRegisterContext serializer)
3939
public string FlexPartNumber { get; }
4040

4141
public string FlexVersion { get; }
42-
4342
}
4443
}

OpenEphys.Onix1/NeuropixelsV2eData.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@ public unsafe override IObservable<NeuropixelsV2eDataFrame> Generate()
5555
return DeviceManager.GetDevice(DeviceName).SelectMany(deviceInfo =>
5656
{
5757
var info = (NeuropixelsV2eDeviceInfo)deviceInfo;
58+
var metadata = ProbeIndex switch
59+
{
60+
NeuropixelsV2Probe.ProbeA => info.ProbeMetadataA,
61+
NeuropixelsV2Probe.ProbeB => info.ProbeMetadataB,
62+
_ => throw new InvalidEnumArgumentException($"Unexpected {nameof(ProbeIndex)} value: {ProbeIndex}")
63+
};
64+
65+
if (metadata.ProbeSerialNumber == null)
66+
{
67+
throw new InvalidOperationException($"{ProbeIndex} is not detected. Ensure that the flex connection is properly seated.");
68+
}
69+
5870
var device = info.GetDeviceContext(typeof(NeuropixelsV2e));
5971
var passthrough = device.GetPassthroughDeviceContext(typeof(DS90UB9x));
6072
var probeData = device.Context
@@ -66,7 +78,7 @@ public unsafe override IObservable<NeuropixelsV2eDataFrame> Generate()
6678
{
6779
NeuropixelsV2Probe.ProbeA => (double)info.GainCorrectionA,
6880
NeuropixelsV2Probe.ProbeB => (double)info.GainCorrectionB,
69-
_ => throw new ArgumentOutOfRangeException(nameof(ProbeIndex), $"Unexpected {nameof(ProbeIndex)} value: {ProbeIndex}"),
81+
_ => throw new InvalidEnumArgumentException($"Unexpected {nameof(ProbeIndex)} value: {ProbeIndex}")
7082
};
7183

7284
return Observable.Create<NeuropixelsV2eDataFrame>(observer =>

OpenEphys.Onix1/NeuropixelsV2eDeviceInfo.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,24 @@ namespace OpenEphys.Onix1
44
{
55
class NeuropixelsV2eDeviceInfo : DeviceInfo
66
{
7-
public NeuropixelsV2eDeviceInfo(ContextTask context, Type deviceType, uint deviceAddress, double? gainCorrectionA, double? gainCorrectionB, bool invertPolarity)
7+
public NeuropixelsV2eDeviceInfo(ContextTask context, Type deviceType, uint deviceAddress, double? gainCorrectionA, double? gainCorrectionB, bool invertPolarity, INeuropixelsV2eMetadata probeMetadataA, INeuropixelsV2eMetadata probeMetadataB)
88
: base(context, deviceType, deviceAddress)
99
{
1010
GainCorrectionA = gainCorrectionA;
1111
GainCorrectionB = gainCorrectionB;
1212
InvertPolarity = invertPolarity;
13+
ProbeMetadataA = probeMetadataA;
14+
ProbeMetadataB = probeMetadataB;
1315
}
1416

1517
public double? GainCorrectionA { get; }
1618

1719
public double? GainCorrectionB { get; }
1820

19-
public bool InvertPolarity { get; }
21+
public bool InvertPolarity { get; }
22+
23+
public INeuropixelsV2eMetadata ProbeMetadataA { get; }
24+
25+
public INeuropixelsV2eMetadata ProbeMetadataB { get; }
2026
}
2127
}

OpenEphys.Onix1/NeuropixelsV2eMetadata.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace OpenEphys.Onix1
44
{
5-
class NeuropixelsV2eMetadata
5+
class NeuropixelsV2eMetadata : INeuropixelsV2eMetadata
66
{
77
const uint OFFSET_PROBE_SN = 0x00;
88
const uint OFFSET_FLEX_VERSION = 0x10;
@@ -39,6 +39,5 @@ public NeuropixelsV2eMetadata(I2CRegisterContext serializer)
3939
public string FlexPartNumber { get; }
4040

4141
public string FlexVersion { get; }
42-
4342
}
4443
}

0 commit comments

Comments
 (0)