glue-viz / bqplot-image-gl

Jupyter widget for displaying images with a focus on astronomy
MIT License
20 stars 15 forks source link

feat: mouse move events exposed #37

Closed maartenbreddels closed 3 years ago

maartenbreddels commented 3 years ago

This allows for capturing mouse events, with a demo that shows an image pixel coordinate and its value. image

pllim commented 3 years ago

This looks very promising, thanks! Does it work the same for mouse clicks (left, right, etc)?

For example: I want to extract the X, Y when I left-click on a star -- how do I do that?

maartenbreddels commented 3 years ago

good question, added: ![Uploading image.png…]()

pllim commented 3 years ago

error: can't copy 'bqplot-image-gl.json': doesn't exist or not a regular file

Maybe if you delete this line, it will proceed further...

https://github.com/glue-viz/bqplot-image-gl/blob/4eea0ada74610b7a3d6739a07475fbf43306a798/MANIFEST.in#L2

pllim commented 3 years ago

Ops, sorry... That wasn't it. Maybe this one:

https://github.com/glue-viz/bqplot-image-gl/blob/4eea0ada74610b7a3d6739a07475fbf43306a798/setup.py#L139

😬

maartenbreddels commented 3 years ago

trying include etc/jupyter/nbconfig/notebook.d/bqplot-image-gl.json now, no idea why this happens all of the sudden, but Python packaging is always like this :)

codecov[bot] commented 3 years ago

Codecov Report

Merging #37 (579fd98) into master (3058ac5) will decrease coverage by 0.78%. The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #37      +/-   ##
==========================================
- Coverage   66.66%   65.88%   -0.79%     
==========================================
  Files           5        5              
  Lines          84       85       +1     
==========================================
  Hits           56       56              
- Misses         28       29       +1     
Impacted Files Coverage Δ
bqplot_image_gl/interacts.py 0.00% <0.00%> (ø)
bqplot_image_gl/_version.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 4eea0ad...579fd98. Read the comment docs.

pllim commented 3 years ago

Nice, got some green now!

maartenbreddels commented 3 years ago

Yes, do you want to try it out first? PS: ignore codecov for now, I think it's done.

pllim commented 3 years ago

do you want to try it out first?

I could but not till next week. Don't let me block this from merging.

rosteen commented 3 years ago

I tried this out on Friday and while no errors were thrown, the figure cell in mouse.ipynb wouldn't actually display the figure, so I was unable to confirm that the new feature works. It's unclear to me at this point whether the problem is due to this PR or something else in my stack, although I did try again in a fresh environment and had the same problem.

maartenbreddels commented 3 years ago

Did you do this on lab or notebook? and did you compare to a release or master?

rosteen commented 3 years ago

I guess I should include enough information to actually be useful, eh?

I just checked and I have the same problem on the master with that example notebook, so it's not this PR. I'm running via jupyter notebook examples/mouse.ipynb, not on lab. Hmm...

Some relevant installed versions:

bqplot 0.12.21 ipywidgets 7.6.3 jupyter-client 6.1.11 jupyter-core 4.7.1 widgetsnbextension 3.5.1

pllim commented 3 years ago

Not working for me either (in notebook): Image not showing and nothing happens when I mouse over the plot area where the image is supposed to appear.. I tried both pip install git+https://... from this branch and also pip install . from a local checkout of this branch. I see the following warnings on terminal but not sure what to make of them:

[W 13:50:51.657 NotebookApp] 404 GET /nbextensions/pep8_magic.js?v=20210208135018 (::1) 41.93ms referer=http://localhost:8888/notebooks/mouse.ipynb
[W 13:50:51.658 NotebookApp] 404 GET /nbextensions/pep8_magic/main.js?v=20210208135018 (::1) 42.55ms referer=http://localhost:8888/notebooks/mouse.ipynb
[W 13:50:51.659 NotebookApp] 404 GET /nbextensions/pep8.js?v=20210208135018 (::1) 42.81ms referer=http://localhost:8888/notebooks/mouse.ipynb
[W 13:50:51.659 NotebookApp] 404 GET /nbextensions/pep8--user.js?v=20210208135018 (::1) 43.07ms referer=http://localhost:8888/notebooks/mouse.ipynb
[W 13:50:51.666 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20210208135018 (::1) 1.18ms referer=http://localhost:8888/notebooks/mouse.ipynb

pip install -e . also does not work with a slightly different problem: figure does not even show empty plot.

Some version info; will be happy to provide more if I didn't give you enough info:

Python 3.8.3 (default, May 19 2020, 18:47:26) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
# Name                    Version                   Build  Channel
bqplot                    0.12.21                  pypi_0    pypi
glue-astronomy            0.1                      pypi_0    pypi
glue-core                 1.0.1                    pypi_0    pypi
glue-jupyter              0.2.1                    pypi_0    pypi
glue-vispy-viewers        1.0.2                    pypi_0    pypi
ipydatawidgets            4.2.0                    pypi_0    pypi
ipyevents                 0.8.0                    pypi_0    pypi
ipygoldenlayout           0.3.0                    pypi_0    pypi
ipykernel                 5.3.2                    pypi_0    pypi
ipympl                    0.6.3                    pypi_0    pypi
ipysplitpanes             0.1.0                    pypi_0    pypi
ipython                   7.15.0                   py38_0  
ipython_genutils          0.2.0              pyhd3eb1b0_1  
ipyvolume                 0.5.2                    pypi_0    pypi
ipyvue                    1.5.0                    pypi_0    pypi
ipyvuetify                1.6.1                    pypi_0    pypi
ipywebrtc                 0.5.0                    pypi_0    pypi
ipywidgets                7.6.3                    pypi_0    pypi
jupyter-client            6.1.6                    pypi_0    pypi
jupyter-core              4.6.3                    pypi_0    pypi
jupyter-server            1.2.2                    pypi_0    pypi
jupyterlab                2.1.5                    pypi_0    pypi
jupyterlab-pygments       0.1.2                    pypi_0    pypi
jupyterlab-server         1.2.0                    pypi_0    pypi
jupyterlab-widgets        1.0.0                    pypi_0    pypi
pyopengl                  3.1.5                    pypi_0    pypi
widgetsnbextension        3.5.1                    pypi_0    pypi
pllim commented 3 years ago

Just for completeness, if you meant if I tried with both stable and dev bqplot, I only tried with stable because I could not install the dev version of bqplot checked out from its default branch using pip install ..

  Building wheel for bqplot (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: .../python .../pep517/_in_process.py build_wheel /tmp/...
       cwd: /tmp/...
  Complete output (50 lines):
  running bdist_wheel
  running jsdeps
  Installing build dependencies with npm.  This may take a while...
  > yarn install
  yarn install v1.22.10
  [1/4] Resolving packages...
  [2/4] Fetching packages...
  error human-signals@2.1.0: The engine "node" is incompatible with this module. Expected version ">=10.17.0". Got "10.13.0"

conda does not give me nodejs that is newer than 10.13. 🤷

pllim commented 3 years ago

So, I got the mouse event to work but not using your ImageGL. Instead I used HeatMap from bqplot directly. See astropy/astrowidgets#121 for a working prototype. Turns out what I really need is your normalized_x and normalized_y, not pixel_x and pixel_y; either the math is wrong here or the usage is different for HeatMap vs ImageGL.

Screenshot 2021-02-08 161333

maartenbreddels commented 3 years ago

conda does not give me nodejs that is newer than 10.13. 🤷

you probably want to add the conda-forge channel conda install -c conda-forge nodejs

maartenbreddels commented 3 years ago

I tried reproducing the issue of not showing the image, but i could not, I have done:

$ conda create -n bqplot-image-gl -c conda-forge nodejs notebook bqplot=0.12.21 ipywidgets=7.6.3  widgetsnbextension=3.5.1
$ conda activate bqplot-image-gl   
# from the root of this repo
$ pip install .
$ jupyter notebook

and that gives me a working notebook where I see the image, could someone confirm this?

pllim commented 3 years ago

@maartenbreddels , can you please do a conda list? Thanks.

maartenbreddels commented 3 years ago
$ conda list                                                                                                                                    bqplot-image-gl
# packages in environment at /Users/maartenbreddels/miniconda3/envs/bqplot-image-gl:
#
# Name                    Version                   Build  Channel
appnope                   0.1.2            py39h6e9494a_1    conda-forge
argon2-cffi               20.1.0           py39hcbf5805_2    conda-forge
async_generator           1.10                       py_0    conda-forge
attrs                     20.3.0             pyhd3deb0d_0    conda-forge
backcall                  0.2.0              pyh9f0ad1d_0    conda-forge
backports                 1.0                        py_2    conda-forge
backports.functools_lru_cache 1.6.1                      py_0    conda-forge
bleach                    3.3.0              pyh44b312d_0    conda-forge
bqplot                    0.12.21            pyhd8ed1ab_0    conda-forge
bqplot-image-gl           1.0.0                    pypi_0    pypi
ca-certificates           2020.12.5            h033912b_0    conda-forge
certifi                   2020.12.5        py39h6e9494a_1    conda-forge
cffi                      1.14.4           py39h7786acb_1    conda-forge
decorator                 4.4.2                      py_0    conda-forge
defusedxml                0.6.0                      py_0    conda-forge
entrypoints               0.3             pyhd8ed1ab_1003    conda-forge
importlib-metadata        3.4.0            py39h6e9494a_0    conda-forge
importlib_metadata        3.4.0                hd8ed1ab_0    conda-forge
ipykernel                 5.1.0              pyh24bf2e0_0    conda-forge
ipython                   7.20.0           py39h71a6800_2    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
ipywidgets                7.6.3              pyhd3deb0d_0    conda-forge
jedi                      0.18.0           py39h6e9494a_2    conda-forge
jinja2                    2.11.3             pyh44b312d_0    conda-forge
jsonschema                3.2.0                      py_2    conda-forge
jupyter_client            6.1.11             pyhd8ed1ab_1    conda-forge
jupyter_core              4.7.1            py39h6e9494a_0    conda-forge
jupyterlab_pygments       0.1.2              pyh9f0ad1d_0    conda-forge
jupyterlab_widgets        1.0.0              pyhd8ed1ab_1    conda-forge
libblas                   3.9.0                8_openblas    conda-forge
libcblas                  3.9.0                8_openblas    conda-forge
libcxx                    11.0.1               habf9029_0    conda-forge
libffi                    3.3                  h046ec9c_2    conda-forge
libgfortran               5.0.0           9_3_0_h6c81a4c_17    conda-forge
libgfortran5              9.3.0               h6c81a4c_17    conda-forge
liblapack                 3.9.0                8_openblas    conda-forge
libopenblas               0.3.12          openmp_h54245bb_1    conda-forge
libsodium                 1.0.18               hbcb3906_1    conda-forge
llvm-openmp               11.0.1               h7c73e74_0    conda-forge
markupsafe                1.1.1            py39hcbf5805_3    conda-forge
mistune                   0.8.4           py39hcbf5805_1003    conda-forge
nbclient                  0.5.1                      py_0    conda-forge
nbconvert                 6.0.7            py39h6e9494a_3    conda-forge
nbformat                  5.1.2              pyhd8ed1ab_1    conda-forge
ncurses                   6.2                  h2e338ed_4    conda-forge
nest-asyncio              1.4.3              pyhd8ed1ab_0    conda-forge
notebook                  6.2.0            py39h6e9494a_0    conda-forge
numpy                     1.20.0           py39h3c955ea_0    conda-forge
openssl                   1.1.1i               h35c211d_0    conda-forge
packaging                 20.9               pyh44b312d_0    conda-forge
pandas                    1.2.1            py39h089d6f7_0    conda-forge
pandoc                    2.11.4               h35c211d_0    conda-forge
pandocfilters             1.4.2                      py_1    conda-forge
parso                     0.8.1              pyhd8ed1ab_0    conda-forge
pexpect                   4.8.0              pyh9f0ad1d_2    conda-forge
pickleshare               0.7.5                   py_1003    conda-forge
pip                       21.0.1             pyhd8ed1ab_0    conda-forge
prometheus_client         0.9.0              pyhd3deb0d_0    conda-forge
prompt-toolkit            3.0.14             pyha770c72_0    conda-forge
ptyprocess                0.7.0              pyhd3deb0d_0    conda-forge
pycparser                 2.20               pyh9f0ad1d_2    conda-forge
pygments                  2.7.4              pyhd8ed1ab_0    conda-forge
pyparsing                 2.4.7              pyh9f0ad1d_0    conda-forge
pyrsistent                0.17.3           py39hcbf5805_2    conda-forge
python                    3.9.1           h2502468_5_cpython    conda-forge
python-dateutil           2.8.1                      py_0    conda-forge
python_abi                3.9                      1_cp39    conda-forge
pytz                      2021.1             pyhd8ed1ab_0    conda-forge
pyzmq                     22.0.1           py39h4c39a0a_0    conda-forge
readline                  8.0                  h0678c8f_2    conda-forge
send2trash                1.5.0                      py_0    conda-forge
setuptools                49.6.0           py39h6e9494a_3    conda-forge
six                       1.15.0             pyh9f0ad1d_0    conda-forge
sqlite                    3.34.0               h17101e1_0    conda-forge
terminado                 0.9.2            py39h6e9494a_0    conda-forge
testpath                  0.4.4                      py_0    conda-forge
tk                        8.6.10               h0419947_1    conda-forge
tornado                   6.1              py39hcbf5805_1    conda-forge
traitlets                 5.0.5                      py_0    conda-forge
traittypes                0.2.1              pyh9f0ad1d_2    conda-forge
tzdata                    2021a                he74cb21_0    conda-forge
wcwidth                   0.2.5              pyh9f0ad1d_2    conda-forge
webencodings              0.5.1                      py_1    conda-forge
wheel                     0.36.2             pyhd3deb0d_0    conda-forge
widgetsnbextension        3.5.1            py39h6e9494a_4    conda-forge
xz                        5.2.5                haf1e3a3_1    conda-forge
zeromq                    4.3.4                h1c7c35f_0    conda-forge
zipp                      3.4.0                      py_0    conda-forge
zlib                      1.2.11            h7795811_1010    conda-forge
rosteen commented 3 years ago

This worked for me after following your instructions @maartenbreddels (I think specifically doing pip install . rather than pip install -e .).

pllim commented 3 years ago

It is a bit concerning that this doesn't work with some stuff from default channel... A lot of scientists just install the Anaconda thingy with default channel. But perhaps out of scope here.

maartenbreddels commented 3 years ago

It is a bit concerning that this doesn't work with some stuff from default channel... A lot of scientists just install the Anaconda thingy with default channel. But perhaps out of scope here.

Note that nodejs is only needed when building from original source, the source tarball and wheel do not require nodejs.

pllim commented 3 years ago

Still doesn't work for me even when I followed instructions at https://github.com/glue-viz/bqplot-image-gl/pull/37#issuecomment-775838085 ... This is my conda list:

# packages in environment at .../miniconda/envs/ztmp-bqplot:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       1_gnu    conda-forge
argon2-cffi               20.1.0           py39h3811e60_2    conda-forge
async_generator           1.10                       py_0    conda-forge
attrs                     20.3.0             pyhd3deb0d_0    conda-forge
backcall                  0.2.0              pyh9f0ad1d_0    conda-forge
backports                 1.0                        py_2    conda-forge
backports.functools_lru_cache 1.6.1                      py_0    conda-forge
bleach                    3.3.0              pyh44b312d_0    conda-forge
bqplot                    0.12.21            pyhd8ed1ab_0    conda-forge
bqplot-image-gl           1.0.0                    pypi_0    pypi
ca-certificates           2020.12.5            ha878542_0    conda-forge
certifi                   2020.12.5        py39hf3d152e_1    conda-forge
cffi                      1.14.4           py39he32792d_1    conda-forge
decorator                 4.4.2                      py_0    conda-forge
defusedxml                0.6.0                      py_0    conda-forge
entrypoints               0.3             pyhd8ed1ab_1003    conda-forge
icu                       68.1                 h58526e2_0    conda-forge
importlib-metadata        3.4.0            py39hf3d152e_0    conda-forge
importlib_metadata        3.4.0                hd8ed1ab_0    conda-forge
ipykernel                 5.1.0              pyh24bf2e0_0    conda-forge
ipython                   7.20.0           py39hef51801_2    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
ipywidgets                7.6.3              pyhd3deb0d_0    conda-forge
jedi                      0.18.0           py39hf3d152e_2    conda-forge
jinja2                    2.11.3             pyh44b312d_0    conda-forge
jsonschema                3.2.0                      py_2    conda-forge
jupyter_client            6.1.11             pyhd8ed1ab_1    conda-forge
jupyter_core              4.7.1            py39hf3d152e_0    conda-forge
jupyterlab_pygments       0.1.2              pyh9f0ad1d_0    conda-forge
jupyterlab_widgets        1.0.0              pyhd8ed1ab_1    conda-forge
ld_impl_linux-64          2.35.1               hea4e1c9_2    conda-forge
libblas                   3.9.0                8_openblas    conda-forge
libcblas                  3.9.0                8_openblas    conda-forge
libffi                    3.3                  h58526e2_2    conda-forge
libgcc-ng                 9.3.0               h2828fa1_18    conda-forge
libgfortran-ng            9.3.0               hff62375_18    conda-forge
libgfortran5              9.3.0               hff62375_18    conda-forge
libgomp                   9.3.0               h2828fa1_18    conda-forge
liblapack                 3.9.0                8_openblas    conda-forge
libopenblas               0.3.12          pthreads_h4812303_1    conda-forge
libsodium                 1.0.18               h36c2ea0_1    conda-forge
libstdcxx-ng              9.3.0               h6de172a_18    conda-forge
libuv                     1.40.0               h7f98852_0    conda-forge
markupsafe                1.1.1            py39h3811e60_3    conda-forge
mistune                   0.8.4           py39h3811e60_1003    conda-forge
nbclient                  0.5.1                      py_0    conda-forge
nbconvert                 6.0.7            py39hf3d152e_3    conda-forge
nbformat                  5.1.2              pyhd8ed1ab_1    conda-forge
ncurses                   6.2                  h58526e2_4    conda-forge
nest-asyncio              1.4.3              pyhd8ed1ab_0    conda-forge
nodejs                    15.3.0               h92b4a50_1    conda-forge
notebook                  6.2.0            py39hf3d152e_0    conda-forge
numpy                     1.20.0           py39hdbf815f_0    conda-forge
openssl                   1.1.1i               h7f98852_0    conda-forge
packaging                 20.9               pyh44b312d_0    conda-forge
pandas                    1.2.2            py39hde0f152_0    conda-forge
pandoc                    2.11.4               h7f98852_0    conda-forge
pandocfilters             1.4.2                      py_1    conda-forge
parso                     0.8.1              pyhd8ed1ab_0    conda-forge
pexpect                   4.8.0              pyh9f0ad1d_2    conda-forge
pickleshare               0.7.5                   py_1003    conda-forge
pip                       21.0.1             pyhd8ed1ab_0    conda-forge
prometheus_client         0.9.0              pyhd3deb0d_0    conda-forge
prompt-toolkit            3.0.14             pyha770c72_0    conda-forge
ptyprocess                0.7.0              pyhd3deb0d_0    conda-forge
pycparser                 2.20               pyh9f0ad1d_2    conda-forge
pygments                  2.7.4              pyhd8ed1ab_0    conda-forge
pyparsing                 2.4.7              pyh9f0ad1d_0    conda-forge
pyrsistent                0.17.3           py39h3811e60_2    conda-forge
python                    3.9.1           hffdb5ce_5_cpython    conda-forge
python-dateutil           2.8.1                      py_0    conda-forge
python_abi                3.9                      1_cp39    conda-forge
pytz                      2021.1             pyhd8ed1ab_0    conda-forge
pyzmq                     22.0.1           py39hea8fd45_0    conda-forge
readline                  8.0                  he28a2e2_2    conda-forge
send2trash                1.5.0                      py_0    conda-forge
setuptools                49.6.0           py39hf3d152e_3    conda-forge
six                       1.15.0             pyh9f0ad1d_0    conda-forge
sqlite                    3.34.0               h74cdb3f_0    conda-forge
terminado                 0.9.2            py39hf3d152e_0    conda-forge
testpath                  0.4.4                      py_0    conda-forge
tk                        8.6.10               h21135ba_1    conda-forge
tornado                   6.1              py39h3811e60_1    conda-forge
traitlets                 5.0.5                      py_0    conda-forge
traittypes                0.2.1              pyh9f0ad1d_2    conda-forge
tzdata                    2021a                he74cb21_0    conda-forge
wcwidth                   0.2.5              pyh9f0ad1d_2    conda-forge
webencodings              0.5.1                      py_1    conda-forge
wheel                     0.36.2             pyhd3deb0d_0    conda-forge
widgetsnbextension        3.5.1            py39hf3d152e_4    conda-forge
xz                        5.2.5                h516909a_1    conda-forge
zeromq                    4.3.4                h9c3ff4c_0    conda-forge
zipp                      3.4.0                      py_0    conda-forge
zlib                      1.2.11            h516909a_1010    conda-forge
maartenbreddels commented 3 years ago

Did ImageGL ever work for you, and could you list the steps you have performed? And did you try to create a new env?

pllim commented 3 years ago

To clarify: I see the axis but image doesn't show.

Did ImageGL ever work for you

Not sure. How do I check?

could you list the steps you have performed? And did you try to create a new env?

I followed your instruction as much as possible.

$ conda create -n ztmp-bqplot -c conda-forge nodejs notebook bqplot=0.12.21 ipywidgets=7.6.3  widgetsnbextension=3.5.1
$ conda activate ztmp-bqplot
$ pip install .
$ cd examples/
$ jupyter notebook
maartenbreddels commented 3 years ago

Not sure. How do I check?

Install the released bqplot-image-gl (from pypi)

pllim commented 3 years ago

I mean, is there something you want me to run to make sure, like certain notebook?

maartenbreddels commented 3 years ago

You can try to run the notebook in this PR, or the contour notebook with the released bqplot-image-gl to see what does and does not work.

pllim commented 3 years ago

Okay, with bqplot-image-gl from PyPI and two more installs (see below) to get contour notebook to run, I also don't see the image. Has this package ever been tested on Linux? Is this package hardware dependent in some way (graphics card, etc)?

conda install ipyvuetify -c conda-forge
conda install scikit-image -c conda-forge
pllim commented 3 years ago

Yeah, okay. This works on Windows machine, but not the Linux one. I'll open a new issue (#38).

pllim commented 3 years ago

This makes me think though... Does STScI have a need to deploy this on Linux machines? Or we are just going to assume all users going to be using OSX or Windows?

maartenbreddels commented 3 years ago

There should not be a general Linux issue, if webgl works (you could try some webgl demos to check this) ImageGL should also work. Otherwise it's a bug.

(from mobile phone)

On Tue, Feb 9, 2021, 21:39 P. L. Lim notifications@github.com wrote:

This makes me think though... Does STScI have a need to deploy this on Linux machines? Or we are just going to assume all users going to be using OSX or Windows?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/glue-viz/bqplot-image-gl/pull/37#issuecomment-776227899, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANPEPO3MB6KJMCTHDURP2LS6GMPXANCNFSM4XEZI4OQ .

pllim commented 3 years ago

webgl is indeed complaining on Linux machine. I'll contact IT and get back to you. (Solved: See #38)

maartenbreddels commented 3 years ago

Thanks for all the feedback, any problems can be addressed in separate issues, I think this is good to go.

pllim commented 3 years ago

Thanks! Any plans to do a release with this feature or are you waiting for something else?

maartenbreddels commented 3 years ago

Yes, waiting for #35 (needs help from @astrofrog) and then we can do a release.