maurosilber / SMO

Robust and unbiased estimation of the background distribution for fluorescence microscopy.
MIT License
12 stars 4 forks source link

CellProfiler SMO plugin error (UnboundLocalError: local variable 'y_data' referenced before assignment) #6

Open iuri-cv opened 2 weeks ago

iuri-cv commented 2 weeks ago

Hi, I get the following error message when running the SMO plugin in CellProfiler:

Worker 2: Running module SMO 7 Worker 2: run_image_set_exception, get_always_continue False Worker 2: Error detected during run of module SMO#7 Worker 2: Traceback (most recent call last): Worker 2: File "/home/iuri/cp4_8/lib/python3.8/site-packages/cellprofiler_core/pipeline/_pipeline.py", line 1208, in run_image_set Worker 2: self.run_module(module, workspace) Worker 2: File "/home/iuri/cp4_8/lib/python3.8/site-packages/cellprofiler_core/pipeline/_pipeline.py", line 1349, in run_module Worker 2: module.run(workspace) Worker 2: File "/home/iuri/cp4_8/CellProfiler-plugins/active_plugins/smo.py", line 202, in run Worker 2: image=y_data.data, Worker 2: UnboundLocalError: local variable 'y_data' referenced before assignment

Any idea on how to solve this ? Thanks in advance.

maurosilber commented 2 weeks ago

y_data is defined here:

https://github.com/maurosilber/SMO/blob/7a67de920ad75cab1c7f6c5b8695543cb509004b/smo/plugins/cellprofiler/smo.py#L185-L198

In that if-elif chain, I didn't consider the possibility of a different output choice than the ones there. Could it be that you didn't select any option at all?

Otherwise, there might have been some changes in CellProfiler since I developed the plugin. What version are you using?

iuri-cv commented 2 weeks ago

Thanks for the quick reply. I get the same error whether selecting "Background correction" or any other output choice. I've tried the SMO plugin with CellProfiler 4.2.1 (Windows) and CellProfiler 4.2.6 (Linux/Ubuntu). I get the same error with both.

maurosilber commented 2 weeks ago

I just downloaded 4.2.7 and added the SMO plugin. It seems to work with "Start test mode", but with "Analyze Images" I get the same error as you do.

iuri-cv commented 2 weeks ago

Yes, it also works for me in test mode. When checking the question mark to the side of the selected option in "Output choice" I noticed this message: image Maybe it has something to do with the error ?

iuri-cv commented 2 weeks ago

Just to let you know I've managed to run the SMO plugin for Fiji within a macro. It seems to take ~7 seconds per image (2048x1536 pixels).

maurosilber commented 2 weeks ago

Great. I'll try to see if I can fix the issue with the CellProfiler plugin later. The problem seems to be that "Analyze Images" uses multiple threads and needs to serialize the plugin with JSON.