-
Notifications
You must be signed in to change notification settings - Fork 1
v0.6.0 #598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v0.6.0 #598
Changes from all commits
0935d19
1159339
c0cb7c2
d44aed5
60da548
74eb338
8057ad0
748c2fd
4771f07
56ff6fb
3f4fd5f
42bd123
5833fd8
7404211
ea5d78d
df0da79
2b2588a
4e78eca
3b7166f
819a5e7
76bb1de
5c576bb
604a197
0813fb7
d03f4cb
42914d4
a939cfc
b2fa3e3
796d854
2f3a6fe
7aa24a3
6ceacca
ac952d0
1802246
97f47d8
09eff4d
7f19eb8
4ef8ba4
f13e84b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| """ Image manager | ||
| """Image manager | ||
|
|
||
| Receives images from the camera and sends them to Liveview and ScopeOp. | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| """ Experiment form GUI window | ||
| """Experiment form GUI window | ||
|
|
||
| Takes user input and exports experiment metadata. | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| """ Liveview GUI window | ||
| """Liveview GUI window | ||
|
|
||
| Displays camera preview and conveys info to user during runs.""" | ||
|
|
||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we turn off fast flow in the future the pneumatic module min step size will stay doubled There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am similarly concerned if this reset adequately resets step size. Have you done multiple runs in a row where at least one run fails on fastflow? From the scope routine it looks like a failure in fastflow means it'll never reset the step size |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,6 @@ | |
| checkLedWorking, | ||
| ) | ||
| from ulc_mm_package.image_processing.flow_control import ( | ||
| FlowController, | ||
| CantReachTargetFlowrate, | ||
| ) | ||
| from ulc_mm_package.image_processing.cell_finder import ( | ||
|
|
@@ -244,10 +243,12 @@ def flow_control_routine( | |
| mscope.flow_controller.reset() | ||
| flow_controller = mscope.flow_controller | ||
| flow_controller.set_target_flowrate(target_flowrate) | ||
| flow_controller.set_alpha(processing_constants.FLOW_CONTROL_EWMA_ALPHA) | ||
| if fast_flow: | ||
| flow_controller.set_alpha( | ||
| processing_constants.FLOW_CONTROL_EWMA_ALPHA * 2 | ||
| ) # Double the alpha, ~halve the half life | ||
| flow_controller.pneumatic_module.min_step_size *= 2 | ||
|
|
||
| while True: | ||
| img, timestamp = yield flow_val, syringe_can_move | ||
|
|
@@ -261,15 +262,25 @@ def flow_control_routine( | |
| flow_val, flow_error, syringe_can_move = flow_controller.control_flow( | ||
| img, timestamp | ||
| ) | ||
|
|
||
| # This check is here so that we don't flood the logger with the same message repeatedly | ||
| if (prev_can_move is True) and (syringe_can_move is False): | ||
| # This is here so that we don't flood the logger with the same message | ||
| # If we were in fast_flow, we need to reset the min_step_size | ||
| if fast_flow: | ||
| flow_controller.pneumatic_module.min_step_size = ( | ||
| flow_controller.pneumatic_module.default_min_step_size | ||
| ) | ||
|
|
||
| self.logger.error( | ||
| "Can't reach target flowrate. Syringe at end of travel." | ||
| ) | ||
|
|
||
| if fast_flow: | ||
| if flow_error is not None: | ||
| if flow_error == 0: | ||
| flow_controller.pneumatic_module.min_step_size = ( | ||
| flow_controller.pneumatic_module.default_min_step_size | ||
| ) | ||
| return flow_val | ||
|
|
||
| @init_generator | ||
|
|
@@ -386,6 +397,7 @@ def periodic_autobrightness_routine( | |
| if counter >= processing_constants.PERIODIC_AB_PERIOD_NUM_FRAMES: | ||
| autobrightness.autobrightness_pid_control(img) | ||
| curr_img_brightness = autobrightness.prev_mean_img_brightness | ||
| counter = 0 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks good, but how was this loop ever working without this line? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lol it embarrassingly wasn't, this was a long overlooked bug |
||
|
|
||
| def checkPressureDifference( | ||
| self, mscope: MalariaScope, ambient_pressure: float | ||
|
|
@@ -485,7 +497,9 @@ def find_cells_routine( | |
| # Maximum number of times to run check for cells routine before aborting | ||
| max_attempts = 3 | ||
| cell_finder = CellFinder() | ||
| flow_controller = FlowController(mscope.pneumatic_module) | ||
| mscope.flow_controller.reset() | ||
| flow_controller = mscope.flow_controller | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we have a local There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just for a bit of cleanliness/ease of typing, (instead of having to type |
||
|
|
||
| img = yield | ||
|
|
||
| # Initial check for cells, return current motor position if cells found | ||
|
|
@@ -495,6 +509,11 @@ def find_cells_routine( | |
| except NoCellsFound: | ||
| cell_finder.reset() | ||
|
|
||
| # Defensive check, ensure the motor isn't moving (say for example, | ||
| # if CellFinder was triggered by an OOF exception and SSAF just triggered a motor move) | ||
| while mscope.motor.is_locked(): | ||
| pass | ||
|
|
||
| while True: | ||
| """ | ||
| 1. Pull syringe for pull_time seconds (unless deliberately skipped) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,6 +71,19 @@ def __init__(self): | |
| # Setup heatmap masking | ||
| self.heatmaps = np.zeros((len(YOGO_CLASS_LIST), sy * sx)) | ||
|
|
||
| def reset(self): | ||
| self.pred_tensors.fill(0) | ||
| self.new_pred_pointer = 0 | ||
| self.max_confs = {x: [] for x in self.class_ids} | ||
| self.curr_min_of_max_confs_by_class = { | ||
| x: HIGH_CONF_THRESH - 1e-6 for x in self.class_ids | ||
| } | ||
| self.min_confs = {x: [] for x in self.class_ids} | ||
| self.curr_max_of_min_confs_by_class = { | ||
| x: HIGH_CONF_THRESH for x in self.class_ids | ||
| } | ||
|
Comment on lines
+77
to
+84
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I apologize in advance because I know very little about the predictions handler... but why do these variables need to reset? I assumed these would be consistent across each experiment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no sweat! These variables hold the predictions for each run - but they are really big arrays - 15 rows * 3.5M columns (which is just an upper bound for how many cells we would reasonably expect YOGO to see). Instead of re-creating this giant array for each run, we just clear it, so that the next run's predictions can fill it up. |
||
| self.heatmaps.fill(0) | ||
|
|
||
| def add_raw_pred_to_heatmap(self, yogo_res: AsyncInferenceResult) -> None: | ||
| """Add the raw YOGO prediction to the heatmap. | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.