Skip to content

Commit e37cac8

Browse files
authored
feat: Support 4 shank in Pathfinder, defaults to 1 (#608)
1 parent 7d7de94 commit e37cac8

File tree

4 files changed

+58
-14
lines changed

4 files changed

+58
-14
lines changed

Assets/Scripts/EphysLink/CommunicationManager.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,30 @@ public void GetAngles(string manipulatorId, Action<Vector3> onSuccessCallback,
310310
}).Emit("get_angles", manipulatorId);
311311
}
312312

313+
public void GetShankCount(string manipulatorId, Action<int> onSuccessCallback,
314+
Action<string> onErrorCallback = null)
315+
{
316+
_connectionManager.Socket.ExpectAcknowledgement<ShankCountCallbackParameters>(data =>
317+
{
318+
if (data.error == "")
319+
{
320+
try
321+
{
322+
onSuccessCallback?.Invoke(data.shank_count);
323+
}
324+
catch (Exception e)
325+
{
326+
onErrorCallback?.Invoke(e.ToString());
327+
}
328+
}
329+
else
330+
{
331+
onErrorCallback?.Invoke(data.error);
332+
Debug.LogWarning(data.error);
333+
}
334+
}).Emit("get_shank_count", manipulatorId);
335+
}
336+
313337
/// <summary>
314338
/// Request a manipulator be moved to a specific position.
315339
/// </summary>

Assets/Scripts/EphysLink/DataFormats.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,15 @@ public struct AngularCallbackParameters
130130
public string error;
131131
}
132132

133+
/// <summary>
134+
/// Returned callback data format from shank count data.
135+
/// </summary>
136+
public struct ShankCountCallbackParameters
137+
{
138+
public int shank_count;
139+
public string error;
140+
}
141+
133142
/// <summary>
134143
/// Returned callback data format from driving to depth.
135144
/// </summary>

Assets/Scripts/Pinpoint/UI/EphysLinkSettings/ManipulatorConnectionPanel.cs

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ public class ManipulatorConnectionPanel : MonoBehaviour
1414
{
1515
#region Constructor
1616

17-
public void Initialize(Pinpoint.UI.EphysLinkSettings.EphysLinkSettings settingsMenu, string manipulatorID, int numAxes)
17+
public void Initialize(Pinpoint.UI.EphysLinkSettings.EphysLinkSettings settingsMenu, string manipulatorID,
18+
int numAxes)
1819
{
1920
// Set properties
2021
_ephysLinkSettings = settingsMenu;
@@ -37,19 +38,29 @@ public void Initialize(Pinpoint.UI.EphysLinkSettings.EphysLinkSettings settingsM
3738
_probeConnectionGroup.SetActive(false);
3839
_probePropertiesSection.SetActive(false);
3940

40-
// Create new probe
41-
var trajectoryPlannerManager = FindObjectOfType<TrajectoryPlannerManager>();
42-
var newProbe = trajectoryPlannerManager.AddNewProbe(ProbeProperties.ProbeType.Neuropixels1);
43-
44-
// Configure probe and link to Ephys Link
45-
newProbe.ManipulatorBehaviorController.NumAxes = numAxes;
46-
newProbe.Color = Color.magenta;
47-
newProbe.name = "nsp_" + manipulatorID;
48-
newProbe.Saved = false;
49-
newProbe.SetIsEphysLinkControlled(true, manipulatorID);
41+
CommunicationManager.Instance.GetShankCount(manipulatorID, shankCount =>
42+
{
43+
// Use 2.4 if 4 shank, otherwise default to 1
44+
var probeType = shankCount == 4
45+
? ProbeProperties.ProbeType.Neuropixels24
46+
: ProbeProperties.ProbeType.Neuropixels1;
47+
48+
// Create new probe
49+
var trajectoryPlannerManager = FindObjectOfType<TrajectoryPlannerManager>();
50+
var newProbe = trajectoryPlannerManager.AddNewProbe(probeType);
51+
52+
// Configure probe and link to Ephys Link
53+
newProbe.ManipulatorBehaviorController.NumAxes = numAxes;
54+
newProbe.Color = Color.magenta;
55+
newProbe.name = "nsp_" + manipulatorID;
56+
newProbe.Saved = false;
57+
newProbe.SetIsEphysLinkControlled(true, manipulatorID);
58+
}, Debug.LogError);
59+
60+
// Exit (don't need to do anything else for Pathfinder)
5061
return;
5162
}
52-
63+
5364
// Restore or setup normal manipulator
5465

5566
UpdateLinkableProbeOptions();
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"Date": "12/11/2023 1:28:36 PM",
2+
"Date": "12/11/2023 3:35:16 PM",
33
"UnityVersion": "2022.3.12f1",
44
"com.unity.scriptablebuildpipeline": "1.21.20",
55
"com.unity.addressables": "1.21.18",
66
"traceEvents": [
7-
{"name": "Building Use Existing Build (requires built groups)", "ph": "X", "dur": 4203.7, "tid": 1, "ts": 1585, "pid": 1}
7+
{"name": "Building Use Existing Build (requires built groups)", "ph": "X", "dur": 6052.9, "tid": 1, "ts": 2179, "pid": 1}
88
]
99
}

0 commit comments

Comments
 (0)