Skip to content

Commit ccfb833

Browse files
committed
Refactor probe configuration properties for serialization and backward compatibility
1 parent c41fd25 commit ccfb833

File tree

6 files changed

+146
-9
lines changed

6 files changed

+146
-9
lines changed

OpenEphys.Onix1.Design/NeuropixelsV2eProbeConfigurationDialog.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,18 @@ public NeuropixelsV2eProbeConfigurationDialog(NeuropixelsV2ProbeConfiguration co
6060
{
6161
[ProbeType.SingleShank] = configuration is NeuropixelsV2SingleShankProbeConfiguration
6262
? configuration.Clone()
63-
: new NeuropixelsV2SingleShankProbeConfiguration(configuration.Probe, NeuropixelsV2SingleShankReference.External),
63+
: new NeuropixelsV2SingleShankProbeConfiguration(configuration.Probe,
64+
NeuropixelsV2SingleShankReference.External,
65+
configuration.InvertPolarity,
66+
configuration.GainCalibrationFileName,
67+
configuration.ProbeInterfaceFileName),
6468
[ProbeType.QuadShank] = configuration is NeuropixelsV2QuadShankProbeConfiguration
6569
? configuration.Clone()
66-
: new NeuropixelsV2QuadShankProbeConfiguration(configuration.Probe, NeuropixelsV2QuadShankReference.External)
70+
: new NeuropixelsV2QuadShankProbeConfiguration(configuration.Probe,
71+
NeuropixelsV2QuadShankReference.External,
72+
configuration.InvertPolarity,
73+
configuration.GainCalibrationFileName,
74+
configuration.ProbeInterfaceFileName)
6775
};
6876

6977
var currentProbeType = GetCurrentProbeType(configuration);

OpenEphys.Onix1/ConfigureNeuropixelsV2e.cs

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,17 @@ public bool ShouldSerializeInvertPolarity()
7878
[Category(ConfigurationCategory)]
7979
[Description("Probe A configuration.")]
8080
[Editor("OpenEphys.Onix1.Design.NeuropixelsV2eProbeConfigurationEditor, OpenEphys.Onix1.Design", typeof(UITypeEditor))]
81-
[XmlElement(nameof(ProbeConfigurationA), typeof(NeuropixelsV2QuadShankProbeConfiguration))]
81+
[XmlElement(nameof(ProbeConfigurationA), typeof(NeuropixelsV2QuadShankProbeConfiguration))] // NB: Needed for backward compatibility
8282
[TypeConverter(typeof(GenericPropertyConverter))]
8383
public NeuropixelsV2ProbeConfiguration ProbeConfigurationA { get; set; } = new NeuropixelsV2QuadShankProbeConfiguration(NeuropixelsV2Probe.ProbeA, NeuropixelsV2QuadShankReference.External);
8484

85+
/// <summary>
86+
/// Prevent the <see cref="ProbeConfigurationA"/> property from being serialized.
87+
/// </summary>
88+
/// <returns>False</returns>
89+
[Obsolete]
90+
public bool ShouldSerializeProbeConfigurationA() => false;
91+
8592
/// <summary>
8693
/// Gets or sets the path to the gain calibration file for this probe.
8794
/// </summary>
@@ -105,15 +112,36 @@ public bool ShouldSerializeGainCalibrationFileA()
105112
{
106113
return false;
107114
}
115+
116+
/// <summary>
117+
/// Gets or sets the <see cref="ProbeConfigurationA"/> property.
118+
/// </summary>
119+
/// <remarks>
120+
/// [Obsolete]. Cannot tag this property with the Obsolete attribute due to https://github.com/dotnet/runtime/issues/100453
121+
/// </remarks>
122+
[Browsable(false)]
123+
[Externalizable(false)]
124+
public NeuropixelsV2ProbeConfiguration ConfigurationA
125+
{
126+
get => ProbeConfigurationA;
127+
set => ProbeConfigurationA = value;
128+
}
108129

109130
/// <inheritdoc/>
110131
[Category(ConfigurationCategory)]
111132
[Description("Probe B configuration.")]
112133
[Editor("OpenEphys.Onix1.Design.NeuropixelsV2eProbeConfigurationEditor, OpenEphys.Onix1.Design", typeof(UITypeEditor))]
113-
[XmlElement(nameof(ProbeConfigurationB), typeof(NeuropixelsV2QuadShankProbeConfiguration))]
134+
[XmlElement(nameof(ProbeConfigurationB), typeof(NeuropixelsV2QuadShankProbeConfiguration))] // NB: Needed for backward compatibility
114135
[TypeConverter(typeof(GenericPropertyConverter))]
115136
public NeuropixelsV2ProbeConfiguration ProbeConfigurationB { get; set; } = new NeuropixelsV2QuadShankProbeConfiguration(NeuropixelsV2Probe.ProbeB, NeuropixelsV2QuadShankReference.External);
116137

138+
/// <summary>
139+
/// Prevent the <see cref="ProbeConfigurationB"/> property from being serialized.
140+
/// </summary>
141+
/// <returns>False</returns>
142+
[Obsolete]
143+
public bool ShouldSerializeProbeConfigurationB() => false;
144+
117145
/// <summary>
118146
/// Gets or sets the path to the gain calibration file for this probe.
119147
/// </summary>
@@ -138,6 +166,20 @@ public bool ShouldSerializeGainCalibrationFileB()
138166
return false;
139167
}
140168

169+
/// <summary>
170+
/// Gets or sets the <see cref="ProbeConfigurationB"/> property.
171+
/// </summary>
172+
/// <remarks>
173+
/// [Obsolete]. Cannot tag this property with the Obsolete attribute due to https://github.com/dotnet/runtime/issues/100453
174+
/// </remarks>
175+
[Browsable(false)]
176+
[Externalizable(false)]
177+
public NeuropixelsV2ProbeConfiguration ConfigurationB
178+
{
179+
get => ProbeConfigurationB;
180+
set => ProbeConfigurationB = value;
181+
}
182+
141183
/// <summary>
142184
/// Configures a NeuropixelsV2e device.
143185
/// </summary>

OpenEphys.Onix1/ConfigureNeuropixelsV2eBeta.cs

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,17 @@ public bool ShouldSerializeInvertPolarity()
9393
[Category(ConfigurationCategory)]
9494
[Description("Probe A configuration.")]
9595
[Editor("OpenEphys.Onix1.Design.NeuropixelsV2eProbeConfigurationEditor, OpenEphys.Onix1.Design", typeof(UITypeEditor))]
96-
[XmlElement(nameof(ProbeConfigurationA), typeof(NeuropixelsV2QuadShankProbeConfiguration))]
96+
[XmlElement(nameof(ProbeConfigurationA), typeof(NeuropixelsV2QuadShankProbeConfiguration))] // NB: Needed for backward compatibility
9797
[TypeConverter(typeof(GenericPropertyConverter))]
9898
public NeuropixelsV2ProbeConfiguration ProbeConfigurationA { get; set; } = new NeuropixelsV2QuadShankProbeConfiguration(NeuropixelsV2Probe.ProbeA, NeuropixelsV2QuadShankReference.External);
9999

100+
/// <summary>
101+
/// Prevent the <see cref="ProbeConfigurationA"/> property from being serialized.
102+
/// </summary>
103+
/// <returns>False</returns>
104+
[Obsolete]
105+
public bool ShouldSerializeProbeConfigurationA() => false;
106+
100107
/// <summary>
101108
/// Gets or sets the path to the gain calibration file for this probe.
102109
/// </summary>
@@ -121,14 +128,35 @@ public bool ShouldSerializeGainCalibrationFileA()
121128
return false;
122129
}
123130

131+
/// <summary>
132+
/// Gets or sets the <see cref="ProbeConfigurationA"/> property.
133+
/// </summary>
134+
/// <remarks>
135+
/// [Obsolete]. Cannot tag this property with the Obsolete attribute due to https://github.com/dotnet/runtime/issues/100453
136+
/// </remarks>
137+
[Browsable(false)]
138+
[Externalizable(false)]
139+
public NeuropixelsV2ProbeConfiguration ConfigurationA
140+
{
141+
get => ProbeConfigurationA;
142+
set => ProbeConfigurationA = value;
143+
}
144+
124145
/// <inheritdoc/>
125146
[Category(ConfigurationCategory)]
126147
[Description("Probe B configuration.")]
127148
[Editor("OpenEphys.Onix1.Design.NeuropixelsV2eProbeConfigurationEditor, OpenEphys.Onix1.Design", typeof(UITypeEditor))]
128-
[XmlElement(nameof(ProbeConfigurationB), typeof(NeuropixelsV2QuadShankProbeConfiguration))]
149+
[XmlElement(nameof(ProbeConfigurationB), typeof(NeuropixelsV2QuadShankProbeConfiguration))] // NB: Needed for backward compatibility
129150
[TypeConverter(typeof(GenericPropertyConverter))]
130151
public NeuropixelsV2ProbeConfiguration ProbeConfigurationB { get; set; } = new NeuropixelsV2QuadShankProbeConfiguration(NeuropixelsV2Probe.ProbeB, NeuropixelsV2QuadShankReference.External);
131152

153+
/// <summary>
154+
/// Prevent the <see cref="ProbeConfigurationB"/> property from being serialized.
155+
/// </summary>
156+
/// <returns>False</returns>
157+
[Obsolete]
158+
public bool ShouldSerializeProbeConfigurationB() => false;
159+
132160
/// <summary>
133161
/// Gets or sets the path to the gain calibration file for this probe.
134162
/// </summary>
@@ -153,6 +181,20 @@ public bool ShouldSerializeGainCalibrationFileB()
153181
return false;
154182
}
155183

184+
/// <summary>
185+
/// Gets or sets the <see cref="ProbeConfigurationB"/> property.
186+
/// </summary>
187+
/// <remarks>
188+
/// [Obsolete]. Cannot tag this property with the Obsolete attribute due to https://github.com/dotnet/runtime/issues/100453
189+
/// </remarks>
190+
[Browsable(false)]
191+
[Externalizable(false)]
192+
public NeuropixelsV2ProbeConfiguration ConfigurationB
193+
{
194+
get => ProbeConfigurationB;
195+
set => ProbeConfigurationB = value;
196+
}
197+
156198
/// <summary>
157199
/// Configures a NeuropixelsV2eBeta device.
158200
/// </summary>

OpenEphys.Onix1/NeuropixelsV2ProbeConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public abstract class NeuropixelsV2ProbeConfiguration
8686
/// </remarks>
8787
[Category(DeviceFactory.ConfigurationCategory)]
8888
[FileNameFilter("Gain calibration files (*_gainCalValues.csv)|*_gainCalValues.csv")]
89-
[Description("Path to the gain calibration file for probe A.")]
89+
[Description("Path to the gain calibration file for this probe.")]
9090
[Editor("Bonsai.Design.OpenFileNameEditor, Bonsai.Design", DesignTypes.UITypeEditor)]
9191
public string GainCalibrationFileName { get; set; }
9292

OpenEphys.Onix1/NeuropixelsV2QuadShankProbeConfiguration.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public enum NeuropixelsV2QuadShankReference : uint
4747
[XmlType(TypeName = XmlTypeName, Namespace = Constants.XmlNamespace)]
4848
public class NeuropixelsV2QuadShankProbeConfiguration : NeuropixelsV2ProbeConfiguration
4949
{
50-
internal const string XmlTypeName = "QuadShank";
50+
internal const string XmlTypeName = nameof(NeuropixelsV2QuadShankProbeConfiguration);
5151

5252
/// <summary>
5353
/// Initializes a default instance of the <see cref="NeuropixelsV2QuadShankProbeConfiguration"/> class.
@@ -82,6 +82,29 @@ public NeuropixelsV2QuadShankProbeConfiguration(NeuropixelsV2QuadShankProbeConfi
8282
probeInterfaceFileName = probeConfiguration.probeInterfaceFileName;
8383
}
8484

85+
/// <summary>
86+
/// Initializes a new instance of the <see cref="NeuropixelsV2QuadShankProbeConfiguration"/> class with the given
87+
/// values.
88+
/// </summary>
89+
/// <param name="probe">The <see cref="NeuropixelsV2Probe"/> for this probe.</param>
90+
/// <param name="reference">The <see cref="NeuropixelsV2QuadShankReference"/> reference value.</param>
91+
/// <param name="invertPolarity">Boolean defining if the signal polarity should be inverted.</param>
92+
/// <param name="gainCalibrationFileName">String defining the path to the gain calibration file.</param>
93+
/// <param name="probeInterfaceFileName">String defining the path to the ProbeInterface file.</param>
94+
public NeuropixelsV2QuadShankProbeConfiguration(
95+
NeuropixelsV2Probe probe,
96+
NeuropixelsV2QuadShankReference reference,
97+
bool invertPolarity,
98+
string gainCalibrationFileName,
99+
string probeInterfaceFileName)
100+
{
101+
Probe = probe;
102+
Reference = reference;
103+
InvertPolarity = invertPolarity;
104+
GainCalibrationFileName = gainCalibrationFileName;
105+
ProbeInterfaceFileName = probeInterfaceFileName;
106+
}
107+
85108
/// <summary>
86109
/// Initializes a new instance of the <see cref="NeuropixelsV2QuadShankProbeConfiguration"/> class with the given
87110
/// <see cref="NeuropixelsV2eQuadShankProbeGroup"/> channel configuration.

OpenEphys.Onix1/NeuropixelsV2SingleShankProbeConfiguration.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public enum NeuropixelsV2SingleShankReference : uint
3535
[XmlType(TypeName = XmlTypeName, Namespace = Constants.XmlNamespace)]
3636
public class NeuropixelsV2SingleShankProbeConfiguration : NeuropixelsV2ProbeConfiguration
3737
{
38-
internal const string XmlTypeName = "SingleShank";
38+
internal const string XmlTypeName = nameof(NeuropixelsV2SingleShankProbeConfiguration);
3939

4040
/// <summary>
4141
/// Initializes a default instance of the <see cref="NeuropixelsV2SingleShankProbeConfiguration"/> class.
@@ -68,6 +68,28 @@ public NeuropixelsV2SingleShankProbeConfiguration(NeuropixelsV2SingleShankProbeC
6868
probeInterfaceFileName = probeConfiguration.probeInterfaceFileName;
6969
}
7070

71+
/// <summary>
72+
/// Initializes a new instance of the <see cref="NeuropixelsV2SingleShankProbeConfiguration"/> class with the given
73+
/// values.
74+
/// </summary>
75+
/// <param name="reference">The <see cref="NeuropixelsV2SingleShankReference"/> reference value.</param>
76+
/// <param name="probe">The <see cref="NeuropixelsV2Probe"/> for this probe.</param>
77+
/// <param name="invertPolarity">Boolean defining if the signal polarity should be inverted.</param>
78+
/// <param name="gainCalibrationFileName">String defining the path to the gain calibration file.</param>
79+
/// <param name="probeInterfaceFileName">String defining the path to the ProbeInterface file.</param>
80+
public NeuropixelsV2SingleShankProbeConfiguration(NeuropixelsV2Probe probe,
81+
NeuropixelsV2SingleShankReference reference,
82+
bool invertPolarity,
83+
string gainCalibrationFileName,
84+
string probeInterfaceFileName)
85+
{
86+
Probe = probe;
87+
Reference = reference;
88+
InvertPolarity = invertPolarity;
89+
GainCalibrationFileName = gainCalibrationFileName;
90+
ProbeInterfaceFileName = probeInterfaceFileName;
91+
}
92+
7193
/// <summary>
7294
/// Initializes a new instance of the <see cref="NeuropixelsV2SingleShankProbeConfiguration"/> class with the given
7395
/// <see cref="NeuropixelsV2eSingleShankProbeGroup"/> channel configuration.

0 commit comments

Comments
 (0)