@@ -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
0 commit comments