Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only export ProbeInterface contact annotations if they exist #368

Merged
merged 1 commit into from
Nov 8, 2024
Merged
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
7 changes: 6 additions & 1 deletion OpenEphys.Onix1.Design/DesignHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion OpenEphys.Onix1.Design/OpenEphys.Onix1.Design.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PackageReference Include="Bonsai.Design" Version="2.8.5" />
<PackageReference Include="Bonsai.Design.Visualizers" Version="2.8.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="OpenEphys.ProbeInterface.NET" Version="0.1.1" />
<PackageReference Include="OpenEphys.ProbeInterface.NET" Version="0.2.0" />
<PackageReference Include="ZedGraph" Version="5.1.7" />
</ItemGroup>

Expand Down
37 changes: 21 additions & 16 deletions OpenEphys.Onix1/NeuropixelsV1eProbeGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,30 @@ public class NeuropixelsV1eProbeGroup : ProbeGroup
/// Initializes a new instance of the <see cref="NeuropixelsV1eProbeGroup"/> class.
/// </summary>
public NeuropixelsV1eProbeGroup()
: base("probeinterface", "0.2.21",
new List<Probe>()
{
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;
}

/// <summary>
/// Initializes a new instance of the <see cref="NeuropixelsV1eProbeGroup"/> class.
/// </summary>
Expand Down
37 changes: 21 additions & 16 deletions OpenEphys.Onix1/NeuropixelsV2eProbeGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,30 @@ public class NeuropixelsV2eProbeGroup : ProbeGroup
/// the default settings for all contacts, including their positions, shapes, and IDs.
/// </remarks>
public NeuropixelsV2eProbeGroup()
: base("probeinterface", "0.2.21",
new List<Probe>()
{
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;
}

/// <summary>
/// Initializes a new instance of the <see cref="NeuropixelsV2eProbeGroup"/> class.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion OpenEphys.Onix1/OpenEphys.Onix1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
<PackageReference Include="Bonsai.Core" Version="2.8.5" />
<PackageReference Include="clroni" Version="6.1.2" />
<PackageReference Include="OpenCV.Net" Version="3.4.2" />
<PackageReference Include="OpenEphys.ProbeInterface.NET" Version="0.1.1" />
<PackageReference Include="OpenEphys.ProbeInterface.NET" Version="0.2.0" />
</ItemGroup>
</Project>
64 changes: 34 additions & 30 deletions OpenEphys.Onix1/Rhs2116ProbeGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,41 @@ public class Rhs2116ProbeGroup : ProbeGroup
/// the default settings for two probes, including the contact positions, shapes, and IDs.
/// </remarks>
public Rhs2116ProbeGroup()
: base("probeinterface", "0.2.21",
new List<Probe>()
{
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;
}

/// <summary>
Expand Down