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
21 changes: 15 additions & 6 deletions OpenEphys.Onix1.Design/ChannelConfigurationDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,21 @@ public partial class ChannelConfigurationDialog : Form
internal event EventHandler OnResizeZedGraph;
internal event EventHandler OnDrawProbeGroup;

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;

[Obsolete("Designer only.", true)]
ChannelConfigurationDialog()
Expand All @@ -49,8 +59,6 @@ public ChannelConfigurationDialog(ProbeGroup probeGroup)
ProbeGroup = probeGroup;
}

SelectedContacts = new bool[ProbeGroup.NumberOfContacts];

ReferenceContacts = new List<int>();

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

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

return true;
}
Expand Down Expand Up @@ -1013,6 +1019,8 @@ private void MenuItemOpenFile(object sender, EventArgs e)
if (OpenFile<ProbeGroup>())
{
DrawProbeGroup();
ResetZoom();
UpdateFontSize();
RefreshZedGraph();
}
}
Expand All @@ -1021,6 +1029,7 @@ private void MenuItemLoadDefaultConfig(object sender, EventArgs e)
{
LoadDefaultChannelLayout();
DrawProbeGroup();
ResetZoom();
UpdateFontSize();
RefreshZedGraph();
}
Expand Down
37 changes: 21 additions & 16 deletions OpenEphys.Onix1.Design/NeuropixelsV2eChannelConfigurationDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,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);

HighlightEnabledContacts();
UpdateContactLabels();
Expand All @@ -42,13 +42,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 @@ -57,8 +60,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 @@ -106,7 +107,7 @@ internal override void DrawScale()

internal override void HighlightEnabledContacts()
{
if (ProbeConfiguration == null || ProbeConfiguration.ChannelMap == null)
if (ProbeConfiguration == null)
return;

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

var channelMap = ProbeConfiguration.ChannelMap;

var contactsToEnable = contactObjects.Where(c =>
{
var tag = c.Tag as ContactTag;
var channel = NeuropixelsV2QuadShankElectrode.GetChannelNumber(tag.ContactIndex);
return ProbeConfiguration.ChannelMap[channel].Index == tag.ContactIndex;
var channel = NeuropixelsV2Electrode.GetChannelNumber(tag.ContactIndex, ProbeConfiguration.ProbeType);
return channelMap[channel].Index == tag.ContactIndex;
});

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

var channelMap = ProbeConfiguration.ChannelMap;

textObjsToUpdate = textObjs.Where(c =>
{
var tag = c.Tag as ContactTag;
var channel = NeuropixelsV2QuadShankElectrode.GetChannelNumber(tag.ContactIndex);
return ProbeConfiguration.ChannelMap[channel].Index == tag.ContactIndex;
var channel = NeuropixelsV2Electrode.GetChannelNumber(tag.ContactIndex, ProbeConfiguration.ProbeType);
return channelMap[channel].Index == tag.ContactIndex;
});

foreach (var textObj in textObjsToUpdate)
Expand All @@ -167,7 +172,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
Loading