Skip to content

Commit 59caa13

Browse files
cell finder bug fix
1 parent d9d475a commit 59caa13

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

ulc_mm_package/hardware/real/pneumatic_module.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ def isMovePossible(self, move_dir: SyringeDirection) -> bool:
223223
# Cannot move the syringe down
224224
elif (
225225
self.duty_cycle - self.min_step_size < self.min_duty_cycle
226-
or self.mpr.ambient_pressure - self.mpr.prev_pressure > MAX_VACUUM_PRESSURE
227-
) and move_dir == SyringeDirection.DOWN:
226+
and move_dir == SyringeDirection.DOWN
227+
):
228228
return False
229229

230230
return True

ulc_mm_package/hardware/scope_routines.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
BrightnessCriticallyLow,
1515
checkLedWorking,
1616
)
17+
from ulc_mm_package.image_processing.flow_control import FlowController
1718

1819
from ulc_mm_package.image_processing.cell_finder import (
1920
CellFinder,
@@ -201,7 +202,11 @@ def count_parasitemia(
201202
def count_parasitemia_periodic_wrapper(
202203
self,
203204
mscope: MalariaScope,
204-
) -> Generator[List[AsyncInferenceResult], Tuple[np.ndarray, Optional[int]], None,]:
205+
) -> Generator[
206+
List[AsyncInferenceResult],
207+
Tuple[np.ndarray, Optional[int]],
208+
None,
209+
]:
205210
while True:
206211
img, counts = yield mscope.cell_diagnosis_model.get_asyn_results()
207212
mscope.cell_diagnosis_model(img, counts)
@@ -478,6 +483,7 @@ def find_cells_routine(
478483
# Maximum number of times to run check for cells routine before aborting
479484
max_attempts = 3
480485
cell_finder = CellFinder()
486+
flow_controller = FlowController(mscope.pneumatic_module)
481487
img = yield
482488

483489
# Initial check for cells, return current motor position if cells found
@@ -503,11 +509,9 @@ def find_cells_routine(
503509
# in which case, cells are already present, we just need to sweep the motor to find them
504510
if not (skip_syringe_pull):
505511
start = perf_counter()
506-
mscope.pneumatic_module.setDutyCycle(
507-
mscope.pneumatic_module.getMinDutyCycle()
508-
)
509512

510513
while perf_counter() - start < pull_time:
514+
flow_controller.adjustSyringe(-1)
511515
img = yield
512516
mscope.pneumatic_module.setDutyCycle(
513517
mscope.pneumatic_module.getMaxDutyCycle()

ulc_mm_package/image_processing/flow_control.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def control_flow(
191191
self.prev_adjustment_stamp = self.counter
192192

193193
try:
194-
self._adjustSyringe(flow_error)
194+
self.adjustSyringe(flow_error)
195195
syringe_successfully_adjusted = True
196196
except CantReachTargetFlowrate:
197197
syringe_successfully_adjusted = False
@@ -203,7 +203,7 @@ def control_flow(
203203
else:
204204
return (None, None, None)
205205

206-
def _adjustSyringe(self, flow_error: float):
206+
def adjustSyringe(self, flow_error: float):
207207
"""Adjusts the syringe based on the flow error.
208208
209209
Parameters
@@ -237,6 +237,7 @@ def _adjustSyringe(self, flow_error: float):
237237
except SyringeEndOfTravel:
238238
raise CantReachTargetFlowrate(self.flowrate)
239239

240+
240241
def stop(self):
241242
self.fre.stop()
242243
self.fre.reset()

0 commit comments

Comments
 (0)