-
Notifications
You must be signed in to change notification settings - Fork 52
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
Images being processed but not saved #682
Comments
Did a little digging. The number 100 happens to be the size of the notification queue in Acquire class. Change to 150 and that is where it stalls out..... |
Hopefully fixed by #685 I'm going to add a test for this now Btw, I made some improvements to headless mode, so there is a now a |
Great. So it looks like you’ve commited the rest of the changes for the notification API… I will play with this as well. Is the documentation updated?
Carl
…----------------------------------------------------------
Dr. Carl Kesselman
William H. Keck Professor of Engineering
Professor, Epstein Department of Industrial and Systems Engineering
Fellow, Information Sciences Institute
Viterbi School of Engineering
Professor, Department of Population and Public Health Sciences, Keck School of Medicine
Professor, Biomedical Sciences, Ostrow School of Dentistry
University of Southern California
4676 Admiralty Way, Suite 1001, Marina del Rey, CA 90292-6695
Phone: +1 (310) 448-9338
Email: ***@***.***
Web: http://www.isi.edu/~carl
On Sep 7, 2023 at 8:32 AM -0700, Henry Pinkard ***@***.***>, wrote:
Hopefully fixed by #685<https://urldefense.us/v2/url?u=https-3A__github.com_micro-2Dmanager_pycro-2Dmanager_pull_685&d=DwMCaQ&c=qzHnJIRvjI6L-clJH8JwLQvf_Iq43fzikf6aoxZgMb8&r=sGCma2ufaUVT-N141kRIZQ&m=FOkEKq-dYiTxtbcx-fUeY5dvAJSvWfYwuigoq1sH4T8AQVdotsd34ECvqT3u7w_5&s=Jh2KL09qdMKE5e4EuIShlFRMhbITwaQuTYfTdRyKovg&e=>
I'm going to add a test for this now
Btw, I made some improvements to headless mode, so there is a now a stop_headless() so you shouldn't have to terminate manually.
—
Reply to this email directly, view it on GitHub<https://urldefense.us/v2/url?u=https-3A__github.com_micro-2Dmanager_pycro-2Dmanager_issues_682-23issuecomment-2D1710362644&d=DwMCaQ&c=qzHnJIRvjI6L-clJH8JwLQvf_Iq43fzikf6aoxZgMb8&r=sGCma2ufaUVT-N141kRIZQ&m=FOkEKq-dYiTxtbcx-fUeY5dvAJSvWfYwuigoq1sH4T8AQVdotsd34ECvqT3u7w_5&s=HE3InKv2_c-0Ljfofg2PFpy6z0s_YCas2Ayfjid09QY&e=>, or unsubscribe<https://urldefense.us/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AA3OGXU5HYTMORBFHYKRBATXZHSH5ANCNFSM6AAAAAA4METWC4&d=DwMCaQ&c=qzHnJIRvjI6L-clJH8JwLQvf_Iq43fzikf6aoxZgMb8&r=sGCma2ufaUVT-N141kRIZQ&m=FOkEKq-dYiTxtbcx-fUeY5dvAJSvWfYwuigoq1sH4T8AQVdotsd34ECvqT3u7w_5&s=wZtg-p8oi2equj2SWN_wmNZi-hmWVMivbEtsywOe6pY&e=>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Great! No not yet. I'm making some examples/tests right now. Curious to hear what you think--changes can certainly be made if you have ideas for improvement. |
There's also the python backend now: |
You'll also need the latest CI build to test if you don't want to wait until tomorrows nightly build |
Added test based on your example: #689 |
Here's test code for receiving notifications: from pycromanager import Acquisition, multi_d_acquisition_events, AcqNotification
import time
import numpy as np
events = multi_d_acquisition_events(num_time_points=10, time_interval_s=0)
print_notification_fn = lambda x: print(x.to_json())
start = time.time()
with Acquisition(directory='C:\\Users\\henry\\Desktop\\data', name='acq', notification_callback_fn=print_notification_fn,
show_display=False) as acq:
start = time.time()
future = acq.acquire(events)
future.await_execution({'time': 5}, AcqNotification.Hardware.POST_HARDWARE)
print('time point 5 post hardware')
image = future.await_image_saved({'time': 5}, return_image=True)
print('time point 5 image saved ', time.time() - start, '\t\tmean image value: ', np.mean(image))
images = future.await_image_saved([{'time': 7}, {'time': 8}, {'time': 9}], return_image=True)
assert (len(images) == 3)
for image in images:
print('mean of image in stack: ', np.mean(image))
# Make sure the returned images were the correct ones
on_disk = [acq.get_dataset().read_image(time=t) for t in [7, 8, 9]]
assert all([np.all(on_disk[i] == images[i]) for i in range(3)])
|
So with the Python backend, the image_saved_fn callback will not be called and the acquisition engine will not write the ndtiff? I like the idea of no Java (I never bothered to learn Java), but would like to make sure that I don’t end up an extra copy operation on the acquisition, which seems to be what happens when you define the callback with the java backend (looks like the java engine sends the image to python for processing by the callback, and then back again)
So assuming I’m still using NDTiff, I would need to open the file and set the image_process_fn to do the write myself (rendering the directory argument useless?). I assume that I would save the image and then return None in the image argument from the callback?
Does this sound correct?
Carl
…----------------------------------------------------------
Dr. Carl Kesselman
William H. Keck Professor of Engineering
Professor, Epstein Department of Industrial and Systems Engineering
Fellow, Information Sciences Institute
Viterbi School of Engineering
Professor, Department of Population and Public Health Sciences, Keck School of Medicine
Professor, Biomedical Sciences, Ostrow School of Dentistry
University of Southern California
4676 Admiralty Way, Suite 1001, Marina del Rey, CA 90292-6695
Phone: +1 (310) 448-9338
Email: ***@***.***
Web: http://www.isi.edu/~carl
On Sep 7, 2023, at 10:56 AM, Henry Pinkard ***@***.***> wrote:
There's also the python backend now: start_headless(python_backed=True). No file saving built in, so you have to use an image processor to divert images if you don't want to fill up RAM. Not sure if this fits your use case or not, but if you try it, let me know how it goes
—
Reply to this email directly, view it on GitHub<https://urldefense.us/v2/url?u=https-3A__github.com_micro-2Dmanager_pycro-2Dmanager_issues_682-23issuecomment-2D1710563059&d=DwMCaQ&c=qzHnJIRvjI6L-clJH8JwLQvf_Iq43fzikf6aoxZgMb8&r=sGCma2ufaUVT-N141kRIZQ&m=EUDQ0OMDLafw12eknQ8aE0wqu9vuNbRdkE_Fc1wv4DdUIW1_O-4s1dqg2ZVCsJTv&s=ewZMS4Avg0ifskuKXfXXIvykexOM4g5TKzzYwSqTd-M&e=>, or unsubscribe<https://urldefense.us/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AA3OGXQCKQGVP2SJOLQ7SVLXZIDDZANCNFSM6AAAAAA4METWC4&d=DwMCaQ&c=qzHnJIRvjI6L-clJH8JwLQvf_Iq43fzikf6aoxZgMb8&r=sGCma2ufaUVT-N141kRIZQ&m=EUDQ0OMDLafw12eknQ8aE0wqu9vuNbRdkE_Fc1wv4DdUIW1_O-4s1dqg2ZVCsJTv&s=RgxUSoVFMg-WH-m_3lwcKhkX36ciA8YYOTHSJeLb0m0&e=>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Right now, the image_saved_fn still gets called (when the image "saves" to RAM)--Im not sure I actually tested it though. No saving to NDTiff, as the writer code for this lives in Java. image_saved_fn and and image processors are pretty similar in python backend, with the difference being that the later allows you to prevent the image from being stored in memory in python (and accessible via a
Yes exactly, there is an inefficient copy/serialization that should be avoidable with the python backend. I made a python engine that is essentially a line-for-line copy of the Java one. So the nice thing about this is if you find bugs/improvements in the python engine, you can PR them and then it will be easy to improve the Java engine simultaneously.
Yes, with the python backend you should get an error if you pass directory. If you implement an image processor that returns |
Ahh, so here’s the rub… There is no way to write NDTiff from Python. I suppose I can just write the raw images, or write Zarr myself, or even …gasp… use OME-Zarr?
Thoughts? Perhaps there is a way to spool out of the in memory copy to an on disk version?
Carl
…----------------------------------------------------------
Dr. Carl Kesselman
William H. Keck Professor of Engineering
Professor, Epstein Department of Industrial and Systems Engineering
Fellow, Information Sciences Institute
Viterbi School of Engineering
Professor, Department of Population and Public Health Sciences, Keck School of Medicine
Professor, Biomedical Sciences, Ostrow School of Dentistry
University of Southern California
4676 Admiralty Way, Suite 1001, Marina del Rey, CA 90292-6695
Phone: +1 (310) 448-9338
Email: ***@***.***
Web: http://www.isi.edu/~carl
On Sep 7, 2023, at 1:31 PM, Henry Pinkard ***@***.***> wrote:
So with the Python backend, the image_saved_fn callback will not be called and the acquisition engine will not write the ndtiff?
Right now, the image_saved_fn still gets called (when the image "saves" to RAM)--Im not sure I actually tested it though. No saving to NDTiff, as the writer code for this lives in Java. image_saved_fn and and image processors are pretty similar in python backend, with the difference being that the later allows you to prevent the image from being stored in memory in python (and accessible via a Dataset)
I like the idea of no Java (I never bothered to learn Java), but would like to make sure that I don’t end up an extra copy operation on the acquisition, which seems to be what happens when you define the callback with the java backend (looks like the java engine sends the image to python for processing by the callback, and then back again)
Yes exactly, there is an inefficient copy/serialization that should be avoidable with the python backend.
I made a python engine that is essentially a line-for-line copy of the Java one. So the nice thing about this is if you find bugs/improvements in the python engine, you can PR them and then it will be easy to improve the Java engine simultaneously.
So assuming I’m still using NDTiff, I would need to open the file and set the image_process_fn to do the write myself (rendering the directory argument useless?). I assume that I would save the image and then return None in the image argument from the callback?
Yes, with the python backend you should get an error if you pass directory. If you implement an image processor that returns None then you can save the images yourself. Or if you implement a an image_save_fn, the images will be stored in a Dataset in RAM
—
Reply to this email directly, view it on GitHub<https://urldefense.us/v2/url?u=https-3A__github.com_micro-2Dmanager_pycro-2Dmanager_issues_682-23issuecomment-2D1710733531&d=DwMFaQ&c=qzHnJIRvjI6L-clJH8JwLQvf_Iq43fzikf6aoxZgMb8&r=sGCma2ufaUVT-N141kRIZQ&m=bsJAmQ2xpbR0ssS_iVmLA9HsKCJQcvlghMCQYzf6dmE_1lRufi1HU2qZ7FHcgHl4&s=3qNihNnnVP9msf_AvUsdB3c6AiNc0hYDj9OZMbxLv5g&e=>, or unsubscribe<https://urldefense.us/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AA3OGXUAJRGZW3Z4A6GHOUDXZIVIXANCNFSM6AAAAAA4METWC4&d=DwMFaQ&c=qzHnJIRvjI6L-clJH8JwLQvf_Iq43fzikf6aoxZgMb8&r=sGCma2ufaUVT-N141kRIZQ&m=bsJAmQ2xpbR0ssS_iVmLA9HsKCJQcvlghMCQYzf6dmE_1lRufi1HU2qZ7FHcgHl4&s=i9VS9N3zc9EOVZy9Z98I7cjVnJY_k2clNyPx7ApClnA&e=>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Correct, there's no NDTiff writing from python. And this doesn't seem likely to be added anytime soon, because better to focus on new file saving in the c++ layer (micro-manager/mmCoreAndDevices#323), which would be faster than NDTiff and available from Java and Python. As far as I know, Zarr and anything based on it currently lacks the features to be really fast. But I don't actually know what that the limit of its performance is. So if you're saving to disk and NDTiff is good enough, probably best to stick with the Java backend. Though the python backend can still be a useful tool to swap in at times for debugging |
Got it.
Carl
…----------------------------------------------------------
Dr. Carl Kesselman
William H. Keck Professor of Engineering
Professor, Epstein Department of Industrial and Systems Engineering
Fellow, Information Sciences Institute
Viterbi School of Engineering
Professor, Department of Population and Public Health Sciences, Keck School of Medicine
Professor, Biomedical Sciences, Ostrow School of Dentistry
University of Southern California
4676 Admiralty Way, Suite 1001, Marina del Rey, CA 90292-6695
Phone: +1 (310) 448-9338
Email: ***@***.***
Web: http://www.isi.edu/~carl
On Sep 7, 2023, at 2:39 PM, Henry Pinkard ***@***.***> wrote:
Correct, there's no NDTiff writing from python. And this doesn't seem likely to be added anytime soon, because better to focus on new file saving in the c++ layer (micro-manager/mmCoreAndDevices#323<https://urldefense.us/v2/url?u=https-3A__github.com_micro-2Dmanager_mmCoreAndDevices_issues_323&d=DwMCaQ&c=qzHnJIRvjI6L-clJH8JwLQvf_Iq43fzikf6aoxZgMb8&r=sGCma2ufaUVT-N141kRIZQ&m=ZOm5gpXsNzrmZI8pUufUoW8rzFZ96SbXST3qpG4oPA-P1JAXYEY2OolsaLOIxmlQ&s=DJvVnVEculSZwxkCovMTiPmOYP-THbHRPsVK8HnMBJ8&e=>), which would be faster than NDTiff and available from Java and Python.
As far as I know, Zarr and anything based on it currently lacks the features<https://urldefense.us/v2/url?u=https-3A__github.com_micro-2Dmanager_micro-2Dmanager_issues_1243-23issuecomment-2D1594932561&d=DwMCaQ&c=qzHnJIRvjI6L-clJH8JwLQvf_Iq43fzikf6aoxZgMb8&r=sGCma2ufaUVT-N141kRIZQ&m=ZOm5gpXsNzrmZI8pUufUoW8rzFZ96SbXST3qpG4oPA-P1JAXYEY2OolsaLOIxmlQ&s=rfkt0xq5fwohJh213bvCYTQS2Ou6BN2AmTa2VlDpqFc&e=> to be really fast. But I don't actually know what that the limit of its performance is.
So if you're saving to disk and NDTiff is good enough, probably best to stick with the Java backend. Though the python backend can still be a useful tool to swap in at times for debugging
—
Reply to this email directly, view it on GitHub<https://urldefense.us/v2/url?u=https-3A__github.com_micro-2Dmanager_pycro-2Dmanager_issues_682-23issuecomment-2D1710801929&d=DwMCaQ&c=qzHnJIRvjI6L-clJH8JwLQvf_Iq43fzikf6aoxZgMb8&r=sGCma2ufaUVT-N141kRIZQ&m=ZOm5gpXsNzrmZI8pUufUoW8rzFZ96SbXST3qpG4oPA-P1JAXYEY2OolsaLOIxmlQ&s=UxLQzOF-zZhOYQ3w48dOGtQaN9gGYO1coFM-ZG_CgW0&e=>, or unsubscribe<https://urldefense.us/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AA3OGXXHIM6FJLVODR63NHTXZI5JLANCNFSM6AAAAAA4METWC4&d=DwMCaQ&c=qzHnJIRvjI6L-clJH8JwLQvf_Iq43fzikf6aoxZgMb8&r=sGCma2ufaUVT-N141kRIZQ&m=ZOm5gpXsNzrmZI8pUufUoW8rzFZ96SbXST3qpG4oPA-P1JAXYEY2OolsaLOIxmlQ&s=orae1KcStridfiwkCjljcKf4TMvH0qOm5hyFc6MKwlI&e=>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
FYI…. for the first time since I’ve started, I was able to complete a 2 hour, three camera run, with Z-stack from the SPIM (hamamatsu camera) and two other observational cameras at 40FPS (Basler). This includes setting ROI and controlling all aspects from my python control program.
Success!!
Carl
…----------------------------------------------------------
Dr. Carl Kesselman
William H. Keck Professor of Engineering
Professor, Epstein Department of Industrial and Systems Engineering
Fellow, Information Sciences Institute
Viterbi School of Engineering
Professor, Department of Population and Public Health Sciences, Keck School of Medicine
Professor, Biomedical Sciences, Ostrow School of Dentistry
University of Southern California
4676 Admiralty Way, Suite 1001, Marina del Rey, CA 90292-6695
Phone: +1 (310) 448-9338
Email: ***@***.***
Web: http://www.isi.edu/~carl
On Sep 7, 2023, at 3:16 PM, Carl Kesselman ***@***.***> wrote:
Got it.
Carl
----------------------------------------------------------
Dr. Carl Kesselman
William H. Keck Professor of Engineering
Professor, Epstein Department of Industrial and Systems Engineering
Fellow, Information Sciences Institute
Viterbi School of Engineering
Professor, Department of Population and Public Health Sciences, Keck School of Medicine
Professor, Biomedical Sciences, Ostrow School of Dentistry
University of Southern California
4676 Admiralty Way, Suite 1001, Marina del Rey, CA 90292-6695
Phone: +1 (310) 448-9338
Email: ***@***.***
Web: http://www.isi.edu/~carl
On Sep 7, 2023, at 2:39 PM, Henry Pinkard ***@***.***> wrote:
Correct, there's no NDTiff writing from python. And this doesn't seem likely to be added anytime soon, because better to focus on new file saving in the c++ layer (micro-manager/mmCoreAndDevices#323<https://urldefense.us/v2/url?u=https-3A__github.com_micro-2Dmanager_mmCoreAndDevices_issues_323&d=DwMCaQ&c=qzHnJIRvjI6L-clJH8JwLQvf_Iq43fzikf6aoxZgMb8&r=sGCma2ufaUVT-N141kRIZQ&m=ZOm5gpXsNzrmZI8pUufUoW8rzFZ96SbXST3qpG4oPA-P1JAXYEY2OolsaLOIxmlQ&s=DJvVnVEculSZwxkCovMTiPmOYP-THbHRPsVK8HnMBJ8&e=>), which would be faster than NDTiff and available from Java and Python.
As far as I know, Zarr and anything based on it currently lacks the features<https://urldefense.us/v2/url?u=https-3A__github.com_micro-2Dmanager_micro-2Dmanager_issues_1243-23issuecomment-2D1594932561&d=DwMCaQ&c=qzHnJIRvjI6L-clJH8JwLQvf_Iq43fzikf6aoxZgMb8&r=sGCma2ufaUVT-N141kRIZQ&m=ZOm5gpXsNzrmZI8pUufUoW8rzFZ96SbXST3qpG4oPA-P1JAXYEY2OolsaLOIxmlQ&s=rfkt0xq5fwohJh213bvCYTQS2Ou6BN2AmTa2VlDpqFc&e=> to be really fast. But I don't actually know what that the limit of its performance is.
So if you're saving to disk and NDTiff is good enough, probably best to stick with the Java backend. Though the python backend can still be a useful tool to swap in at times for debugging
—
Reply to this email directly, view it on GitHub<https://urldefense.us/v2/url?u=https-3A__github.com_micro-2Dmanager_pycro-2Dmanager_issues_682-23issuecomment-2D1710801929&d=DwMCaQ&c=qzHnJIRvjI6L-clJH8JwLQvf_Iq43fzikf6aoxZgMb8&r=sGCma2ufaUVT-N141kRIZQ&m=ZOm5gpXsNzrmZI8pUufUoW8rzFZ96SbXST3qpG4oPA-P1JAXYEY2OolsaLOIxmlQ&s=UxLQzOF-zZhOYQ3w48dOGtQaN9gGYO1coFM-ZG_CgW0&e=>, or unsubscribe<https://urldefense.us/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AA3OGXXHIM6FJLVODR63NHTXZI5JLANCNFSM6AAAAAA4METWC4&d=DwMCaQ&c=qzHnJIRvjI6L-clJH8JwLQvf_Iq43fzikf6aoxZgMb8&r=sGCma2ufaUVT-N141kRIZQ&m=ZOm5gpXsNzrmZI8pUufUoW8rzFZ96SbXST3qpG4oPA-P1JAXYEY2OolsaLOIxmlQ&s=orae1KcStridfiwkCjljcKf4TMvH0qOm5hyFc6MKwlI&e=>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Awesome!! Thanks for all your testing, suggestions, and PRs--they've really made pycromanager a lot better for everyone |
Bug report
The following test case seems to hang after saving 100 out of the 200 images in the acquisition. All of the images are processed, but onlly 100 are saved.
Version Info
The text was updated successfully, but these errors were encountered: