Skip to content

Commit 73a504e

Browse files
committed
Add files to repo
1 parent 50ce550 commit 73a504e

File tree

5 files changed

+304
-0
lines changed

5 files changed

+304
-0
lines changed

LICENSE

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2024 Open Ephys and Contributors
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.8.34511.84
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenEphys.ProbeInterface", "OpenEphys.ProbeInterface\OpenEphys.ProbeInterface.csproj", "{822F3536-A4B7-4FE4-8332-A75A8458EE56}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{822F3536-A4B7-4FE4-8332-A75A8458EE56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{822F3536-A4B7-4FE4-8332-A75A8458EE56}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{822F3536-A4B7-4FE4-8332-A75A8458EE56}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{822F3536-A4B7-4FE4-8332-A75A8458EE56}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {F227E125-2232-46B7-9485-913F6D365AE6}
24+
EndGlobalSection
25+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<Title>OpenEphys.ProbeInterface</Title>
5+
<Authors>Open Ephys</Authors>
6+
<Copyright>Copyright © Open Ephys and Contributors 2024</Copyright>
7+
<TargetFramework>net472</TargetFramework>
8+
<Description>API based on Probe Interface specifications for parsing channel configurations</Description>
9+
<PackageTags>Bonsai Rx Open Ephys Onix</PackageTags>
10+
<VersionPrefix>0.1.0</VersionPrefix>
11+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
12+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
13+
<PackageOutputPath>..\bin\$(Configuration)</PackageOutputPath>
14+
<PackageProjectUrl></PackageProjectUrl>
15+
<IncludeSymbols Condition="'$(Configuration)'=='Release'">true</IncludeSymbols>
16+
<GeneratePackageOnBuild Condition="'$(Configuration)'=='Release'">true</GeneratePackageOnBuild>
17+
<RepositoryUrl></RepositoryUrl>
18+
<RepositoryType>git</RepositoryType>
19+
<PackageLicenseFile>LICENSE</PackageLicenseFile>
20+
<PackageIcon>icon.png</PackageIcon>
21+
<VersionSuffix></VersionSuffix>
22+
<LangVersion>10.0</LangVersion>
23+
<Nullable>enable</Nullable>
24+
</PropertyGroup>
25+
26+
<ItemGroup>
27+
<Content Include="..\..\LICENSE" PackagePath="/" />
28+
<Content Include="..\..\icon.png" PackagePath="/" />
29+
</ItemGroup>
30+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
namespace OpenEphys.ProbeInterface;
2+
3+
public class ProbeGroup
4+
{
5+
public string? Specification { get; set; }
6+
public string? Version { get; set; }
7+
public Probe[]? Probes { get; set; }
8+
9+
public ProbeGroup() { }
10+
11+
public ProbeGroup(string specification, string version, Probe[] probes)
12+
{
13+
Specification = specification;
14+
Version = version;
15+
Probes = probes;
16+
17+
ValidateContactIds();
18+
ValidateShankIds();
19+
ValidateDeviceChannelIndices();
20+
}
21+
22+
public ProbeGroup(ProbeGroup probeGroup)
23+
{
24+
Specification = probeGroup.Specification;
25+
Version = probeGroup.Version;
26+
Probes = probeGroup.Probes;
27+
}
28+
29+
public int NumContacts
30+
{
31+
get
32+
{
33+
int numContacts = 0;
34+
35+
foreach (var probe in Probes)
36+
{
37+
numContacts += probe.NumContacts;
38+
}
39+
40+
return numContacts;
41+
}
42+
}
43+
44+
public string[] GetContactIds()
45+
{
46+
string[] contactIds = new string[NumContacts];
47+
48+
var length = 0;
49+
50+
foreach (var probe in Probes)
51+
{
52+
probe.Contact_Ids.CopyTo(contactIds, length);
53+
length += probe.NumContacts;
54+
}
55+
56+
return contactIds;
57+
}
58+
59+
private void ValidateContactIds()
60+
{
61+
int contactNum = 0;
62+
63+
for (int i = 0; i < Probes.Length; i++)
64+
{
65+
if (Probes[i].Contact_Ids == null)
66+
{
67+
Probes[i].Contact_Ids = new string[Probes[i].Contact_Positions.Length];
68+
69+
for (int j = 0; j < Probes[i].Contact_Ids.Length; j++)
70+
{
71+
Probes[i].Contact_Ids[j] = contactNum.ToString();
72+
contactNum++;
73+
}
74+
}
75+
else
76+
contactNum += Probes[i].Contact_Ids.Length;
77+
}
78+
}
79+
80+
private void ValidateShankIds()
81+
{
82+
for (int i = 0; i < Probes.Length; i++)
83+
{
84+
if (Probes[i].Shank_Ids == null)
85+
{
86+
Probes[i].Shank_Ids = new string[Probes[i].Contact_Positions.Length];
87+
}
88+
}
89+
}
90+
91+
private void ValidateDeviceChannelIndices()
92+
{
93+
for (int i = 0; i < Probes.Length; i++)
94+
{
95+
if (Probes[i].Device_Channel_Indices == null)
96+
{
97+
Probes[i].Device_Channel_Indices = new uint[Probes[i].Contact_Ids.Length];
98+
99+
for (int j = 0; j < Probes[i].Device_Channel_Indices.Length; j++)
100+
{
101+
if (uint.TryParse(Probes[i].Contact_Ids[j], out uint result))
102+
{
103+
Probes[i].Device_Channel_Indices[j] = result;
104+
}
105+
}
106+
}
107+
}
108+
}
109+
}
110+
111+
public class Probe
112+
{
113+
public uint? Ndim { get; set; }
114+
public string? Si_Units { get; set; }
115+
public ProbeAnnotations? Annotations { get; set; }
116+
public ContactAnnotations? Contact_Annotations { get; set; }
117+
public float[][]? Contact_Positions { get; set; }
118+
public float[][][]? Contact_Plane_Axes { get; set; }
119+
public string[]? Contact_Shapes { get; set; }
120+
public ContactShapeParam[]? Contact_Shape_Params { get; set; }
121+
public float[][]? Probe_Planar_Contour { get; set; }
122+
public uint[]? Device_Channel_Indices { get; set; }
123+
public string[]? Contact_Ids { get; set; }
124+
public string[]? Shank_Ids { get; set; }
125+
126+
public Probe() { }
127+
128+
public Probe(uint ndim, string si_units, ProbeAnnotations annotations, ContactAnnotations contact_annotations,
129+
float[][] contact_positions, float[][][] contact_plane_axes, string[] contact_shapes,
130+
ContactShapeParam[] contact_shape_params, float[][] probe_planar_contour, uint[] device_channel_indices,
131+
string[] contact_ids, string[] shank_ids)
132+
{
133+
Ndim = ndim;
134+
Si_Units = si_units;
135+
Annotations = annotations;
136+
Contact_Annotations = contact_annotations;
137+
Contact_Positions = contact_positions;
138+
Contact_Plane_Axes = contact_plane_axes;
139+
Contact_Shapes = contact_shapes;
140+
Contact_Shape_Params = contact_shape_params;
141+
Probe_Planar_Contour = probe_planar_contour;
142+
Device_Channel_Indices = device_channel_indices;
143+
Contact_Ids = contact_ids;
144+
Shank_Ids = shank_ids;
145+
}
146+
147+
/// <summary>
148+
/// Returns a Contact object that contains the position, shape, shape params, and IDs (device / contact / shank)
149+
/// for a single contact at the given index
150+
/// </summary>
151+
/// <param name="index">Relative index of the contact in this Probe</param>
152+
/// <returns></returns>
153+
public Contact GetContact(int index)
154+
{
155+
return new Contact(Contact_Positions[index][0], Contact_Positions[index][1], Contact_Shapes[index], Contact_Shape_Params[index],
156+
Device_Channel_Indices[index], Contact_Ids[index], Shank_Ids[index]);
157+
}
158+
159+
public int NumContacts => Contact_Ids.Length;
160+
}
161+
162+
public struct Contact
163+
{
164+
public float PosX { get; set; }
165+
public float PosY { get; set; }
166+
public string Shape { get; set; }
167+
public ContactShapeParam ShapeParams { get; set; }
168+
public uint DeviceId { get; set; }
169+
public string ContactId { get; set; }
170+
public string ShankId { get; set; }
171+
172+
public Contact(float posX, float posY, string shape, ContactShapeParam shapeParam, uint device_id, string contact_id, string shank_id)
173+
{
174+
PosX = posX;
175+
PosY = posY;
176+
Shape = shape;
177+
ShapeParams = shapeParam;
178+
DeviceId = device_id;
179+
ContactId = contact_id;
180+
ShankId = shank_id;
181+
}
182+
}
183+
184+
public struct ContactShapeParam
185+
{
186+
public float Radius { get; set; }
187+
188+
public ContactShapeParam()
189+
{
190+
Radius = float.NaN;
191+
}
192+
193+
public ContactShapeParam(float radius)
194+
{
195+
Radius = radius;
196+
}
197+
}
198+
199+
public struct ProbeAnnotations
200+
{
201+
public string Name { get; set; }
202+
public string Manufacturer { get; set; }
203+
204+
public ProbeAnnotations()
205+
{
206+
Name = string.Empty;
207+
Manufacturer = string.Empty;
208+
}
209+
210+
public ProbeAnnotations(string name, string manufacturer)
211+
{
212+
Name = name;
213+
Manufacturer = manufacturer;
214+
}
215+
}
216+
217+
public struct ContactAnnotations
218+
{
219+
public string[] Contact_Annotations { get; set; }
220+
221+
public ContactAnnotations()
222+
{
223+
Contact_Annotations = new string[0];
224+
}
225+
226+
public ContactAnnotations(string[] contact_annotations)
227+
{
228+
Contact_Annotations = contact_annotations;
229+
}
230+
}

icon.png

12.2 KB
Loading

0 commit comments

Comments
 (0)