Adding interactive ROIs in lyse

23 views
Skip to first unread message

Shawn Storm

unread,
Dec 17, 2025, 4:39:03 AM12/17/25
to the labscript suite
Hi all,

I am working with single atoms with optical tweezers and I would like to incorporate a feature that would save time. Namely, to position the ROIs over the fluorescence of every atom, I typically have to manually put the coordinates and the box size in python, rerun and see if the position matches where the atoms are. This takes a few iterations and with many atoms and due to daily drifts this accrues a lot of time. I am wondering if it is possible to, in lyse, have interactive ROIs that I can change on the fly so I can just run the experiment, see the fluorescence and change ROIs in lyse. I got this idea from a group that is not using labscript and has their own data analysis program. Attached you can see a video that of what I would like to do in their program. I was thinking of pyqt to do this so I would really appreciate any guidance on this!
Screencast from 2025-12-17 10-33-20.mp4

Ian B. Spielman

unread,
Dec 17, 2025, 7:52:16 AM12/17/25
to labscri...@googlegroups.com
Dear Shawn,

This is possible, but not easy, to directly implement in the current Lyse schema. If I were to do this right now, I would use Lyse to communicate with an external helper process (see this https://github.com/rpanderson/analysislib-mloop for an example of how this might be done). The reason for this is that the helper GUI really does not want to use the automatic figure-window managing that Lyse currently implements for figures.

I would say that many of the recent changes to Lyse were implemented with the motivation to increase the flexibility going forward. For example, in-house I wrote a class-based revision of Lyse workers in which each worker process can (if it wants to) create and control its own PyQt window. This process still receives messages like Lyse workers currently do, but they are instead dispatched to class methods, and the state of the class persists between shots.

It would take a bit of time to get this going again with the recently lyse update, but it could be done.

— Ian

NIST Fellow
Group Leader, NIST laser cooling and trapping group
Fellow, Joint Quantum Institute

National Institute of Standards and Technology and the University of Maryland

----- WEB -----
http://ultracold.jqi.umd.edu

----- EMAIL ——
spie...@jqi.umd.edu
ian.sp...@nist.gov (NIST administration only)

----- ZOOM -----
https://umd.zoom.us/j/7984811536

----- MAIL -----
UMD:
2207 Atlantic Bldg.
College Park, MD 20742

NIST:
100 Bureau Drive, Stop 8424
Gaithersburg, MD 20899-8424 USA

----- OFFICE -----
UMD: Physical Sciences Complex, Room 2153


> On Dec 17, 2025, at 04:39, Shawn Storm <shawn...@unifi.it> wrote:
>
> Hi all,
>
> I am working with single atoms with optical tweezers and I would like to incorporate a feature that would save time. Namely, to position the ROIs over the fluorescence of every atom, I typically have to manually put the coordinates and the box size in python, rerun and see if the position matches where the atoms are. This takes a few iterations and with many atoms and due to daily drifts this accrues a lot of time. I am wondering if it is possible to, in lyse, have interactive ROIs that I can change on the fly so I can just run the experiment, see the fluorescence and change ROIs in lyse. I got this idea from a group that is not using labscript and has their own data analysis program. Attached you can see a video that of what I would like to do in their program. I was thinking of pyqt to do this so I would really appreciate any guidance on this!
>
> --
> You received this message because you are subscribed to the Google Groups "the labscript suite" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to labscriptsuit...@googlegroups.com.
> To view this discussion, visit https://groups.google.com/d/msgid/labscriptsuite/fe033a94-ce92-428f-800f-c186bcb8e30an%40googlegroups.com.
> <Screencast from 2025-12-17 10-33-20.mp4>

Shawn Storm

unread,
Dec 19, 2025, 9:09:18 AM12/19/25
to the labscript suite

Hi Ian, 

Many thanks for the quick reply and thanks also for sharing that github example. I was actually going to start looking into incorporating mloop with Labscript soon and I am very happy to see that it is already implemented! 

Ok I am quite interested in implementing this interactive ROI project and providing it for others in the labscript community to use. How do you suggest I move forward? Would it be possible to collaborate with you or someone else on this to implement it?

Sincerely,
Shawn

dihm....@gmail.com

unread,
Dec 22, 2025, 9:44:42 AM12/22/25
to the labscript suite
Shawn,

This sounds like an interesting project that I'm sure will find some wider interest. Like Ian said, recent changes to Lyse should (hopefully) make something like this a bit easier to implement. I have a few random thoughts to add:

1) To the extent possible, I'd encourage you to find a way to leverage the existing `Plot` subclass framework. The `Plot` class is defined in `analysis_subprocess.py` and is intended to be subclassed so that extra functionality can be baked in. One then can register the custom subclass so that lyse figure management magic can continue to occur. If you can fit the functionality within that framework, it would make merging into lyse proper significantly more likely. If the implementation relies on a separate process implementation with messaging between, I suspect the best way to share will be with a separate repo (much like mloop).
1a) One difficulty I can foresee with the `Plot` framework is if you want the custom ROIs to be saved to the shot file (ie communicated back to the analysis script). That may be harder, though we are talking python so anything is possible... 
2) For the implementation, I'd suggest you look in to pyqtgraph. It is what is currently used for camera plots in BLACS. It is very performant and has a fairly native concept of ROI management. Personally, I've found it takes a lot of the pain out of Qt integration for (fast updating) images and plots. It should be compatible with `Plot` subclassing, though we'd likely want to consider some kind of override for the auto close and open behavior since that is mostly a hack to ensure matplotlib plots update correctly.
3) As for moving forward, you're off to a great start! Asking here is the perfect first step. Next I'd suggest you create a fork of lyse, make a new feature branch, and start prototyping the change. With luck you'll lure someone it to help. Personally I'm interested, but busy. Realistically the best I can offer is comments and feedback, which making a public repo where code is easily seen will make that much easier. 

-David

Karthik Chandrashekara

unread,
Dec 22, 2025, 10:08:56 AM12/22/25
to the labscript suite
Hi Shawn (and others!),

I would also like to point out this live plot panel (add-on?) that was developed in Jean-Philippe Brantut's group at EPFL:  

https://github.com/LQG-EPFL/analysis_plot_panel 


I do not know if it will serve your exact needs but there is already an option to interactively define an ROI. It was pretty much ready to use for us but we still modified it to our requirements for more extensive on-the-fly analysis of our absorption images and has matured in to a version of its own which I can also share if you like!
Reply all
Reply to author
Forward
0 new messages