Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
6 changes: 2 additions & 4 deletions OpenEphys.Onix1.Design/ChannelConfigurationDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,8 @@ internal bool ValidateProbeGroup(ProbeGroup newConfiguration)
}
else
{
MessageBox.Show($"Error: Number of contacts does not match; expected {ProbeGroup.NumberOfContacts} contacts" +
$", but found {newConfiguration.NumberOfContacts} contacts", "Contact Number Mismatch");

return false;
throw new InvalidOperationException($"Number of contacts does not match; expected {ProbeGroup.NumberOfContacts} contacts" +
$", but found {newConfiguration.NumberOfContacts} contacts. Ensure the file contains the correct probe group type.");
}
}

Expand Down
3 changes: 3 additions & 0 deletions OpenEphys.Onix1.Design/INeuropixelsV2ProbeInfo.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using System;
using System.Collections.Generic;

namespace OpenEphys.Onix1.Design
{
interface INeuropixelsV2ProbeInfo
{
public IEnumerable<NeuropixelsV2Electrode> Electrodes { get; init; }

Array GetReferenceEnumValues();

Array GetComboBoxChannelPresets();
Expand Down
2 changes: 1 addition & 1 deletion OpenEphys.Onix1.Design/NeuropixelsV2QuadShankInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ enum QuadShankChannelPreset
None
}

IEnumerable<NeuropixelsV2Electrode> Electrodes { get; init; }
public IEnumerable<NeuropixelsV2Electrode> Electrodes { get; init; }

public NeuropixelsV2QuadShankInfo(NeuropixelsV2QuadShankProbeConfiguration probeConfiguration)
{
Expand Down
78 changes: 78 additions & 0 deletions OpenEphys.Onix1.Design/NeuropixelsV2SingleShankInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;

namespace OpenEphys.Onix1.Design
{
internal class NeuropixelsV2SingleShankInfo : INeuropixelsV2ProbeInfo
{
const int BankDStartIndex = 896;

enum SingleShankChannelPreset
{
BankA,
BankB,
BankC,
BankD,
None
}

public IEnumerable<NeuropixelsV2Electrode> Electrodes { get; init; }

public NeuropixelsV2SingleShankInfo(NeuropixelsV2SingleShankProbeConfiguration probeConfiguration)
{
Electrodes = probeConfiguration.ProbeGroup.ToElectrodes();
}

public Array GetReferenceEnumValues()
{
return Enum.GetValues(typeof(NeuropixelsV2SingleShankReference));
}

public Array GetComboBoxChannelPresets()
{
return Enum.GetValues(typeof(SingleShankChannelPreset));
}

public Enum CheckForExistingChannelPreset(NeuropixelsV2Electrode[] channelMap)
{
if (channelMap.All(e => e.Bank == NeuropixelsV2Bank.A))
{
return SingleShankChannelPreset.BankA;
}
else if (channelMap.All(e => e.Bank == NeuropixelsV2Bank.B))
{
return SingleShankChannelPreset.BankB;
}
else if (channelMap.All(e => e.Bank == NeuropixelsV2Bank.C))
{
return SingleShankChannelPreset.BankC;
}
else if (channelMap.All(e => e.Bank == NeuropixelsV2Bank.D ||
(e.Bank == NeuropixelsV2Bank.C && e.Index >= BankDStartIndex)))
{
return SingleShankChannelPreset.BankD;
}
else
{
return SingleShankChannelPreset.None;
}
}

public NeuropixelsV2Electrode[] GetChannelPreset(Enum channelPreset)
{
var preset = (SingleShankChannelPreset)channelPreset;

return preset switch
{
SingleShankChannelPreset.BankA => Electrodes.Where(e => e.Bank == NeuropixelsV2Bank.A).ToArray(),
SingleShankChannelPreset.BankB => Electrodes.Where(e => e.Bank == NeuropixelsV2Bank.B).ToArray(),
SingleShankChannelPreset.BankC => Electrodes.Where(e => e.Bank == NeuropixelsV2Bank.C).ToArray(),
SingleShankChannelPreset.BankD => Electrodes.Where(e => e.Bank == NeuropixelsV2Bank.D || (e.Bank == NeuropixelsV2Bank.C && e.Index >= BankDStartIndex)).ToArray(),
SingleShankChannelPreset.None => Array.Empty<NeuropixelsV2Electrode>(),
_ => throw new InvalidEnumArgumentException($"Unknown value of {nameof(SingleShankChannelPreset)}: {channelPreset}")
};
}
}
}
22 changes: 15 additions & 7 deletions OpenEphys.Onix1.Design/NeuropixelsV2eChannelConfigurationDialog.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Linq;
using System.Reflection;
using System.Windows.Forms;
using OpenEphys.ProbeInterface.NET;
using ZedGraph;
Expand All @@ -15,9 +14,21 @@ public partial class NeuropixelsV2eChannelConfigurationDialog : ChannelConfigura
internal event EventHandler OnZoom;
internal event EventHandler OnFileLoad;

internal NeuropixelsV2ProbeConfiguration ProbeConfiguration;
NeuropixelsV2ProbeConfiguration probeConfiguration;

readonly Func<int, int> GetChannelNumberFunc;
internal NeuropixelsV2ProbeConfiguration ProbeConfiguration
{
get => probeConfiguration;
set
{
probeConfiguration = value;
ProbeGroup = value.ProbeGroup;

GetChannelNumberFunc = ProbeConfiguration.GetChannelNumberFunc();
}
}

Func<int, int> GetChannelNumberFunc { get; set; }

/// <summary>
/// Initializes a new instance of <see cref="NeuropixelsV2eChannelConfigurationDialog"/>.
Expand All @@ -31,10 +42,7 @@ public NeuropixelsV2eChannelConfigurationDialog(NeuropixelsV2ProbeConfiguration

zedGraphChannels.ZoomStepFraction = 0.5;

ProbeConfiguration = probeConfiguration.Clone();
ProbeConfiguration.ProbeGroup = (NeuropixelsV2eProbeGroup)ProbeGroup;

GetChannelNumberFunc = ProbeConfiguration.ChannelMap[0].GetChannelNumberFunc();
ProbeConfiguration = Activator.CreateInstance(probeConfiguration.GetType(), probeConfiguration) as NeuropixelsV2ProbeConfiguration;

HighlightEnabledContacts();
UpdateContactLabels();
Expand Down
9 changes: 6 additions & 3 deletions OpenEphys.Onix1.Design/NeuropixelsV2eDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,18 @@ public NeuropixelsV2eDialog(IConfigureNeuropixelsV2 configureNode)
InitializeComponent();
Shown += FormShown;

if (configureNode is ConfigureNeuropixelsV2eBeta)
bool isBeta = false;

if (configureNode is ConfigureNeuropixelsV2eBeta configureV2eBeta)
{
Text = Text.Replace("NeuropixelsV2e ", "NeuropixelsV2eBeta ");
isBeta = true;
}

ProbeConfigurations = new()
{
{ NeuropixelsV2Probe.ProbeA, new(configureNode.ProbeConfigurationA) },
{ NeuropixelsV2Probe.ProbeB, new(configureNode.ProbeConfigurationB) }
{ NeuropixelsV2Probe.ProbeA, new(configureNode.ProbeConfigurationA, isBeta) },
{ NeuropixelsV2Probe.ProbeB, new(configureNode.ProbeConfigurationB, isBeta) }
};

foreach (var channelConfiguration in ProbeConfigurations)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading