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
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ public partial class ManipulatorBehaviorController : MonoBehaviour
/// Getter and setter or the zero coordinate offset of the manipulator.
/// If passed a NaN value, the previous value is kept.
/// </summary>
public Vector4 ZeroCoordinateOffset
public Vector4 ReferenceCoordinateOffset
{
get => _zeroCoordinateOffset;
get => _referenceCoordinateOffset;
set
{
_zeroCoordinateOffset = new Vector4(
float.IsNaN(value.x) ? _zeroCoordinateOffset.x : value.x,
float.IsNaN(value.y) ? _zeroCoordinateOffset.y : value.y,
float.IsNaN(value.z) ? _zeroCoordinateOffset.z : value.z,
float.IsNaN(value.w) ? _zeroCoordinateOffset.w : value.w
_referenceCoordinateOffset = new Vector4(
float.IsNaN(value.x) ? _referenceCoordinateOffset.x : value.x,
float.IsNaN(value.y) ? _referenceCoordinateOffset.y : value.y,
float.IsNaN(value.z) ? _referenceCoordinateOffset.z : value.z,
float.IsNaN(value.w) ? _referenceCoordinateOffset.w : value.w
);

ZeroCoordinateOffsetChangedEvent.Invoke(_zeroCoordinateOffset);
ZeroCoordinateOffsetChangedEvent.Invoke(_referenceCoordinateOffset);
}
}

Expand Down Expand Up @@ -89,7 +89,7 @@ public bool IsRightHanded
#region Private internal fields

private Vector4 _lastLoggedManipulatorPosition = Vector4.zero;
private Vector4 _zeroCoordinateOffset = Vector4.zero;
private Vector4 _referenceCoordinateOffset = Vector4.zero;
private float _brainSurfaceOffset;
private bool _isRightHanded;
private float _lastLoggedTime;
Expand Down Expand Up @@ -124,7 +124,7 @@ private void Awake()
private void OnDisable()
{
ManipulatorID = null;
_zeroCoordinateOffset = Vector4.zero;
_referenceCoordinateOffset = Vector4.zero;
_brainSurfaceOffset = 0;
}

Expand Down Expand Up @@ -210,7 +210,7 @@ public Vector4 ConvertInsertionAPMLDVToManipulatorPosition(Vector3 insertionAPML
posInManipulatorTransform.w -= float.IsNaN(BrainSurfaceOffset) ? 0 : BrainSurfaceOffset;

// Apply coordinate offsets and return result
return posInManipulatorTransform + ZeroCoordinateOffset;
return posInManipulatorTransform + ReferenceCoordinateOffset;
}

/// <summary>
Expand Down Expand Up @@ -327,7 +327,7 @@ public async Awaitable<bool> MoveBackToZeroCoordinate()
var setPositionResponse = await CommunicationManager.Instance.SetPosition(
new SetPositionRequest(
ManipulatorID,
ZeroCoordinateOffset,
ReferenceCoordinateOffset,
AUTOMATIC_MOVEMENT_SPEED
)
);
Expand Down Expand Up @@ -362,7 +362,7 @@ private async Awaitable UpdateProbePositionFromManipulator()

// Apply zero coordinate offset.
var zeroCoordinateAdjustedManipulatorPosition =
positionResponse.Position - ZeroCoordinateOffset;
positionResponse.Position - ReferenceCoordinateOffset;

// Convert to coordinate space.
var manipulatorSpacePosition = CoordinateTransform.T2U(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ private Vector3 GetOffsetAdjustedTargetCoordinate(ProbeManager targetInsertionPr
var offsetAdjustedTargetCoordinateWorldT =
targetWorldT + offsetAdjustedRelativeTargetPositionWorldT;

// Converting worldT to AtlasT (to capture new Bregma offset when there is scaling)
// Converting worldT to AtlasT (to capture new reference coordinate offset when there is scaling)
// then switch axes to get APMLDV.
var offsetAdjustedTargetCoordinateAtlasT =
BrainAtlasManager.ActiveReferenceAtlas.World2Atlas(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ public partial class ManipulatorBehaviorController
#endregion

/// <summary>
/// Reset zero coordinate of the manipulator
/// Reset reference coordinate of the manipulator
/// </summary>
/// <remarks>
/// Alerts user of 4-axis manipulators if depth axis is not at 0 and 3-axis manipulators if depth is too far from
/// center.
/// </remarks>
public async Awaitable<bool> ResetZeroCoordinate()
public async Awaitable<bool> ResetReferenceCoordinate()
{
// Query current position.
var positionalResponse = await CommunicationManager.Instance.GetPosition(ManipulatorID);
Expand Down Expand Up @@ -70,18 +70,18 @@ when Mathf.Abs(Dimensions.z / 2f - positionalResponse.Position.w)
return false;

// Complete reset.
ZeroCoordinateOffset = positionalResponse.Position;
ReferenceCoordinateOffset = positionalResponse.Position;
BrainSurfaceOffset = 0;

// Log event.
OutputLog.Log(
new[]
{
"Copilot",
"Automation",
DateTime.Now.ToString(CultureInfo.InvariantCulture),
"ResetZeroCoordinate",
"ResetReferenceCoordinate",
ManipulatorID,
ZeroCoordinateOffset.ToString()
ReferenceCoordinateOffset.ToString()
}
);
return true;
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/Pinpoint/Probes/ProbeAutomationState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public enum ProbeAutomationState
IsUncalibrated,

/// <summary>
/// Is calibrated to Bregma. Could be positioned anywhere.
/// Is calibrated to the reference coordinate. Could be positioned anywhere.
/// </summary>
IsCalibrated,

Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/Pinpoint/Probes/ProbeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,7 @@ public static ProbeManagerData ProbeManager2ProbeData(ProbeManager probeManager)

data.NumAxes = probeManager.ManipulatorBehaviorController.NumAxes;
data.ManipulatorID = probeManager.ManipulatorBehaviorController.ManipulatorID;
data.ZeroCoordOffset = probeManager.ManipulatorBehaviorController.ZeroCoordinateOffset;
data.ZeroCoordOffset = probeManager.ManipulatorBehaviorController.ReferenceCoordinateOffset;
data.Dimensions = probeManager.ManipulatorBehaviorController.Dimensions;
data.BrainSurfaceOffset = probeManager.ManipulatorBehaviorController.BrainSurfaceOffset;
// data.Drop2SurfaceWithDepth = probeManager
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/Pinpoint/TP_ProbeQuickSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void ResetZeroCoordinate()
if (ProbeManager.ActiveProbeManager.IsEphysLinkControlled)
{
_communicationManager.GetPosition(ProbeManager.ActiveProbeManager.ManipulatorBehaviorController.ManipulatorID,
zeroCoordinate => ProbeManager.ActiveProbeManager.ManipulatorBehaviorController.ZeroCoordinateOffset = zeroCoordinate);
zeroCoordinate => ProbeManager.ActiveProbeManager.ManipulatorBehaviorController.ReferenceCoordinateOffset = zeroCoordinate);
ProbeManager.ActiveProbeManager.ManipulatorBehaviorController.BrainSurfaceOffset = 0;
}
else
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/Pinpoint/TrajectoryPlannerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ public ProbeManager AddNewProbe(ProbeProperties.ProbeType probeType, ProbeInsert

// Repopulate Ephys Link information
probeManager.ManipulatorBehaviorController.NumAxes = numAxes;
probeManager.ManipulatorBehaviorController.ZeroCoordinateOffset = zeroCoordinateOffset;
probeManager.ManipulatorBehaviorController.ReferenceCoordinateOffset = zeroCoordinateOffset;
probeManager.ManipulatorBehaviorController.BrainSurfaceOffset = brainSurfaceOffset;
// probeManager.ManipulatorBehaviorController.IsSetToDropToSurfaceWithDepth = dropToSurfaceWithDepth;
// probeManager.ManipulatorBehaviorController.IsSetToDropToSurfaceWithDepth = dropToSurfaceWithDepth;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void ResetZeroCoordinate()
ProbeManager.ManipulatorBehaviorController.ManipulatorID,
zeroCoordinate =>
{
ProbeManager.ManipulatorBehaviorController.ZeroCoordinateOffset =
ProbeManager.ManipulatorBehaviorController.ReferenceCoordinateOffset =
zeroCoordinate;
ProbeManager.ManipulatorBehaviorController.BrainSurfaceOffset = 0;
}
Expand All @@ -44,7 +44,7 @@ public void ResetZeroCoordinate()
DateTime.Now.ToString(CultureInfo.InvariantCulture),
"ResetZeroCoordinate",
ProbeManager.ManipulatorBehaviorController.ManipulatorID,
ProbeManager.ManipulatorBehaviorController.ZeroCoordinateOffset.ToString()
ProbeManager.ManipulatorBehaviorController.ReferenceCoordinateOffset.ToString()
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public void OnLinkedProbeSelectionChanged(int value)
/// <param name="newValue">New offset X-axis value</param>
public void UpdateZeroCoordinateOffsetX(string newValue)
{
_attachedProbe.ManipulatorBehaviorController.ZeroCoordinateOffset = new Vector4(
_attachedProbe.ManipulatorBehaviorController.ReferenceCoordinateOffset = new Vector4(
float.Parse(newValue),
float.NaN,
float.NaN,
Expand All @@ -264,7 +264,7 @@ public void UpdateZeroCoordinateOffsetX(string newValue)
/// <param name="newValue">New offset Y-axis value</param>
public void UpdateZeroCoordinateOffsetY(string newValue)
{
_attachedProbe.ManipulatorBehaviorController.ZeroCoordinateOffset = new Vector4(
_attachedProbe.ManipulatorBehaviorController.ReferenceCoordinateOffset = new Vector4(
float.NaN,
float.Parse(newValue),
float.NaN,
Expand All @@ -278,7 +278,7 @@ public void UpdateZeroCoordinateOffsetY(string newValue)
/// <param name="newValue">New offset Z-axis value</param>
public void UpdateZeroCoordinateOffsetZ(string newValue)
{
_attachedProbe.ManipulatorBehaviorController.ZeroCoordinateOffset = new Vector4(
_attachedProbe.ManipulatorBehaviorController.ReferenceCoordinateOffset = new Vector4(
float.NaN,
float.NaN,
float.Parse(newValue),
Expand All @@ -292,7 +292,7 @@ public void UpdateZeroCoordinateOffsetZ(string newValue)
/// <param name="newValue">New offset D-axis value</param>
public void UpdateZeroCoordinateOffsetD(string newValue)
{
_attachedProbe.ManipulatorBehaviorController.ZeroCoordinateOffset = new Vector4(
_attachedProbe.ManipulatorBehaviorController.ReferenceCoordinateOffset = new Vector4(
float.NaN,
float.NaN,
float.NaN,
Expand Down Expand Up @@ -402,7 +402,7 @@ private void UpdateProbePropertiesSectionState()
{
_probePropertiesSection.SetActive(true);
UpdateZeroCoordinateOffsetInputFields(
_attachedProbe.ManipulatorBehaviorController.ZeroCoordinateOffset
_attachedProbe.ManipulatorBehaviorController.ReferenceCoordinateOffset
);
UpdateBrainSurfaceOffsetInputField(
_attachedProbe.ManipulatorBehaviorController.BrainSurfaceOffset
Expand Down
20 changes: 10 additions & 10 deletions Assets/Scripts/UI/AutomationStack/AutomationStackHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public partial class AutomationStackHandler : MonoBehaviour
// Panels.
private VisualElement _automationStackPanel;

#region Bregma Calibration
#region Reference Coordinate Calibration

private Button _resetBregmaCalibrationButton;
private Button _resetReferenceCoordinateButton;

#endregion

Expand Down Expand Up @@ -83,8 +83,8 @@ private void OnEnable()
{
// Get components.
_automationStackPanel = _root.Q("automation-stack-panel");
_resetBregmaCalibrationButton = _automationStackPanel.Q<Button>(
"reset-bregma-calibration-button"
_resetReferenceCoordinateButton = _automationStackPanel.Q<Button>(
"reset-reference-coordinate-button"
);
_targetInsertionRadioButtonGroup = _automationStackPanel.Q<RadioButtonGroup>(
"target-insertion-radio-button-group"
Expand All @@ -102,7 +102,7 @@ private void OnEnable()
_exitButton = _automationStackPanel.Q<Button>("exit-button");

// Register callbacks.
_resetBregmaCalibrationButton.clicked += ResetBregmaCalibration;
_resetReferenceCoordinateButton.clicked += ResetReferenceCoordinate;
_targetInsertionRadioButtonGroup.RegisterValueChangedCallback(
OnTargetInsertionSelectionChanged
);
Expand All @@ -116,7 +116,7 @@ private void OnEnable()
private void OnDisable()
{
// Unregister callbacks.
_resetBregmaCalibrationButton.clicked -= ResetBregmaCalibration;
_resetReferenceCoordinateButton.clicked -= ResetReferenceCoordinate;
_targetInsertionRadioButtonGroup.UnregisterValueChangedCallback(
OnTargetInsertionSelectionChanged
);
Expand Down Expand Up @@ -144,13 +144,13 @@ private void FixedUpdate()

#region Stages

#region Bregma Calibration
#region Reference Coordinate Calibration

/// <summary>
/// Reset the Bregma calibration of the active probe.
/// Reset the reference coordinate calibration of the active probe.
/// </summary>
/// <exception cref="InvalidOperationException">Probe is not selected/active and is not controlled by Ephys Link</exception>
private partial void ResetBregmaCalibration();
private partial void ResetReferenceCoordinate();

#endregion

Expand Down Expand Up @@ -192,7 +192,7 @@ private void FixedUpdate()
/// </remarks>
/// <exception cref="InvalidOperationException">
/// Probe is not selected/active, is not controlled by Ephys Link, and is not
/// calibrated to bregma.
/// calibrated to reference coordinate.
/// </exception>
private partial void OnDriveToTargetEntryCoordinatePressed();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace UI.AutomationStack
{
/// <summary>
/// Implements Bregma calibration in the Automation Stack.<br />
/// Implements reference coordinate calibration in the Automation Stack.<br />
/// </summary>
public partial class AutomationStackHandler
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
namespace UI.AutomationStack
{
/// <summary>
/// Implements Bregma calibration in the Automation Stack.<br />
/// Implements reference coordinate calibration in the Automation Stack.<br />
/// </summary>
public partial class AutomationStackHandler
{
private async partial void ResetBregmaCalibration()
private async partial void ResetReferenceCoordinate()
{
// Throw exception if invariant is violated.
if (!AutomationStackState.IsEnabled)
throw new InvalidOperationException(
"Cannot reset Bregma calibration if automation is not enabled on probe "
"Cannot reset reference coordinate calibration if automation is not enabled on probe "
+ ProbeManager.ActiveProbeManager.name
);

// Reset the Bregma calibration of the active probe manager.
if (await ActiveManipulatorBehaviorController.ResetZeroCoordinate())
// Reset the reference coordinate calibration of the active probe manager.
if (await ActiveManipulatorBehaviorController.ResetReferenceCoordinate())
// Set probe's automation state to be calibrated if it did happen.
ActiveProbeStateManager.SetCalibrated();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ private async partial void OnDriveToTargetEntryCoordinatePressed()
// Throw exception if invariant is violated.
if (!AutomationStackState.IsEnabled || !ActiveProbeStateManager.IsCalibrated())
throw new InvalidOperationException(
$"Cannot drive {ProbeManager.ActiveProbeManager.name} to target insertion if not enabled and not calibrated to Bregma."
$"Cannot drive {ProbeManager.ActiveProbeManager.name} to target insertion if not enabled and not calibrated to reference coordinate."
);

// If the probe is moving, call stop.
Expand Down
Loading