fish-quant / fq-imjoy

ImJoy plugins to run different smFISH analysis in a user-friendly setting.
https://fq-imjoy.readthedocs.io/en/latest/
MIT License
2 stars 1 forks source link

'Analyze current image' not working #27

Closed jstitlow closed 3 years ago

jstitlow commented 3 years ago

Greetings, this is a really cool project! Have been using FQ in Matlab for years and we now have a quirky situation that calls for open source smFISH analysis with a GUI, so thanks!

Describe the bug Spot detection with FG-Imjoy takes a very long time. I suspect there is something wrong, because file processing has not finished after several hours, even though I have cropped the image down to 115x115x5 and chosen a threshold that detects only < 100 spots.

Shortly after the app hangs, there is a Python error message in the Chrome log: File "/Users/joshtitlow/Library/Python/3.7/lib/python/site-packages/matplotlib/figure.py", line 428, in show manager = getattr(self.canvas, 'manager') AttributeError: 'FigureCanvasAgg' object has no attribute 'manager'

To Reproduce Not sure,

Logs

FISH-QUANT_nlnxi1609564245421.txt

Chrome_console_FG-Imjoy.log

Screenshots image

Versions:

Additional context Add any other context about the problem here.

jstitlow commented 3 years ago

UPDATE

Any idea how to fix the AttributeError or do you think there is a different problem?

Thanks! j

muellerflorian commented 3 years ago

Thanks for the detailed bug report. For the moment, I can't reproduce it (but I'm not on a Mac).

a first comment, we pinned the versions of all libraries (with the hope to avoid problems like this :-) ): https://github.com/fish-quant/big-fish/blob/master/requirements.txt

could you try one thing? for demo purposes, you can actually run the engine on myminder.org. For this, you have to

  1. connect to a mybinder engine (button + Add MyBinder-Engine in the engine meny in the upper right corner).
  2. Run FISH-quant plugin on this engine (from the dropdown menu when clicking on the puzzle symbol left of the plugin name). Starting might take a bit of time.
  3. after starting FISH-quant, you can get test data by clicking on the "get zipped data".
  4. from there one, the workflow is as usual (most fields contain some useful default values).

If this works, you can connect the plugin to your local engine, and attempt to analyze the test data with ImJoy running locally.

In the meantime, I'm going to have a closer look myself.

jstitlow commented 3 years ago

Thanks.

muellerflorian commented 3 years ago

thanks for the feedback. so there really seems to be an issue with creating Matplotlib plots locally.

concerning your question. If you click on puzzle symbol next to the plugin name, you will get a dropdown menu. Here, all engines ImJoy is connected to will be shown. The local one will be called "Jupyter Notebook" if you kept the default name.

image

oeway commented 3 years ago

Hi @jstitlow I cannot reproduce your issue on my Mac, but I made a custom version for you with matplotlib pinned to 2.2.3, could you please try it here: launch ImJoy and let us know if it works for you.

The only changed I made is to pin matplotlib to 2.2.3 here.

jstitlow commented 3 years ago

Thanks, the custom version gives the same result. Something could be wrong with my conda environment. Can we exchange .yml files (mine is here)? Maybe mine will reproduce the error in your environment, or yours will work in my environment?

Regarding Florian's suggestion to switch to the local jupyter engine, when I select the Jupyter Notebook engine, the plugin reloads and no longer works. Here is what I did:

  1. open imjoy app
  2. add MyBinder engine
  3. click FISH-QUANT puzzle icon and select Jupyter Notebook
  4. it asks me to Please connect to the plugin engine
  5. I click the Jupyter-Engine Manager puzzle icon and select reload
  6. it says Failed to connect to plugin engine
  7. I click the spaceship icon and Add Jupyter Engine
  8. The engine connects, but FISH-QUANT behavior is the same

Does this experiment confirm that my jupyter kernel is the issue, since I am now presumably running a working FQ plugin from binder on my local machine?

Thanks, and sorry for the distraction.

oeway commented 3 years ago

Hi, I just created new environment based on your yml file, and I can successfully run the plugin, see the screen recording below:

fish-quant-startup

As you see above, to make sure you are using your local engine, you need to make sure 1) the Jupyter Engine engine is connected 2) the engine is selected as the plugin engine for fish-quant.

However, I just noticed one thing in your error log:

JupyterConnection.js:62 Traceback (most recent call last):
  File "/Users/joshtitlow/Library/Python/3.7/lib/python/site-packages/matplotlib/figure.py", line 428, in show
    manager = getattr(self.canvas, 'manager')
AttributeError: 'FigureCanvasAgg' object has no attribute 'manager'

This perhaps means you are running your system installed Python instead of the one from conda, this means the PATH env variable is not configured correctly. Could you try to run which python3 and you should see something like /Users/wei.ouyang/miniconda3/envs/fq-imjoy/bin/python3

Then you can also try, see if it runs with this:

python3 -m imjoy --jupyter

And connect it via Add Jupyter Engine in ImJoy.

jstitlow commented 3 years ago

Thanks for the suggestions and screen recording.

It's working now.

I ran imjoy --jupyter from conda base environment, and when I opened imjoy, it looks to have setup the environment properly.

muellerflorian commented 3 years ago

little follow-up.

thanks @oeway for figuring this out!

@jstitlow: any suggestions for how we can improve the documentation to avoid this problem for future users?

jstitlow commented 3 years ago

I’m still not sure what the issue was exactly. I think it would just get filed under the existing FAQ ‘Remove Conda Environment’ The solution was to start imjoy from the conda base environment, so maybe add an additional suggestion to the existing FAQ as shown below.

  1. Open anaconda terminal
  2. Activate base environment: conda deactivate
  3. Remove fq-imjoy environment: conda env remove --name fq-imjoy or

    1. Open anaconda terminal
    2. Activate base environment: conda activate
    3. Run imjoy from base environment: imjoy --jupyter
    4. When imjoy opens, it will setup the environment properly

From: Florian Mueller notifications@github.com Reply-To: fish-quant/fq-imjoy reply@reply.github.com Date: Wednesday, January 6, 2021 at 2:01 AM To: fish-quant/fq-imjoy fq-imjoy@noreply.github.com Cc: Me jstitlow@gmail.com, Mention mention@noreply.github.com Subject: Re: [fish-quant/fq-imjoy] 'Analyze current image' not working (#27)

little follow-up.

thanks @oewayhttps://github.com/oeway for figuring this out!

@jstitlowhttps://github.com/jstitlow: any suggestions for how we can improve the documentation to avoid this problem for future users?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/fish-quant/fq-imjoy/issues/27#issuecomment-755123823, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABMMCBRF7UVLXZSAQQE2QN3SYQDDJANCNFSM4VQZ252Q.

muellerflorian commented 3 years ago

thanks for the feedback.

based on Wei's comments, it seems that your initial attempts were done with the system python and not the anaconda one.

Ideally, we would like to avoid running it out of the base environment since this environment might get easily corrupted by other updates. The plugin engine doesn't handle the environments, it runs in whatever environment you decided to install it.

I'm still surprised, that it didn't work when using a dedicated environment ... essentially what you need to do:

Installation (only once)

  1. conda create --name fq-imjoy python=3.7
  2. conda activate fq-imjoy
  3. pip install -U imjoy

Starting engine (each time you want to use it).

  1. conda activate fq-imjoy
  2. imjoy --jupyter