Skip to content

Commit 0a5a0e3

Browse files
committed
1x1
1 parent 6a883c7 commit 0a5a0e3

File tree

5 files changed

+19
-13
lines changed

5 files changed

+19
-13
lines changed

ulc_mm_package/QtGUI/acquisition.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from py_cameras import PyCamerasError
1919

2020
from ulc_mm_package.hardware.scope import MalariaScope
21+
from ulc_mm_package.image_processing.focus_metrics import downsample_image
2122
from ulc_mm_package.scope_constants import ACQUISITION_PERIOD
2223

2324

@@ -92,5 +93,6 @@ def get_img(self):
9293
self.logger.error(f"Failed to grab image: {e}.")
9394

9495
def send_img(self):
95-
self.update_liveview.emit(self.img)
96+
img_ds = downsample_image(self.img, 2)
97+
self.update_liveview.emit(img_ds)
9698
self.update_infopanel.emit()

ulc_mm_package/QtGUI/scope_op.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -517,11 +517,11 @@ def _init_classic_focus(self, *args):
517517
try:
518518
if self.classic_focus_routine is None:
519519
self.classic_focus_routine = self.routines.classic_focus_routine(
520-
downsample_image(self.last_img, 10)
520+
downsample_image(self.last_img, DOWNSAMPLE_FACTOR)
521521
)
522522
else:
523523
self.routines.classic_focus._check_and_update_metric(
524-
downsample_image(self.last_img, 10)
524+
downsample_image(self.last_img, DOWNSAMPLE_FACTOR)
525525
)
526526
except Exception as e:
527527
self.logger.error(
@@ -780,7 +780,8 @@ def run_autofocus(self, img, _timestamp):
780780

781781
if not self.autofocus_done:
782782
if len(self.autofocus_batch) < AF_BATCH_SIZE:
783-
self.autofocus_batch.append(img)
783+
img_ds = downsample_image(img, 2)
784+
self.autofocus_batch.append(img_ds)
784785

785786
if self.running:
786787
self.img_signal.connect(self.run_autofocus)
@@ -856,9 +857,10 @@ def run_fastflow(self, img, timestamp):
856857
)
857858

858859
try:
859-
img_ds_10x = downsample_image(img, DOWNSAMPLE_FACTOR)
860+
img_ds = downsample_image(img, DOWNSAMPLE_FACTOR)
861+
print(f"Starting fast flow - sending img of shape {img_ds.shape}")
860862
self.flowrate, syringe_can_move = self.fastflow_routine.send(
861-
(img_ds_10x, timestamp)
863+
(img_ds, timestamp)
862864
)
863865

864866
if self.flowrate is not None:
@@ -953,9 +955,10 @@ def run_experiment(self, img, timestamp) -> None:
953955
t1 = perf_counter()
954956
self._update_metadata_if_verbose("update_img_count", t1 - t0)
955957

958+
img_ds_2x = downsample_image(img, 2)
956959
t0 = perf_counter()
957960
prev_yogo_results = self.routines.count_parasitemia(
958-
self.mscope, YOGO.crop_img(img), self.frame_count
961+
self.mscope, YOGO.crop_img(img_ds_2x), self.frame_count
959962
)
960963
t1 = perf_counter()
961964

@@ -1007,7 +1010,7 @@ def run_experiment(self, img, timestamp) -> None:
10071010
raw_focus_err,
10081011
filtered_focus_err,
10091012
focus_adjustment,
1010-
) = self.PSSAF_routine.send(img)
1013+
) = self.PSSAF_routine.send(img_ds_2x)
10111014
except MotorControllerError as e:
10121015
if not SIMULATION:
10131016
self.logger.error(
@@ -1039,11 +1042,11 @@ def run_experiment(self, img, timestamp) -> None:
10391042
# ------------------------------------
10401043
t0 = perf_counter()
10411044
# Downsample image for use in flowrate + classic image focus metric
1042-
img_ds_10x = downsample_image(img, 10)
1045+
img_ds = downsample_image(img, DOWNSAMPLE_FACTOR)
10431046
try:
10441047
# Returns the ratio of the current sharpness metric over the best seen
10451048
# so far
1046-
sharpness_ratio_rel_peak = self.classic_focus_routine.send(img_ds_10x)
1049+
sharpness_ratio_rel_peak = self.classic_focus_routine.send(img_ds)
10471050
except OOF as e:
10481051
self.logger.warning(
10491052
f"Strayed too far away from focus, transitioning to cell-finder. {e}"
@@ -1055,7 +1058,7 @@ def run_experiment(self, img, timestamp) -> None:
10551058
# Run flow control routine
10561059
# ------------------------------------
10571060
try:
1058-
self.flowrate, _ = self.flowcontrol_routine.send((img_ds_10x, timestamp))
1061+
self.flowrate, _ = self.flowcontrol_routine.send((img_ds, timestamp))
10591062
except Exception as e:
10601063
self.logger.error(f"Unexpected flow control exception - {e}")
10611064
self.flowrate = -1

ulc_mm_package/hardware/scope_routines.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ def flow_control_routine(
271271
while True:
272272
img, timestamp = yield flow_val, syringe_can_move
273273

274+
print(f"Flow control received img of shape: {img.shape}")
274275
# Get the flow value, difference from target flow, and whether the syringe can move
275276
# If syringe_can_move is False, a CantReachTargetFlowrate exception was raised, meaning
276277
# the syringe can't move further and the target flowrate has not been reached.

ulc_mm_package/image_processing/flowrate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ def __init__(
2020
self,
2121
img_height: int = CAMERA_SELECTION.IMG_HEIGHT // DOWNSAMPLE_FACTOR,
2222
img_width: int = CAMERA_SELECTION.IMG_WIDTH // DOWNSAMPLE_FACTOR,
23-
scale_factor: int = DOWNSAMPLE_FACTOR,
2423
):
2524
"""A class for estimating the flow rate of cells using a 2D cross-correlation.
2625
The class holds two images at a time in `frame_a` and `frame_b`. To use this class,
@@ -58,6 +57,7 @@ def __init__(
5857
self.img_height, self.img_width = img_height, img_width
5958

6059
# for multi-proc
60+
print(f"FRE expects: {img_height}, {img_width}")
6161
self.multiproc_interface = msr.MultiProcFunc.from_arg_definitions(
6262
get_flowrate_with_cross_correlation,
6363
work_fn_inputs=[

ulc_mm_package/scope_constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
CONFIGURATION_FILE = curr_dir / "configs" / f"{socket.gethostname()}-config.ini"
4040

4141
# ================ For flowcontrol and classc image focus ================ #
42-
DOWNSAMPLE_FACTOR = 10
42+
DOWNSAMPLE_FACTOR = 20
4343

4444
# ================ Summary PDF constants ================ #
4545
DEBUG_REPORT = int(

0 commit comments

Comments
 (0)