Skip to content
Draft
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
41 changes: 32 additions & 9 deletions OpenEphys.Onix1.Design/ChannelConfigurationDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,21 @@ public abstract partial class ChannelConfigurationDialog : Form
{
internal event EventHandler OnResizeZedGraph;

internal ProbeGroup ProbeGroup;
ProbeGroup probeGroup;

internal ProbeGroup ProbeGroup
{
get => probeGroup;
set
{
probeGroup = value;
SelectedContacts = new bool[probeGroup.NumberOfContacts];
}
}

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

internal readonly bool[] SelectedContacts = null;
internal bool[] SelectedContacts { get; private set; } = null;

/// <summary>
/// Constructs the dialog window using the given probe group, and plots all contacts after loading.
Expand All @@ -42,8 +52,6 @@ public ChannelConfigurationDialog(ProbeGroup probeGroup)
ProbeGroup = probeGroup;
}

SelectedContacts = new bool[ProbeGroup.NumberOfContacts];

ReferenceContacts = new List<int>();

zedGraphChannels.MouseDownEvent += MouseDownEvent;
Expand Down Expand Up @@ -432,13 +440,25 @@ internal virtual bool OpenFile<T>() where T : ProbeGroup
return false;
}

if (ProbeGroup.NumberOfContacts == newConfiguration.NumberOfContacts)
bool skipContactNumberMismatchCheck = false;

if (ProbeGroup.Probes.First().Annotations.Name != newConfiguration.Probes.First().Annotations.Name)
{
var result = MessageBox.Show($"There is a mismatch between the current probe type ({ProbeGroup.Probes.First().Annotations.Name})" +
$" and the new probe type ({newConfiguration.Probes.First().Annotations.Name}). Continue loading?", "Probe Type Mismatch", MessageBoxButtons.YesNo);

if (result == DialogResult.No)
return false;

skipContactNumberMismatchCheck = true; // NB: If the probe names do not match, skip the check to see if the number of contacts match.
// Example: loading a Neuropixels single-shank 2.0 probe, but the current probe is a quad-shank 2.0 probe.
}

if (skipContactNumberMismatchCheck || ProbeGroup.NumberOfContacts == newConfiguration.NumberOfContacts)
{
newConfiguration.Validate();

ProbeGroup = newConfiguration;
DrawProbeGroup();
RefreshZedGraph();

return true;
}
Expand Down Expand Up @@ -1075,6 +1095,8 @@ private void MenuItemOpenFile(object sender, EventArgs e)
if (OpenFile<ProbeGroup>())
{
DrawProbeGroup();
ResetZoom();
UpdateFontSize();
RefreshZedGraph();
}
}
Expand All @@ -1083,6 +1105,7 @@ private void MenuItemLoadDefaultConfig(object sender, EventArgs e)
{
LoadDefaultChannelLayout();
DrawProbeGroup();
ResetZoom();
UpdateFontSize();
RefreshZedGraph();
}
Expand Down Expand Up @@ -1342,8 +1365,8 @@ internal static bool HasContactAnnotations(ProbeGroup probeGroup)
{
foreach (var probe in probeGroup.Probes)
{
if (probe.ContactAnnotations != null
&& probe.ContactAnnotations.Annotations != null
if (probe.ContactAnnotations != null
&& probe.ContactAnnotations.Annotations != null
&& probe.ContactAnnotations.Annotations.Length > 0)
{
return true;
Expand Down
30 changes: 15 additions & 15 deletions OpenEphys.Onix1.Design/NeuropixelsV2eChannelConfigurationDialog.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
Expand All @@ -17,24 +16,24 @@ public partial class NeuropixelsV2eChannelConfigurationDialog : ChannelConfigura
internal event EventHandler OnFileLoad;

/// <summary>
/// Public <see cref="NeuropixelsV2QuadShankProbeConfiguration"/> object that is manipulated by
/// Public <see cref="NeuropixelsV2ProbeConfiguration"/> object that is manipulated by
/// <see cref="NeuropixelsV2eChannelConfigurationDialog"/>.
/// </summary>
public NeuropixelsV2QuadShankProbeConfiguration ProbeConfiguration;
public NeuropixelsV2ProbeConfiguration ProbeConfiguration;

/// <summary>
/// Initializes a new instance of <see cref="NeuropixelsV2eChannelConfigurationDialog"/>.
/// </summary>
/// <param name="probeConfiguration">A <see cref="NeuropixelsV2QuadShankProbeConfiguration"/> object holding the current configuration settings.</param>
public NeuropixelsV2eChannelConfigurationDialog(NeuropixelsV2QuadShankProbeConfiguration probeConfiguration)
/// <param name="probeConfiguration">A <see cref="NeuropixelsV2ProbeConfiguration"/> object holding the current configuration settings.</param>
public NeuropixelsV2eChannelConfigurationDialog(NeuropixelsV2ProbeConfiguration probeConfiguration)
: base(probeConfiguration.ProbeGroup)
{
zedGraphChannels.ZoomButtons = MouseButtons.None;
zedGraphChannels.ZoomButtons2 = MouseButtons.None;

zedGraphChannels.ZoomStepFraction = 0.5;

ProbeConfiguration = probeConfiguration;
ProbeConfiguration = new(probeConfiguration);

ZoomInBoundaryX = 600;
ZoomInBoundaryY = 600;
Expand All @@ -46,13 +45,16 @@ public NeuropixelsV2eChannelConfigurationDialog(NeuropixelsV2QuadShankProbeConfi

internal override ProbeGroup DefaultChannelLayout()
{
return new NeuropixelsV2eProbeGroup();
return new NeuropixelsV2eProbeGroup(ProbeConfiguration.ProbeType);
}

internal override void LoadDefaultChannelLayout()
{
ProbeConfiguration = new(ProbeConfiguration.Probe, ProbeConfiguration.Reference);
ProbeGroup = ProbeConfiguration.ProbeGroup;
base.LoadDefaultChannelLayout();
ProbeConfiguration = new((NeuropixelsV2eProbeGroup)ProbeGroup,
ProbeConfiguration.Probe,
ProbeConfiguration.ProbeType,
ProbeConfiguration.Reference);

OnFileOpenHandler();
}
Expand All @@ -61,8 +63,6 @@ internal override bool OpenFile<T>()
{
if (base.OpenFile<NeuropixelsV2eProbeGroup>())
{
ProbeConfiguration = new((NeuropixelsV2eProbeGroup)ProbeGroup, ProbeConfiguration.Reference, ProbeConfiguration.Probe);

OnFileOpenHandler();

return true;
Expand Down Expand Up @@ -173,7 +173,7 @@ internal override void DrawScale()

const float scaleBarWidth = 1;

curve.Line.Width = scaleBarWidth;
curve.Line.Width = scaleBarWidth;
curve.Label.IsVisible = false;
curve.Symbol.IsVisible = false;
curve.Tag = ScalePointsTag;
Expand All @@ -197,7 +197,7 @@ internal override void HighlightEnabledContacts()
var contactsToEnable = contactObjects.Where(c =>
{
var tag = c.Tag as ContactTag;
var channel = NeuropixelsV2QuadShankElectrode.GetChannelNumber(tag.ContactIndex);
var channel = NeuropixelsV2Electrode.GetChannelNumber(tag.ContactIndex, ProbeConfiguration.ProbeType);
return ProbeConfiguration.ChannelMap[channel].Index == tag.ContactIndex;
});

Expand Down Expand Up @@ -227,7 +227,7 @@ internal override void UpdateContactLabels()
textObjsToUpdate = textObjs.Where(c =>
{
var tag = c.Tag as ContactTag;
var channel = NeuropixelsV2QuadShankElectrode.GetChannelNumber(tag.ContactIndex);
var channel = NeuropixelsV2Electrode.GetChannelNumber(tag.ContactIndex, ProbeConfiguration.ProbeType);
return ProbeConfiguration.ChannelMap[channel].Index == tag.ContactIndex;
});

Expand All @@ -242,7 +242,7 @@ internal override string ContactString(int deviceChannelIndex, int index)
return index.ToString();
}

internal void EnableElectrodes(NeuropixelsV2QuadShankElectrode[] electrodes)
internal void EnableElectrodes(NeuropixelsV2Electrode[] electrodes)
{
ProbeConfiguration.SelectElectrodes(electrodes);
}
Expand Down
7 changes: 5 additions & 2 deletions OpenEphys.Onix1.Design/NeuropixelsV2eDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ public NeuropixelsV2eDialog(IConfigureNeuropixelsV2 configureNode)
InitializeComponent();
Shown += FormShown;

bool isBeta = false;

if (configureNode is ConfigureNeuropixelsV2eBeta configureV2eBeta)
{
isBeta = true;
ConfigureNode = new ConfigureNeuropixelsV2eBeta(configureV2eBeta);
Text = Text.Replace("NeuropixelsV2e ", "NeuropixelsV2eBeta ");
}
Expand All @@ -38,15 +41,15 @@ public NeuropixelsV2eDialog(IConfigureNeuropixelsV2 configureNode)

ProbeConfigurations = new List<NeuropixelsV2eProbeConfigurationDialog>
{
new(ConfigureNode.ProbeConfigurationA, ConfigureNode.GainCalibrationFileA, ConfigureNode.InvertPolarity)
new(ConfigureNode.ProbeConfigurationA, ConfigureNode.GainCalibrationFileA, ConfigureNode.InvertPolarity, isBeta)
{
TopLevel = false,
FormBorderStyle = FormBorderStyle.None,
Dock = DockStyle.Fill,
Parent = this,
Tag = NeuropixelsV2Probe.ProbeA
},
new(ConfigureNode.ProbeConfigurationB, ConfigureNode.GainCalibrationFileB, ConfigureNode.InvertPolarity)
new(ConfigureNode.ProbeConfigurationB, ConfigureNode.GainCalibrationFileB, ConfigureNode.InvertPolarity, isBeta)
{
TopLevel = false,
FormBorderStyle = FormBorderStyle.None,
Expand Down
Loading
Loading