Skip to content

Commit e389ff6

Browse files
committed
Fix: drive depth incorrect when brain is scaled
1 parent e1ba9e7 commit e389ff6

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Assets/Scripts/Pinpoint/UI/EphysCopilot/DrivePanelHandler.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,15 @@ private float _targetDriveDistance
278278
var offsetAdjustedTargetPositionWorldT =
279279
targetPositionWorldT + offsetAdjustedRelativeTargetPositionWorldT;
280280

281-
// Converting worldT back to APMLDV (position transformed)
282-
targetInsertion.APMLDV = targetInsertion.World2T(
283-
offsetAdjustedTargetPositionWorldT
284-
);
285-
281+
// Converting worldT to AtlasT (to capture new Bregma offset when there is scaling)
282+
// then switch axes to get APMLDV.
283+
var offsetAdjustedTargetPositionAtlasT =
284+
BrainAtlasManager.ActiveReferenceAtlas.World2Atlas(offsetAdjustedTargetPositionWorldT);
285+
var offsetAdjustedTargetPositionCoordinateT =
286+
BrainAtlasManager.ActiveAtlasTransform.U2T_Vector(offsetAdjustedTargetPositionAtlasT);
287+
targetInsertion.APMLDV = offsetAdjustedTargetPositionCoordinateT;
288+
289+
// Compute target drive distance.
286290
return Vector3.Distance(targetInsertion.APMLDV, DuraApmldv);
287291
}
288292
}

0 commit comments

Comments
 (0)