Skip to content

Conversation

i-jey
Copy link
Collaborator

@i-jey i-jey commented Jan 30, 2025

Bumping up to v0.6.0 to denote a marked increase in SSAF frequency (and hopefully, a concomitant improvement in image focus over the course of a run)

  • Autobrightness adjustment frequency bugfix
  • Memory leak bugfix (extra instantiation of FlowController in scope_routines.py
  • Switch NCS to THROUGHPUT mode - allows us to run SSAF more frequently (went from 2 imgs/sec --> 10 imgs/sec)
  • QoL: faster fast flow during setup (increase the pneumatic module step size temporarily when doing the initial fast flow step
  • Add a defensive check to CellFinder to ensure motor is not currently in motion before starting CellFinder routine

Tested on scope while monitoring htop to ensure memory usage stayed flat, and tested in the oven at 40C (n=10 runs).

i-jey added 30 commits January 21, 2025 14:57
Reset counter after adjusting autobrightness
remove old pyngrok dependency (no longer used)
…polling of SSAF, and thus improve our ability to track focal drift. May want to tweak EWMA parameters to be less conservative since we can now receive more samples. Needs to be tested extensively on scope however, in particular we need to monitor for any memory increases in case the NCS cannot keep up and we start building up a queue.
…hich is excessive, up from 10 which is what we had previously)
… to speed faster. Set it back to normal once fast flow is done.
NCS performance hint --> throughput + increase SSAF polling
Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Contributor

@NicholasBratvold NicholasBratvold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QOL change in scope_routines.py will keep pneumatic step size doubled if fast flow is disabled. EDIT: I was mistaken, it will only temporarily double if fast flow is enabled.

How does ngrok work now with the files deleted?

@i-jey
Copy link
Collaborator Author

i-jey commented Mar 11, 2025

QOL change in scope_routines.py will keep pneumatic step size doubled if fast flow is disabled.

How does ngrok work now with the files deleted?

QOL change in scope_routines.py will keep pneumatic step size doubled if fast flow is disabled.

How does ngrok work now with the files deleted?

A while back, ngrok updated to v3 and the library we were using to interface with it (pyngrok) stopped working. So we now use the ngrok CLI command instead - there is a bash alias that the technicians use to manually open the tunnel (they type ng when we ask to remote in/pull data).

Copy link
Contributor

@NicholasBratvold NicholasBratvold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification.

@i-jey
Copy link
Collaborator Author

i-jey commented Mar 11, 2025

Sweet - I'll also wait on @mwlkhoo to review and then if all looks good, we can merge.

Copy link
Contributor

@mwlkhoo mwlkhoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments/questions

Copy link
Contributor

Choose a reason for hiding this comment

The 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

if counter >= processing_constants.PERIODIC_AB_PERIOD_NUM_FRAMES:
autobrightness.autobrightness_pid_control(img)
curr_img_brightness = autobrightness.prev_mean_img_brightness
counter = 0
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol it embarrassingly wasn't, this was a long overlooked bug

cell_finder = CellFinder()
flow_controller = FlowController(mscope.pneumatic_module)
mscope.flow_controller.reset()
flow_controller = mscope.flow_controller
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we have a local flow_controller function instead of directly referencing mscope.flow_controller?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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 mscope.flow_controller each time).

Comment on lines +77 to +84
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
}
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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.

… normally when doing fast flow, so that the set up is quicker and more ergonomic for the user (i.e they don't need to wait for a long while for the syringe to hit its stop in the event that debris or stuck cells are messing up the flow estimation calculation. Fix: This properly resets the step size back to what it is normally supposed to be, in the event where fast flow does not reach the target flow rate. Previously it was only being reset when fast flow succeeded.
@i-jey i-jey changed the title v0.5.6 v0.6.0 Mar 12, 2025
@mwlkhoo
Copy link
Contributor

mwlkhoo commented Mar 12, 2025

Looks good, thanks for addressing all my q's!

@NicholasBratvold
Copy link
Contributor

Tested on the scope.

mwlkhoo
mwlkhoo previously approved these changes Mar 12, 2025
Copy link
Contributor

@mwlkhoo mwlkhoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested by Nick, looks good

…eset_if_fast_flow_fails

Reset pneumatic module step size in the case where `fast_flow` fails
@i-jey i-jey dismissed stale reviews from mwlkhoo and NicholasBratvold via f13e84b March 12, 2025 23:14
Copy link
Contributor

@NicholasBratvold NicholasBratvold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@i-jey i-jey merged commit 5b20c53 into master Mar 13, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants