Skip to content

Commit 30eda75

Browse files
committed
Refactor Neuropixels 2.0 probes in preparation for single-shank probes
- Deprecate the QuadShank classes in favor of the more generic configuration class - Update all methods to handle quad-shank cases, with easy scalability to add single-shank probes in the future - Add clone method for NeuropixelsV2eProbeGroup to ensure that dialogs can be exited without affecting settings - Update how the ChannelMap is accessed and utilized
1 parent a7dbd50 commit 30eda75

15 files changed

+741
-564
lines changed

OpenEphys.Onix1.Design/ChannelConfigurationDialog.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,21 @@ public partial class ChannelConfigurationDialog : Form
1919
internal event EventHandler OnResizeZedGraph;
2020
internal event EventHandler OnDrawProbeGroup;
2121

22-
internal ProbeGroup ProbeGroup;
22+
ProbeGroup probeGroup;
23+
24+
internal ProbeGroup ProbeGroup
25+
{
26+
get => probeGroup;
27+
set
28+
{
29+
probeGroup = value;
30+
SelectedContacts = new bool[probeGroup.NumberOfContacts];
31+
}
32+
}
2333

2434
internal readonly List<int> ReferenceContacts = new();
2535

26-
internal readonly bool[] SelectedContacts = null;
36+
internal bool[] SelectedContacts { get; private set; } = null;
2737

2838
[Obsolete("Designer only.", true)]
2939
ChannelConfigurationDialog()
@@ -49,8 +59,6 @@ public ChannelConfigurationDialog(ProbeGroup probeGroup)
4959
ProbeGroup = probeGroup;
5060
}
5161

52-
SelectedContacts = new bool[ProbeGroup.NumberOfContacts];
53-
5462
ReferenceContacts = new List<int>();
5563

5664
zedGraphChannels.MouseDownEvent += MouseDownEvent;
@@ -288,8 +296,6 @@ internal virtual bool OpenFile<T>() where T : ProbeGroup
288296
newConfiguration.Validate();
289297

290298
ProbeGroup = newConfiguration;
291-
DrawProbeGroup();
292-
RefreshZedGraph();
293299

294300
return true;
295301
}
@@ -1013,6 +1019,8 @@ private void MenuItemOpenFile(object sender, EventArgs e)
10131019
if (OpenFile<ProbeGroup>())
10141020
{
10151021
DrawProbeGroup();
1022+
ResetZoom();
1023+
UpdateFontSize();
10161024
RefreshZedGraph();
10171025
}
10181026
}
@@ -1021,6 +1029,7 @@ private void MenuItemLoadDefaultConfig(object sender, EventArgs e)
10211029
{
10221030
LoadDefaultChannelLayout();
10231031
DrawProbeGroup();
1032+
ResetZoom();
10241033
UpdateFontSize();
10251034
RefreshZedGraph();
10261035
}

OpenEphys.Onix1.Design/NeuropixelsV2eChannelConfigurationDialog.cs

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,24 @@ public partial class NeuropixelsV2eChannelConfigurationDialog : ChannelConfigura
1515
internal event EventHandler OnFileLoad;
1616

1717
/// <summary>
18-
/// Public <see cref="NeuropixelsV2QuadShankProbeConfiguration"/> object that is manipulated by
18+
/// Public <see cref="NeuropixelsV2ProbeConfiguration"/> object that is manipulated by
1919
/// <see cref="NeuropixelsV2eChannelConfigurationDialog"/>.
2020
/// </summary>
21-
public NeuropixelsV2QuadShankProbeConfiguration ProbeConfiguration;
21+
public NeuropixelsV2ProbeConfiguration ProbeConfiguration;
2222

