Skip to content

Commit 75428a5

Browse files
committed
[imager] [cytation] image is an np.array
1 parent c9bdf2f commit 75428a5

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

pylabrobot/plate_reading/biotek_backend.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,14 +1194,11 @@ async def _acquire_image(
11941194
timeout = int(self.cam.ExposureTime.GetValue() / 1000 + 1000) # from example
11951195
image_result = self.cam.GetNextImage(timeout)
11961196
if not image_result.IsIncomplete():
1197-
t0 = time.time()
11981197
processor = PySpin.ImageProcessor()
11991198
processor.SetColorProcessing(color_processing_algorithm)
12001199
image_converted = processor.Convert(image_result, pixel_format)
12011200
image_result.Release()
1202-
logger.debug("[cytation5] acquired image in %d tries", num_tries + 1)
1203-
logger.debug("[cytation5] Convert took %.2f seconds for BS", time.time() - t0)
1204-
return image_converted.GetNDArray().tolist() # type: ignore
1201+
return image_converted.GetNDArray() # type: ignore
12051202
except SpinnakerException as e:
12061203
# the image is not ready yet, try again
12071204
logger.debug("Failed to get image: %s", e)

pylabrobot/plate_reading/imager.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ async def capture(
134134
gain: Gain = "machine-auto",
135135
**backend_kwargs,
136136
) -> ImagingResult:
137+
if not isinstance(exposure_time, (int, float, AutoExposure)):
138+
raise TypeError(f"Invalid exposure time: {exposure_time}")
139+
if not isinstance(focal_height, (int, float)) and focal_height != "machine-auto":
140+
raise TypeError(f"Invalid focal height: {focal_height}")
141+
137142
if isinstance(well, tuple):
138143
row, column = well
139144
else:

pylabrobot/plate_reading/standard.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import enum
22
from dataclasses import dataclass
3-
from typing import Awaitable, Callable, List, Literal, Union
3+
from typing import Awaitable, Callable, List, Literal, TypeAlias, Union
44

5-
Image = List[List[float]]
5+
try:
6+
import numpy as np
7+
8+
Image = np.ndarray
9+
except ImportError:
10+
Image = object # type: ignore
611

712

813
class Objective(enum.Enum):

0 commit comments

Comments
 (0)