Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Assets/Scripts/Models/Scene/ManipulatorState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public record ManipulatorState
/// <summary>
/// Drive past target distance (µm).
/// </summary>
public int DrivePastDistance;
public int DrivePastDistance = 50;

#endregion

Expand Down
7 changes: 5 additions & 2 deletions Assets/Scripts/Models/Scene/SceneReducers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -750,13 +750,16 @@ public static SceneState SetTargetInsertionProbeNameReducer(

try
{
// Verify selected target exists and is targetable.
// Verify selected target exists and is targetable:
// 1. Target name must not be empty
// 2. Target probe must exist in the probes list
// 3. Target probe must NOT be a visualization probe (those are manipulator-controlled)
if (
string.IsNullOrEmpty(action.payload.targetName)
|| !state.Probes.Exists(probeState =>
probeState.Name == action.payload.targetName
)
|| !state.Manipulators.Exists(manipulatorState =>
|| state.Manipulators.Exists(manipulatorState =>
manipulatorState.VisualizationProbeName == action.payload.targetName
)
)
Expand Down
5 changes: 0 additions & 5 deletions Assets/Scripts/Pinpoint/Probes/ProbeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ public void Register(ProbeManager probeManager)
/// </summary>
public Vector3 VisualizationLocalAPMLDV { get; set; }

/// <summary>
/// Local field for visualization probe depth.
/// </summary>
public float VisualizationLocalDepth { get; set; }

/// <summary>
/// Local field for visualization probe angles.
/// </summary>
Expand Down
20 changes: 6 additions & 14 deletions Assets/Scripts/Services/EphysLinkService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -704,16 +704,6 @@ var manipulatorState in sceneState.Manipulators.Where(state =>
referenceCoordinateAdjustedWorldPosition
);

// Cancel update if the manipulator's position did not change by a lot.
var probeState = sceneState.Probes.FirstOrDefault(state =>
state.Name == manipulatorState.VisualizationProbeName
);
if (
probeState == null
|| Vector3.SqrMagnitude(transformedAPMLDV - probeState.APMLDV) < 0.0001f
)
continue;

// Get the current forward vector of the probe.
var forwardT = BrainAtlasManager.ActiveAtlasTransform.U2T_Vector(
BrainAtlasManager.ActiveReferenceAtlas.World2Atlas_Vector(
Expand All @@ -726,18 +716,20 @@ var manipulatorState in sceneState.Manipulators.Where(state =>
if (probeController == null)
continue;

var depth = sceneState.NumberOfAxesOnManipulator switch
var depthToApply = sceneState.NumberOfAxesOnManipulator switch
{
3 => duraOffsetAdjustment,
3 => duraOffsetAdjustment, // Positive moves probe forward/deeper into brain
4 => referenceCoordinateAdjustedManipulatorPosition.w,
_ => throw new ValueOutOfRangeException(
"Number of axes on manipulator is invalid."
),
};

// Bake depth into APMLDV along forward vector
var finalAPMLDV = transformedAPMLDV + forwardT * depthToApply;

// Write position data directly to ProbeController's local fields
probeController.VisualizationLocalAPMLDV = transformedAPMLDV;
probeController.VisualizationLocalDepth = depth;
probeController.VisualizationLocalAPMLDV = finalAPMLDV;
probeController.VisualizationLocalAngles = manipulatorState.Angles;
probeController.VisualizationLocalForwardT = forwardT;

Expand Down
Loading