Skip to content

Commit 583a999

Browse files
committed
fix: working on a bugfix for spikeglx rotation issue
1 parent 61fd4fd commit 583a999

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

Assets/Scripts/Pinpoint/Probes/ProbeManager.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ public void UpdateChannelMap()
439439
/// Get a serialized representation of the depth information on each shank of this probe
440440
///
441441
/// SpikeGLX format
442-
/// [probe,shank]()
442+
/// [probe,shank](bottom um, top um, r, g, b, acronym)
443443
/// </summary>
444444
/// <returns>List of strings, each of which has data for one shank in the scene</returns>
445445
public List<string> GetProbeDepthIDs()
@@ -472,28 +472,29 @@ private string perShankDepthIDs(int shank)
472472

473473
ProbeUIManager uiManager = _probeUIManagers[shank];
474474

475-
Vector3 baseCoordWorldT = uiManager.ShankTipT().position;
476-
Vector3 topCoordWorldT = uiManager.ShankTipT().position - _probeController.ProbeTipT.forward * _channelMap.FullHeight;
475+
Transform electrodeBaseT = uiManager.ShankTipT();
476+
Vector3 baseCoordWorldT = electrodeBaseT.position;
477+
Vector3 topCoordWorldT = baseCoordWorldT - electrodeBaseT.forward * _channelMap.FullHeight;
477478
float height = _channelMap.FullHeight;
478479

479-
Vector3 baseCoordWorldU = BrainAtlasManager.WorldT2WorldU(baseCoordWorldT, false);
480-
Vector3 topCoordWorldU = BrainAtlasManager.WorldT2WorldU(topCoordWorldT, false);
481-
482-
// Lerp between the base and top coordinate in small steps'
480+
Vector3 baseCoordWorldU = BrainAtlasManager.WorldT2WorldU(baseCoordWorldT, true);
481+
Vector3 topCoordWorldU = BrainAtlasManager.WorldT2WorldU(topCoordWorldT, true);
483482

483+
// Lerp between the base and top coordinate in small steps
484484

485485
int lastID = BrainAtlasManager.ActiveReferenceAtlas.GetAnnotationIdx(BrainAtlasManager.ActiveReferenceAtlas.World2AtlasIdx(baseCoordWorldU));
486-
if (lastID < 0) lastID = -1;
486+
if (lastID < 0) lastID = 0;
487487

488488
float curBottom = 0f;
489-
float _channelMinUM = 0f; // _channelMinY * 1000f;
490489

491490
for (float perc = 0f; perc < 1f; perc += 0.01f)
492491
{
493492
Vector3 coordU = Vector3.Lerp(baseCoordWorldU, topCoordWorldU, perc);
494493

494+
Debug.Log(BrainAtlasManager.ActiveReferenceAtlas.World2AtlasIdx(coordU));
495495
int ID = BrainAtlasManager.ActiveReferenceAtlas.GetAnnotationIdx(BrainAtlasManager.ActiveReferenceAtlas.World2AtlasIdx(coordU));
496-
if (ID < 0) ID = -1;
496+
if (ID < 0) ID = 0;
497+
Debug.Log(ID);
497498

498499
if (Settings.UseBeryl)
499500
ID = BrainAtlasManager.ActiveReferenceAtlas.Ontology.RemapID_NoLayers(ID);
@@ -502,14 +503,14 @@ private string perShankDepthIDs(int shank)
502503
{
503504
// Save the current step
504505
float newHeight = perc * height * 1000f;
505-
probeAnnotationData.Add((Mathf.RoundToInt(curBottom + _channelMinUM), Mathf.RoundToInt(newHeight + _channelMinUM), BrainAtlasManager.ActiveReferenceAtlas.Ontology.ID2Acronym(ID), BrainAtlasManager.ActiveReferenceAtlas.Ontology.ID2Color(ID)));
506+
probeAnnotationData.Add((Mathf.RoundToInt(curBottom), Mathf.RoundToInt(newHeight), BrainAtlasManager.ActiveReferenceAtlas.Ontology.ID2Acronym(ID), BrainAtlasManager.ActiveReferenceAtlas.Ontology.ID2Color(ID)));
506507
curBottom = newHeight;
507508
lastID = ID;
508509
}
509510
}
510511

511512
// Save the final step
512-
probeAnnotationData.Add((Mathf.RoundToInt(curBottom + _channelMinUM), Mathf.RoundToInt(height * 1000 + _channelMinUM), BrainAtlasManager.ActiveReferenceAtlas.Ontology.ID2Acronym(lastID), BrainAtlasManager.ActiveReferenceAtlas.Ontology.ID2Color(lastID)));
513+
probeAnnotationData.Add((Mathf.RoundToInt(curBottom), Mathf.RoundToInt(height * 1000), BrainAtlasManager.ActiveReferenceAtlas.Ontology.ID2Acronym(lastID), BrainAtlasManager.ActiveReferenceAtlas.Ontology.ID2Color(lastID)));
513514

514515
// Flatten the list data according to the SpikeGLX format
515516
// [probe, shank](startpos, endpos, r, g, b, name)
@@ -556,7 +557,7 @@ public string GetChannelAnnotationIDs(bool collapsed = true)
556557
Vector3 channelCoordWorldT = shankTipCoordWorldT - _probeController.ProbeTipT.forward * channelMapData[i].y / 1000f;
557558

558559
// Now transform this into WorldU
559-
Vector3 channelCoordWorldU = BrainAtlasManager.WorldT2WorldU(channelCoordWorldT, false);
560+
Vector3 channelCoordWorldU = BrainAtlasManager.WorldT2WorldU(channelCoordWorldT, true);
560561

561562
int elecIdx = si * channelMapData.Count + i;
562563
int ID = BrainAtlasManager.ActiveReferenceAtlas.GetAnnotationIdx(BrainAtlasManager.ActiveReferenceAtlas.World2AtlasIdx(channelCoordWorldU));

0 commit comments

Comments
 (0)