Skip to content
Open
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
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}")
};
}
}
}
20 changes: 14 additions & 6 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 @@ -32,9 +43,6 @@ public NeuropixelsV2eChannelConfigurationDialog(NeuropixelsV2ProbeConfiguration
zedGraphChannels.ZoomStepFraction = 0.5;

ProbeConfiguration = Activator.CreateInstance(probeConfiguration.GetType(), probeConfiguration) as NeuropixelsV2ProbeConfiguration;
ProbeConfiguration.ProbeGroup = (NeuropixelsV2eProbeGroup)ProbeGroup;

GetChannelNumberFunc = ProbeConfiguration.ChannelMap[0].GetChannelNumberFunc();

HighlightEnabledContacts();
UpdateContactLabels();
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,10 +26,13 @@ public NeuropixelsV2eDialog(IConfigureNeuropixelsV2 configureNode)
InitializeComponent();
Shown += FormShown;

bool isBeta = false;

if (configureNode is ConfigureNeuropixelsV2eBeta configureV2eBeta)
{
ConfigureNode = new ConfigureNeuropixelsV2eBeta(configureV2eBeta);
Text = Text.Replace("NeuropixelsV2e ", "NeuropixelsV2eBeta ");
isBeta = true;
}
else if (configureNode is ConfigureNeuropixelsV2e configureV2e)
{
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

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

Loading