diff --git a/OpenEphys.Onix1.Design/DesignHelper.cs b/OpenEphys.Onix1.Design/DesignHelper.cs index 5ce05a2..e87e3ba 100644 --- a/OpenEphys.Onix1.Design/DesignHelper.cs +++ b/OpenEphys.Onix1.Design/DesignHelper.cs @@ -50,7 +50,12 @@ static class DesignHelper public static void SerializeObject(object _object, string filepath) { - var stringJson = JsonConvert.SerializeObject(_object, Formatting.Indented); + var serializerSettings = new JsonSerializerSettings() + { + NullValueHandling = NullValueHandling.Ignore, + }; + + var stringJson = JsonConvert.SerializeObject(_object, Formatting.Indented, serializerSettings); File.WriteAllText(filepath, stringJson); } diff --git a/OpenEphys.Onix1.Design/OpenEphys.Onix1.Design.csproj b/OpenEphys.Onix1.Design/OpenEphys.Onix1.Design.csproj index f76a4a7..4859e23 100644 --- a/OpenEphys.Onix1.Design/OpenEphys.Onix1.Design.csproj +++ b/OpenEphys.Onix1.Design/OpenEphys.Onix1.Design.csproj @@ -15,7 +15,7 @@ - + diff --git a/OpenEphys.Onix1/NeuropixelsV1eProbeGroup.cs b/OpenEphys.Onix1/NeuropixelsV1eProbeGroup.cs index 83bb4aa..d0276bc 100644 --- a/OpenEphys.Onix1/NeuropixelsV1eProbeGroup.cs +++ b/OpenEphys.Onix1/NeuropixelsV1eProbeGroup.cs @@ -15,25 +15,30 @@ public class NeuropixelsV1eProbeGroup : ProbeGroup /// Initializes a new instance of the class. /// public NeuropixelsV1eProbeGroup() - : base("probeinterface", "0.2.21", - new List() - { - new(ProbeNdim.Two, - ProbeSiUnits.um, - new ProbeAnnotations("Neuropixels 1.0", "IMEC"), - new ContactAnnotations(new string[0]), - DefaultContactPositions(NeuropixelsV1.ElectrodeCount), - Probe.DefaultContactPlaneAxes(NeuropixelsV1.ElectrodeCount), - Probe.DefaultContactShapes(NeuropixelsV1.ElectrodeCount, ContactShape.Square), - Probe.DefaultSquareParams(NeuropixelsV1.ElectrodeCount, 12.0f), - DefaultProbePlanarContour(), - DefaultDeviceChannelIndices(NeuropixelsV1.ChannelCount, NeuropixelsV1.ElectrodeCount), - Probe.DefaultContactIds(NeuropixelsV1.ElectrodeCount), - DefaultShankIds(NeuropixelsV1.ElectrodeCount)) - }.ToArray()) + : base("probeinterface", "0.2.21", DefaultProbes()) { } + private static Probe[] DefaultProbes() + { + var probe = new Probe[1]; + + probe[0] = new(ProbeNdim.Two, + ProbeSiUnits.um, + new ProbeAnnotations("Neuropixels 1.0", "IMEC"), + null, + DefaultContactPositions(NeuropixelsV1.ElectrodeCount), + Probe.DefaultContactPlaneAxes(NeuropixelsV1.ElectrodeCount), + Probe.DefaultContactShapes(NeuropixelsV1.ElectrodeCount, ContactShape.Square), + Probe.DefaultSquareParams(NeuropixelsV1.ElectrodeCount, 12.0f), + DefaultProbePlanarContour(), + DefaultDeviceChannelIndices(NeuropixelsV1.ChannelCount, NeuropixelsV1.ElectrodeCount), + Probe.DefaultContactIds(NeuropixelsV1.ElectrodeCount), + DefaultShankIds(NeuropixelsV1.ElectrodeCount)); + + return probe; + } + /// /// Initializes a new instance of the class. /// diff --git a/OpenEphys.Onix1/NeuropixelsV2eProbeGroup.cs b/OpenEphys.Onix1/NeuropixelsV2eProbeGroup.cs index 4e3f4bd..058e790 100644 --- a/OpenEphys.Onix1/NeuropixelsV2eProbeGroup.cs +++ b/OpenEphys.Onix1/NeuropixelsV2eProbeGroup.cs @@ -24,25 +24,30 @@ public class NeuropixelsV2eProbeGroup : ProbeGroup /// the default settings for all contacts, including their positions, shapes, and IDs. /// public NeuropixelsV2eProbeGroup() - : base("probeinterface", "0.2.21", - new List() - { - new(ProbeNdim.Two, - ProbeSiUnits.um, - new ProbeAnnotations("Neuropixels 2.0 - Multishank", "IMEC"), - new ContactAnnotations(new string[0]), - DefaultContactPositions(NeuropixelsV2.ElectrodePerShank * numberOfShanks), - Probe.DefaultContactPlaneAxes(NeuropixelsV2.ElectrodePerShank * numberOfShanks), - Probe.DefaultContactShapes(NeuropixelsV2.ElectrodePerShank * numberOfShanks, ContactShape.Square), - Probe.DefaultSquareParams(NeuropixelsV2.ElectrodePerShank * numberOfShanks, 12.0f), - DefaultProbePlanarContourQuadShank(), - DefaultDeviceChannelIndices(NeuropixelsV2.ChannelCount, NeuropixelsV2.ElectrodePerShank * numberOfShanks), - Probe.DefaultContactIds(NeuropixelsV2.ElectrodePerShank * numberOfShanks), - DefaultShankIds(NeuropixelsV2.ElectrodePerShank * numberOfShanks)) - }) + : base("probeinterface", "0.2.21", DefaultProbes()) { } + private static Probe[] DefaultProbes() + { + var probe = new Probe[1]; + + probe[0] = new(ProbeNdim.Two, + ProbeSiUnits.um, + new ProbeAnnotations("Neuropixels 2.0 - Multishank", "IMEC"), + null, + DefaultContactPositions(NeuropixelsV2.ElectrodePerShank * numberOfShanks), + Probe.DefaultContactPlaneAxes(NeuropixelsV2.ElectrodePerShank * numberOfShanks), + Probe.DefaultContactShapes(NeuropixelsV2.ElectrodePerShank * numberOfShanks, ContactShape.Square), + Probe.DefaultSquareParams(NeuropixelsV2.ElectrodePerShank * numberOfShanks, 12.0f), + DefaultProbePlanarContourQuadShank(), + DefaultDeviceChannelIndices(NeuropixelsV2.ChannelCount, NeuropixelsV2.ElectrodePerShank * numberOfShanks), + Probe.DefaultContactIds(NeuropixelsV2.ElectrodePerShank * numberOfShanks), + DefaultShankIds(NeuropixelsV2.ElectrodePerShank * numberOfShanks)); + + return probe; + } + /// /// Initializes a new instance of the class. /// diff --git a/OpenEphys.Onix1/OpenEphys.Onix1.csproj b/OpenEphys.Onix1/OpenEphys.Onix1.csproj index d790a5c..a807b8e 100644 --- a/OpenEphys.Onix1/OpenEphys.Onix1.csproj +++ b/OpenEphys.Onix1/OpenEphys.Onix1.csproj @@ -13,6 +13,6 @@ - + diff --git a/OpenEphys.Onix1/Rhs2116ProbeGroup.cs b/OpenEphys.Onix1/Rhs2116ProbeGroup.cs index 2d46d4b..160e7a3 100644 --- a/OpenEphys.Onix1/Rhs2116ProbeGroup.cs +++ b/OpenEphys.Onix1/Rhs2116ProbeGroup.cs @@ -20,37 +20,41 @@ public class Rhs2116ProbeGroup : ProbeGroup /// the default settings for two probes, including the contact positions, shapes, and IDs. /// public Rhs2116ProbeGroup() - : base("probeinterface", "0.2.21", - new List() - { - new( - ProbeNdim.Two, - ProbeSiUnits.mm, - new ProbeAnnotations("Rhs2116A", ""), - new ContactAnnotations(new string[0]), - DefaultContactPositions(DefaultNumberOfChannelsPerProbe, 0), - Probe.DefaultContactPlaneAxes(DefaultNumberOfChannelsPerProbe), - Probe.DefaultContactShapes(DefaultNumberOfChannelsPerProbe, ContactShape.Circle), - Probe.DefaultCircleParams(DefaultNumberOfChannelsPerProbe, 0.3f), - DefaultProbePlanarContour(0), - Probe.DefaultDeviceChannelIndices(DefaultNumberOfChannelsPerProbe, 0), - Probe.DefaultContactIds(DefaultNumberOfChannelsPerProbe), - Probe.DefaultShankIds(DefaultNumberOfChannelsPerProbe)), - new( - ProbeNdim.Two, - ProbeSiUnits.mm, - new ProbeAnnotations("Rhs2116B", ""), - new ContactAnnotations(new string[0]), - DefaultContactPositions(DefaultNumberOfChannelsPerProbe, 1), - Probe.DefaultContactPlaneAxes(DefaultNumberOfChannelsPerProbe), - Probe.DefaultContactShapes(DefaultNumberOfChannelsPerProbe, ContactShape.Circle), - Probe.DefaultCircleParams(DefaultNumberOfChannelsPerProbe, 0.3f), - DefaultProbePlanarContour(1), - Probe.DefaultDeviceChannelIndices(DefaultNumberOfChannelsPerProbe, DefaultNumberOfChannelsPerProbe), - Probe.DefaultContactIds(DefaultNumberOfChannelsPerProbe), - Probe.DefaultShankIds(DefaultNumberOfChannelsPerProbe)) - }.ToArray()) + : base("probeinterface", "0.2.21", DefaultProbes()) + { + } + + private static Probe[] DefaultProbes() { + var probe = new Probe[2]; + + probe[0] = new(ProbeNdim.Two, + ProbeSiUnits.mm, + new ProbeAnnotations("Rhs2116A", ""), + null, + DefaultContactPositions(DefaultNumberOfChannelsPerProbe, 0), + Probe.DefaultContactPlaneAxes(DefaultNumberOfChannelsPerProbe), + Probe.DefaultContactShapes(DefaultNumberOfChannelsPerProbe, ContactShape.Circle), + Probe.DefaultCircleParams(DefaultNumberOfChannelsPerProbe, 0.3f), + DefaultProbePlanarContour(0), + Probe.DefaultDeviceChannelIndices(DefaultNumberOfChannelsPerProbe, 0), + Probe.DefaultContactIds(DefaultNumberOfChannelsPerProbe), + Probe.DefaultShankIds(DefaultNumberOfChannelsPerProbe)); + + probe[1] = new(ProbeNdim.Two, + ProbeSiUnits.mm, + new ProbeAnnotations("Rhs2116B", ""), + null, + DefaultContactPositions(DefaultNumberOfChannelsPerProbe, 1), + Probe.DefaultContactPlaneAxes(DefaultNumberOfChannelsPerProbe), + Probe.DefaultContactShapes(DefaultNumberOfChannelsPerProbe, ContactShape.Circle), + Probe.DefaultCircleParams(DefaultNumberOfChannelsPerProbe, 0.3f), + DefaultProbePlanarContour(1), + Probe.DefaultDeviceChannelIndices(DefaultNumberOfChannelsPerProbe, DefaultNumberOfChannelsPerProbe), + Probe.DefaultContactIds(DefaultNumberOfChannelsPerProbe), + Probe.DefaultShankIds(DefaultNumberOfChannelsPerProbe)); + + return probe; } ///