|
6 | 6 | using EphysLink; |
7 | 7 | using UnityEngine; |
8 | 8 | using UnityEngine.Events; |
| 9 | +using Urchin.Utils; |
9 | 10 |
|
10 | 11 | namespace TrajectoryPlanner.Probes |
11 | 12 | { |
@@ -272,20 +273,19 @@ void StartEchoing() |
272 | 273 |
|
273 | 274 | public void UpdateSpaceAndTransform() |
274 | 275 | { |
275 | | - throw new NotImplementedException(); |
276 | | - //if (ManipulatorType == "sensapex") |
277 | | - //{ |
278 | | - // CoordinateSpace = new SensapexSpace(); |
279 | | - // Transform = IsRightHanded |
280 | | - // ? new SensapexRightTransform(_probeController.Insertion.Yaw) |
281 | | - // : new SensapexLeftTransform(_probeController.Insertion.Yaw); |
282 | | - //} |
283 | | - //else |
284 | | - //{ |
285 | | - // CoordinateSpace = new NewScaleSpace(); |
286 | | - // Transform = new NewScaleLeftTransform(_probeController.Insertion.Yaw, |
287 | | - // _probeController.Insertion.Pitch); |
288 | | - //} |
| 276 | + if (ManipulatorType == "sensapex") |
| 277 | + { |
| 278 | + ReferenceAtlas = new SensapexSpace(); |
| 279 | + AtlasTransform = IsRightHanded |
| 280 | + ? new SensapexRightTransform(_probeController.Insertion.Yaw) |
| 281 | + : new SensapexLeftTransform(_probeController.Insertion.Yaw); |
| 282 | + } |
| 283 | + else |
| 284 | + { |
| 285 | + ReferenceAtlas = new NewScaleSpace(); |
| 286 | + AtlasTransform = new NewScaleLeftTransform(_probeController.Insertion.Yaw, |
| 287 | + _probeController.Insertion.Pitch); |
| 288 | + } |
289 | 289 | } |
290 | 290 |
|
291 | 291 | public Vector4 ConvertInsertionToManipulatorPosition(Vector3 insertionAPMLDV) |
@@ -317,36 +317,35 @@ public Vector4 ConvertInsertionToManipulatorPosition(Vector3 insertionAPMLDV) |
317 | 317 | /// </summary> |
318 | 318 | public void ComputeBrainSurfaceOffset() |
319 | 319 | { |
320 | | - throw new NotImplementedException(); |
321 | | - //if (_probeManager.IsProbeInBrain()) |
322 | | - //{ |
323 | | - // // Just calculate the distance from the probe tip position to the brain surface |
324 | | - // BrainSurfaceOffset -= _probeManager.GetSurfaceCoordinateT().depthT; |
325 | | - //} |
326 | | - //else |
327 | | - //{ |
328 | | - // // We need to calculate the surface coordinate ourselves |
329 | | - // var tipExtensionDirection = |
330 | | - // IsSetToDropToSurfaceWithDepth ? _probeController.GetTipWorldU().tipUpWorldU : Vector3.up; |
331 | | - |
332 | | - // var brainSurfaceCoordinate = _annotationDataset.FindSurfaceCoordinate( |
333 | | - // _annotationDataset.CoordinateSpace.World2Space(_probeController.GetTipWorldU().tipCoordWorldU - |
334 | | - // tipExtensionDirection * 5), |
335 | | - // _annotationDataset.CoordinateSpace.World2Space_Vector(tipExtensionDirection)); |
336 | | - |
337 | | - // if (float.IsNaN(brainSurfaceCoordinate.x)) |
338 | | - // { |
339 | | - // Debug.LogWarning("Could not find brain surface! Canceling set brain offset."); |
340 | | - // return; |
341 | | - // } |
342 | | - |
343 | | - // var brainSurfaceToTransformed = |
344 | | - // _probeController.Insertion.World2Transformed( |
345 | | - // _annotationDataset.CoordinateSpace.Space2World(brainSurfaceCoordinate)); |
346 | | - |
347 | | - // BrainSurfaceOffset += Vector3.Distance(brainSurfaceToTransformed, |
348 | | - // _probeController.Insertion.apmldv); |
349 | | - //} |
| 320 | + if (_probeManager.IsProbeInBrain()) |
| 321 | + { |
| 322 | + // Just calculate the distance from the probe tip position to the brain surface |
| 323 | + BrainSurfaceOffset -= _probeManager.GetSurfaceCoordinateT().depthT; |
| 324 | + } |
| 325 | + else |
| 326 | + { |
| 327 | + // We need to calculate the surface coordinate ourselves |
| 328 | + var tipExtensionDirection = |
| 329 | + IsSetToDropToSurfaceWithDepth ? _probeController.GetTipWorldU().tipUpWorldU : Vector3.up; |
| 330 | + |
| 331 | + var brainSurfaceIdxCoordU = _probeManager.FindSurfaceIdxCoordinate( |
| 332 | + BrainAtlasManager.ActiveReferenceAtlas.World2AtlasIdx(_probeController.GetTipWorldU().tipCoordWorldU - |
| 333 | + tipExtensionDirection * 5), |
| 334 | + BrainAtlasManager.ActiveReferenceAtlas.World2Atlas_Vector(tipExtensionDirection)); |
| 335 | + |
| 336 | + if (float.IsNaN(brainSurfaceIdxCoordU.x)) |
| 337 | + { |
| 338 | + Debug.LogWarning("Could not find brain surface! Canceling set brain offset."); |
| 339 | + return; |
| 340 | + } |
| 341 | + |
| 342 | + var brainSurfaceToTransformed = |
| 343 | + _probeController.Insertion.World2T( |
| 344 | + BrainAtlasManager.ActiveReferenceAtlas.World2AtlasIdx(brainSurfaceIdxCoordU)); |
| 345 | + |
| 346 | + BrainSurfaceOffset += Vector3.Distance(brainSurfaceToTransformed, |
| 347 | + _probeController.Insertion.apmldv); |
| 348 | + } |
350 | 349 | } |
351 | 350 |
|
352 | 351 | /// <summary> |
|
0 commit comments