2323
/// <summary>
2424
/// Initializes a new instance of <see cref="NeuropixelsV2eChannelConfigurationDialog"/>.
2525
/// </summary>
26-
/// <param name="probeConfiguration">A <see cref="NeuropixelsV2QuadShankProbeConfiguration"/> object holding the current configuration settings.</param>
27-
public NeuropixelsV2eChannelConfigurationDialog(NeuropixelsV2QuadShankProbeConfiguration probeConfiguration)
26+
/// <param name="probeConfiguration">A <see cref="NeuropixelsV2ProbeConfiguration"/> object holding the current configuration settings.</param>
27+
public NeuropixelsV2eChannelConfigurationDialog(NeuropixelsV2ProbeConfiguration probeConfiguration)
2828
: base(probeConfiguration.ProbeGroup)
2929
{
3030
zedGraphChannels.ZoomButtons = MouseButtons.None;
3131
zedGraphChannels.ZoomButtons2 = MouseButtons.None;
3232

3333
zedGraphChannels.ZoomStepFraction = 0.5;
3434

35-
ProbeConfiguration = probeConfiguration;
35+
ProbeConfiguration = new(probeConfiguration);
3636

3737
HighlightEnabledContacts();
3838
UpdateContactLabels();
@@ -42,13 +42,16 @@ public NeuropixelsV2eChannelConfigurationDialog(NeuropixelsV2QuadShankProbeConfi
4242

4343
internal override ProbeGroup DefaultChannelLayout()
4444
{
45-
return new NeuropixelsV2eProbeGroup();
45+
return new NeuropixelsV2eProbeGroup(ProbeConfiguration.ProbeType);
4646
}
4747

4848
internal override void LoadDefaultChannelLayout()
4949
{
50-
ProbeConfiguration = new(ProbeConfiguration.Probe, ProbeConfiguration.Reference);
51-
ProbeGroup = ProbeConfiguration.ProbeGroup;
50+
base.LoadDefaultChannelLayout();
51+
ProbeConfiguration = new((NeuropixelsV2eProbeGroup)ProbeGroup,
52+
ProbeConfiguration.Probe,
53+
ProbeConfiguration.ProbeType,
54+
ProbeConfiguration.Reference);
5255

5356
OnFileOpenHandler();
5457
}
@@ -57,8 +60,6 @@ internal override bool OpenFile<T>()
5760
{
5861
if (base.OpenFile<NeuropixelsV2eProbeGroup>())
5962
{
60-
ProbeConfiguration = new((NeuropixelsV2eProbeGroup)ProbeGroup, ProbeConfiguration.Reference, ProbeConfiguration.Probe);
61-
6263
OnFileOpenHandler();
6364

6465
return true;
@@ -106,7 +107,7 @@ internal override void DrawScale()
106107

107108
internal override void HighlightEnabledContacts()
108109
{
109-
if (ProbeConfiguration == null || ProbeConfiguration.ChannelMap == null)
110+
if (ProbeConfiguration == null)
110111
return;
111112

112113
var contactObjects = zedGraphChannels.GraphPane.GraphObjList.OfType<BoxObj>()
@@ -119,11 +120,13 @@ internal override void HighlightEnabledContacts()
119120
contact.Fill.Color = DisabledContactFill;
120121
}
121122

123+
var channelMap = ProbeConfiguration.ChannelMap;
124+
122125
var contactsToEnable = contactObjects.Where(c =>
123126
{
124127
var tag = c.Tag as ContactTag;
125-
var channel = NeuropixelsV2QuadShankElectrode.GetChannelNumber(tag.ContactIndex);
126-
return ProbeConfiguration.ChannelMap[channel].Index == tag.ContactIndex;
128+
var channel = NeuropixelsV2Electrode.GetChannelNumber(tag.ContactIndex, ProbeConfiguration.ProbeType);
129+
return channelMap[channel].Index == tag.ContactIndex;
127130
});
128131

129132
foreach (var contact in contactsToEnable)
@@ -149,11 +152,13 @@ internal override void UpdateContactLabels()
149152
textObj.FontSpec.FontColor = DisabledContactTextColor;
150153
}
151154

155+
var channelMap = ProbeConfiguration.ChannelMap;
156+
152157
textObjsToUpdate = textObjs.Where(c =>
153158
{
154159
var tag = c.Tag as ContactTag;
155-
var channel = NeuropixelsV2QuadShankElectrode.GetChannelNumber(tag.ContactIndex);
156-
return ProbeConfiguration.ChannelMap[channel].Index == tag.ContactIndex;
160+
var channel = NeuropixelsV2Electrode.GetChannelNumber(tag.ContactIndex, ProbeConfiguration.ProbeType);
161+
return channelMap[channel].Index == tag.ContactIndex;
157162
});
158163

159164
foreach (var textObj in textObjsToUpdate)
@@ -167,7 +172,7 @@ internal override string ContactString(int deviceChannelIndex, int index)
167172
return index.ToString();
168173
}
169174

170-
internal void EnableElectrodes(NeuropixelsV2QuadShankElectrode[] electrodes)
175+
internal void EnableElectrodes(NeuropixelsV2Electrode[] electrodes)
171176
{
172177
ProbeConfiguration.SelectElectrodes(electrodes);
173178
}

0 commit comments

Comments
 (0)