Skip to content

Commit d3728f0

Browse files
committed
Add support for NPX 2.0 single-shank probes
1 parent b52401e commit d3728f0

22 files changed

+827
-145
lines changed

OpenEphys.Onix1.Design/ChannelConfigurationDialog.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,8 @@ internal bool ValidateProbeGroup(ProbeGroup newConfiguration)
311311
}
312312
else
313313
{
314-
MessageBox.Show($"Error: Number of contacts does not match; expected {ProbeGroup.NumberOfContacts} contacts" +
315-
$", but found {newConfiguration.NumberOfContacts} contacts", "Contact Number Mismatch");
316-
317-
return false;
314+
throw new InvalidOperationException($"Number of contacts does not match; expected {ProbeGroup.NumberOfContacts} contacts" +
315+
$", but found {newConfiguration.NumberOfContacts} contacts. Ensure the file contains the correct probe group type.");
318316
}
319317
}
320318

OpenEphys.Onix1.Design/INeuropixelsV2ProbeInfo.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
using System;
2+
using System.Collections.Generic;
23

34
namespace OpenEphys.Onix1.Design
45
{
56
interface INeuropixelsV2ProbeInfo
67
{
8+
public IEnumerable<NeuropixelsV2Electrode> Electrodes { get; init; }
9+
710
Array GetReferenceEnumValues();
811

912
Array GetComboBoxChannelPresets();

OpenEphys.Onix1.Design/NeuropixelsV2QuadShankInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ enum QuadShankChannelPreset
4343
None
4444
}
4545

46-
IEnumerable<NeuropixelsV2Electrode> Electrodes { get; init; }
46+
public IEnumerable<NeuropixelsV2Electrode> Electrodes { get; init; }
4747

4848
public NeuropixelsV2QuadShankInfo(NeuropixelsV2QuadShankProbeConfiguration probeConfiguration)
4949
{
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Linq;
5+
6+
namespace OpenEphys.Onix1.Design
7+
{
8+
internal class NeuropixelsV2SingleShankInfo : INeuropixelsV2ProbeInfo
9+
{
10+
const int BankDStartIndex = 896;
11+
12+
enum SingleShankChannelPreset
13+
{
14+
BankA,
15+
BankB,
16+
BankC,
17+
BankD,
18+
None
19+
}
20+
21+
public IEnumerable<NeuropixelsV2Electrode> Electrodes { get; init; }
22+
23+
public NeuropixelsV2SingleShankInfo(NeuropixelsV2SingleShankProbeConfiguration probeConfiguration)
24+
{
25+
Electrodes = probeConfiguration.ProbeGroup.ToElectrodes();
26+
}
27+
28+
public Array GetReferenceEnumValues()
29+
{
30+
return Enum.GetValues(typeof(NeuropixelsV2SingleShankReference));
31+
}
32+
33+
public Array GetComboBoxChannelPresets()
34+
{
35+
return Enum.GetValues(typeof(SingleShankChannelPreset));
36+
}
37+
38+
public Enum CheckForExistingChannelPreset(NeuropixelsV2Electrode[] channelMap)
39+
{
40+
if (channelMap.All(e => e.Bank == NeuropixelsV2Bank.A))
41+
{
42+
return SingleShankChannelPreset.BankA;
43+
}
44+
else if (channelMap.All(e => e.Bank == NeuropixelsV2Bank.B))
45+
{
46+
return SingleShankChannelPreset.BankB;
47+
}
48+
else if (channelMap.All(e => e.Bank == NeuropixelsV2Bank.C))
49+
{
50+
return SingleShankChannelPreset.BankC;
51+
}
52+
else if (channelMap.All(e => e.Bank == NeuropixelsV2Bank.D ||
53+
(e.Bank == NeuropixelsV2Bank.C && e.Index >= BankDStartIndex)))
54+
{
55+
return SingleShankChannelPreset.BankD;
56+
}
57+
else
58+
{
59+
return SingleShankChannelPreset.None;
60+
}
61+
}
62+
63+
public NeuropixelsV2Electrode[] GetChannelPreset(Enum channelPreset)
64+
{
65+
var preset = (SingleShankChannelPreset)channelPreset;
66+
67+
return preset switch
68+
{
69+
SingleShankChannelPreset.BankA => Electrodes.Where(e => e.Bank == NeuropixelsV2Bank.A).ToArray(),
70+
SingleShankChannelPreset.BankB => Electrodes.Where(e => e.Bank == NeuropixelsV2Bank.B).ToArray(),
71+
SingleShankChannelPreset.BankC => Electrodes.Where(e => e.Bank == NeuropixelsV2Bank.C).ToArray(),
72+
SingleShankChannelPreset.BankD => Electrodes.Where(e => e.Bank == NeuropixelsV2Bank.D || (e.Bank == NeuropixelsV2Bank.C && e.Index >= BankDStartIndex)).ToArray(),
73+
SingleShankChannelPreset.None => Array.Empty<NeuropixelsV2Electrode>(),
74+
_ => throw new InvalidEnumArgumentException($"Unknown value of {nameof(SingleShankChannelPreset)}: {channelPreset}")
75+
};
76+
}
77+
}
78+
}

OpenEphys.Onix1.Design/NeuropixelsV2eChannelConfigurationDialog.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Linq;
3-
using System.Reflection;
43
using System.Windows.Forms;
54
using OpenEphys.ProbeInterface.NET;
65
using ZedGraph;
@@ -15,9 +14,21 @@ public partial class NeuropixelsV2eChannelConfigurationDialog : ChannelConfigura
1514
internal event EventHandler OnZoom;
1615
internal event EventHandler OnFileLoad;
1716

18-
internal NeuropixelsV2ProbeConfiguration ProbeConfiguration;
17+
NeuropixelsV2ProbeConfiguration probeConfiguration;
1918

20-
readonly Func<int, int> GetChannelNumberFunc;
19+
internal NeuropixelsV2ProbeConfiguration ProbeConfiguration
20+
{
21+
get => probeConfiguration;
22+
set
23+
{
24+
probeConfiguration = value;
25+
ProbeGroup = value.ProbeGroup;
26+
27+
GetChannelNumberFunc = ProbeConfiguration.GetChannelNumberFunc();
28+
}
29+
}
30+
31+
Func<int, int> GetChannelNumberFunc { get; set; }
2132

2233
/// <summary>
2334
/// Initializes a new instance of <see cref="NeuropixelsV2eChannelConfigurationDialog"/>.
@@ -32,9 +43,6 @@ public NeuropixelsV2eChannelConfigurationDialog(NeuropixelsV2ProbeConfiguration
3243
zedGraphChannels.ZoomStepFraction = 0.5;
3344

3445
ProbeConfiguration = Activator.CreateInstance(probeConfiguration.GetType(), probeConfiguration) as NeuropixelsV2ProbeConfiguration;
35-
ProbeConfiguration.ProbeGroup = (NeuropixelsV2eProbeGroup)ProbeGroup;
36-
37-
GetChannelNumberFunc = ProbeConfiguration.ChannelMap[0].GetChannelNumberFunc();
3846

3947
HighlightEnabledContacts();
4048
UpdateContactLabels();

OpenEphys.Onix1.Design/NeuropixelsV2eDialog.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ public NeuropixelsV2eDialog(IConfigureNeuropixelsV2 configureNode)
2626
InitializeComponent();
2727
Shown += FormShown;
2828

29+
bool isBeta = false;
30+
2931
if (configureNode is ConfigureNeuropixelsV2eBeta configureV2eBeta)
3032
{
3133
ConfigureNode = new ConfigureNeuropixelsV2eBeta(configureV2eBeta);
3234
Text = Text.Replace("NeuropixelsV2e ", "NeuropixelsV2eBeta ");
35+
isBeta = true;
3336
}
3437
else if (configureNode is ConfigureNeuropixelsV2e configureV2e)
3538
{
@@ -38,15 +41,15 @@ public NeuropixelsV2eDialog(IConfigureNeuropixelsV2 configureNode)
3841

3942
ProbeConfigurations = new List<NeuropixelsV2eProbeConfigurationDialog>
4043
{
41-
new(ConfigureNode.ProbeConfigurationA, ConfigureNode.GainCalibrationFileA, ConfigureNode.InvertPolarity)
44+
new(ConfigureNode.ProbeConfigurationA, ConfigureNode.GainCalibrationFileA, ConfigureNode.InvertPolarity, isBeta)
4245
{
4346
TopLevel = false,
4447
FormBorderStyle = FormBorderStyle.None,
4548
Dock = DockStyle.Fill,
4649
Parent = this,
4750
Tag = NeuropixelsV2Probe.ProbeA
4851
},
49-
new(ConfigureNode.ProbeConfigurationB, ConfigureNode.GainCalibrationFileB, ConfigureNode.InvertPolarity)
52+
new(ConfigureNode.ProbeConfigurationB, ConfigureNode.GainCalibrationFileB, ConfigureNode.InvertPolarity, isBeta)
5053
{
5154
TopLevel = false,
5255
FormBorderStyle = FormBorderStyle.None,

OpenEphys.Onix1.Design/NeuropixelsV2eProbeConfigurationDialog.Designer.cs

Lines changed: 31 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)