Fix handling of missing CSM matrix
The code checks for the camera-stage mapper matrix by looking at its truth value. However, this is ambiguous because the matrix has many elements. That means that if it's missing, we get the expected result, but if it's present we get an error. I have avoided dict.get() and instead look it up with [] notation. This will raise a KeyError if it's missing, which I handle helpfully. If the key is present but the value is not castable to an array, we'll get an exception anyway.
This commit is contained in:
parent
7028ac66bb
commit
6e7adb66cd
1 changed files with 4 additions and 3 deletions
|
|
@ -194,10 +194,11 @@ class CSMExtension(BaseExtension):
|
|||
@property
|
||||
def image_to_stage_displacement_matrix(self) -> np.ndarray: # 2x2 integer array
|
||||
"""A 2x2 matrix that converts displacement in image coordinates to stage coordinates."""
|
||||
displacement_matrix = self.get_settings().get("image_to_stage_displacement")
|
||||
if not displacement_matrix:
|
||||
settings = self.get_settings()
|
||||
try:
|
||||
return np.array(settings["image_to_stage_displacement"])
|
||||
except KeyError:
|
||||
raise ValueError("The microscope has not yet been calibrated.")
|
||||
return np.array(displacement_matrix)
|
||||
|
||||
def move_in_image_coordinates(self, displacement_in_pixels: XYCoordinateType):
|
||||
"""Move by a given number of pixels on the camera"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue