Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions OpenEphys.Onix1/ConfigureNeuropixelsV2e.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,6 @@ public override IObservable<ContextTask> Process(IObservable<ContextTask> source
var probeAMetadata = ReadProbeMetadata(serializer, NeuropixelsV2e.ProbeASelected);
var probeBMetadata = ReadProbeMetadata(serializer, NeuropixelsV2e.ProbeBSelected);

if (probeAMetadata.ProbeSerialNumber == null && probeBMetadata.ProbeSerialNumber == null)
{
throw new InvalidOperationException("No probes were detected. Ensure that the " +
"flex connection is properly seated.");
}

// issue full reset to both probes
ResetProbes(serializer, gpo10Config);

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

var deviceInfo = new NeuropixelsV2eDeviceInfo(context, DeviceType, deviceAddress, gainCorrectionA, gainCorrectionB, invertPolarity);
var deviceInfo = new NeuropixelsV2eDeviceInfo(context, DeviceType, deviceAddress, gainCorrectionA, gainCorrectionB, invertPolarity, probeAMetadata, probeBMetadata);
var shutdown = Disposable.Create(() =>
{
serializer.WriteByte((uint)DS90UB933SerializerI2CRegister.Gpio10, NeuropixelsV2e.DefaultGPO10Config);
Expand Down
8 changes: 1 addition & 7 deletions OpenEphys.Onix1/ConfigureNeuropixelsV2eBeta.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,6 @@ public override IObservable<ContextTask> Process(IObservable<ContextTask> source
var probeAMetadata = ReadProbeMetadata(serializer, ref gpo32Config, NeuropixelsV2eBeta.SelectProbeA);
var probeBMetadata = ReadProbeMetadata(serializer, ref gpo32Config, NeuropixelsV2eBeta.SelectProbeB);

if (probeAMetadata.ProbeSerialNumber == null && probeBMetadata.ProbeSerialNumber == null)
{
throw new InvalidOperationException("No probes were detected. Ensure that the " +
"flex connection is properly seated.");
}

// REC_NRESET and NRESET go high on both probes to take the ASIC out of reset
// TODO: not sure if REC_NRESET and NRESET are tied together on flex
gpo10Config |= NeuropixelsV2eBeta.GPO10ResetMask | NeuropixelsV2eBeta.GPO10NResetMask;
Expand Down Expand Up @@ -217,7 +211,7 @@ public override IObservable<ContextTask> Process(IObservable<ContextTask> source
// Still its good to get them roughly (i.e. within 10 PCLKs) started at the same time.
SyncProbes(serializer, gpo10Config);

var deviceInfo = new NeuropixelsV2eDeviceInfo(context, DeviceType, deviceAddress, gainCorrectionA, gainCorrectionB, invertPolarity);
var deviceInfo = new NeuropixelsV2eDeviceInfo(context, DeviceType, deviceAddress, gainCorrectionA, gainCorrectionB, invertPolarity, probeAMetadata, probeBMetadata);
var shutdown = Disposable.Create(() =>
{
serializer.WriteByte((uint)DS90UB933SerializerI2CRegister.Gpio10, NeuropixelsV2eBeta.DefaultGPO10Config);
Expand Down
13 changes: 13 additions & 0 deletions OpenEphys.Onix1/INeuropixelsV2eMetadata.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace OpenEphys.Onix1
{
interface INeuropixelsV2eMetadata
{
public string ProbePartNumber { get; }

public ulong? ProbeSerialNumber { get; }

public string FlexPartNumber { get; }

public string FlexVersion { get; }
}
}
14 changes: 13 additions & 1 deletion OpenEphys.Onix1/NeuropixelsV2eBetaData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ public unsafe override IObservable<NeuropixelsV2eBetaDataFrame> Generate()
return DeviceManager.GetDevice(DeviceName).SelectMany(deviceInfo =>
{
var info = (NeuropixelsV2eDeviceInfo)deviceInfo;
var metadata = ProbeIndex switch
{
NeuropixelsV2Probe.ProbeA => info.ProbeMetadataA,
NeuropixelsV2Probe.ProbeB => info.ProbeMetadataB,
_ => throw new InvalidEnumArgumentException($"Unexpected {nameof(ProbeIndex)} value: {ProbeIndex}")
};

if (metadata.ProbeSerialNumber == null)
{
throw new InvalidOperationException($"{ProbeIndex} is not detected. Ensure that the flex connection is properly seated.");
}

var device = info.GetDeviceContext(typeof(NeuropixelsV2eBeta));
var passthrough = device.GetPassthroughDeviceContext(typeof(DS90UB9x));
var probeData = device.Context
Expand All @@ -62,7 +74,7 @@ public unsafe override IObservable<NeuropixelsV2eBetaDataFrame> Generate()
{
NeuropixelsV2Probe.ProbeA => (double)info.GainCorrectionA,
NeuropixelsV2Probe.ProbeB => (double)info.GainCorrectionB,
_ => throw new ArgumentOutOfRangeException(nameof(ProbeIndex), $"Unexpected {nameof(ProbeIndex)} value: {ProbeIndex}"),
_ => throw new InvalidEnumArgumentException($"Unexpected {nameof(ProbeIndex)} value: {ProbeIndex}")
};

return Observable.Create<NeuropixelsV2eBetaDataFrame>(observer =>
Expand Down
3 changes: 1 addition & 2 deletions OpenEphys.Onix1/NeuropixelsV2eBetaMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace OpenEphys.Onix1
{
class NeuropixelsV2eBetaMetadata
class NeuropixelsV2eBetaMetadata : INeuropixelsV2eMetadata
{
const uint OFFSET_FLEX_VERSION = 0x00;
const uint OFFSET_FLEX_REVISION = 0x01;
Expand Down Expand Up @@ -39,6 +39,5 @@ public NeuropixelsV2eBetaMetadata(I2CRegisterContext serializer)
public string FlexPartNumber { get; }

public string FlexVersion { get; }

}
}
14 changes: 13 additions & 1 deletion OpenEphys.Onix1/NeuropixelsV2eData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ public unsafe override IObservable<NeuropixelsV2eDataFrame> Generate()
return DeviceManager.GetDevice(DeviceName).SelectMany(deviceInfo =>
{
var info = (NeuropixelsV2eDeviceInfo)deviceInfo;
var metadata = ProbeIndex switch
{
NeuropixelsV2Probe.ProbeA => info.ProbeMetadataA,
NeuropixelsV2Probe.ProbeB => info.ProbeMetadataB,
_ => throw new InvalidEnumArgumentException($"Unexpected {nameof(ProbeIndex)} value: {ProbeIndex}")
};

if (metadata.ProbeSerialNumber == null)
{
throw new InvalidOperationException($"{ProbeIndex} is not detected. Ensure that the flex connection is properly seated.");
}

var device = info.GetDeviceContext(typeof(NeuropixelsV2e));
var passthrough = device.GetPassthroughDeviceContext(typeof(DS90UB9x));
var probeData = device.Context
Expand All @@ -66,7 +78,7 @@ public unsafe override IObservable<NeuropixelsV2eDataFrame> Generate()
{
NeuropixelsV2Probe.ProbeA => (double)info.GainCorrectionA,
NeuropixelsV2Probe.ProbeB => (double)info.GainCorrectionB,
_ => throw new ArgumentOutOfRangeException(nameof(ProbeIndex), $"Unexpected {nameof(ProbeIndex)} value: {ProbeIndex}"),
_ => throw new InvalidEnumArgumentException($"Unexpected {nameof(ProbeIndex)} value: {ProbeIndex}")
};

return Observable.Create<NeuropixelsV2eDataFrame>(observer =>
Expand Down
10 changes: 8 additions & 2 deletions OpenEphys.Onix1/NeuropixelsV2eDeviceInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@ namespace OpenEphys.Onix1
{
class NeuropixelsV2eDeviceInfo : DeviceInfo
{
public NeuropixelsV2eDeviceInfo(ContextTask context, Type deviceType, uint deviceAddress, double? gainCorrectionA, double? gainCorrectionB, bool invertPolarity)
public NeuropixelsV2eDeviceInfo(ContextTask context, Type deviceType, uint deviceAddress, double? gainCorrectionA, double? gainCorrectionB, bool invertPolarity, INeuropixelsV2eMetadata probeMetadataA, INeuropixelsV2eMetadata probeMetadataB)
: base(context, deviceType, deviceAddress)
{
GainCorrectionA = gainCorrectionA;
GainCorrectionB = gainCorrectionB;
InvertPolarity = invertPolarity;
ProbeMetadataA = probeMetadataA;
ProbeMetadataB = probeMetadataB;
}

public double? GainCorrectionA { get; }

public double? GainCorrectionB { get; }

public bool InvertPolarity { get; }
public bool InvertPolarity { get; }

public INeuropixelsV2eMetadata ProbeMetadataA { get; }

public INeuropixelsV2eMetadata ProbeMetadataB { get; }
}
}
3 changes: 1 addition & 2 deletions OpenEphys.Onix1/NeuropixelsV2eMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace OpenEphys.Onix1
{
class NeuropixelsV2eMetadata
class NeuropixelsV2eMetadata : INeuropixelsV2eMetadata
{
const uint OFFSET_PROBE_SN = 0x00;
const uint OFFSET_FLEX_VERSION = 0x10;
Expand Down Expand Up @@ -39,6 +39,5 @@ public NeuropixelsV2eMetadata(I2CRegisterContext serializer)
public string FlexPartNumber { get; }

public string FlexVersion { get; }

}
}