jdaviz icon indicating copy to clipboard operation
jdaviz copied to clipboard

[BUG] slow down in imviz after many dozens of selections

Open jegpeek opened this issue 5 months ago • 6 comments

Jdaviz component

Imviz

Description

Using TIKE with the largest machine available I import a JWST image that is ~10k on a side. I think proceed to select elliptical regions using the solara pop out. As I approach 100 selections the system has a lot of trouble switching between panning and selection modes, taking minutes at times to return to selection mode after panning.

How to Reproduce

Load a 10kx10k JW image in TIKE open imviz pop out solara select a bunch of things try to swap between panning and selecting

Expected behavior

No response

Browser

No response

Jupyter

jupyter --version

Software versions

import platform; print(platform.platform()) import sys; print("Python", sys.version) import numpy; print("Numpy", numpy.version) import astropy; print("astropy", astropy.version) import matplotlib; print("matplotlib", matplotlib.version) import scipy; print("scipy", scipy.version) import skimage; print("scikit-image", skimage.version) import asdf; print("asdf", asdf.version) import stdatamodels; print("stdatamodels", stdatamodels.version) import gwcs; print("gwcs", gwcs.version) import regions; print("regions", regions.version) import specutils; print("specutils", specutils.version) import specreduce; print("specreduce", specreduce.version) import photutils; print("photutils", photutils.version) import astroquery; print("astroquery", astroquery.version) import yaml; print("pyyaml", yaml.version) import asteval; print("asteval", asteval.version) import idna; print("idna", idna.version) import traitlets; print("traitlets", traitlets.version) import bqplot; print("bqplot", bqplot.version) import bqplot_image_gl; print("bqplot-image-gl", bqplot_image_gl.version) import glue; print("glue-core", glue.version) import glue_jupyter; print("glue-jupyter", glue_jupyter.version) import glue_astronomy; print("glue-astronomy", glue_astronomy.version) import echo; print("echo", echo.version) import ipyvue; print("ipyvue", ipyvue.version) import ipyvuetify; print("ipyvuetify", ipyvuetify.version) import ipysplitpanes; print("ipysplitpanes", ipysplitpanes.version) import ipygoldenlayout; print("ipygoldenlayout", ipygoldenlayout.version) import ipypopout; print("ipypopout", ipypopout.version) import jinja2; print("Jinja2", jinja2.version) import solara; print("solara", solara.version) import vispy; print("vispy", vispy.version) import sidecar; print("sidecar", sidecar.version) import jdaviz; print("Jdaviz", jdaviz.version)

jegpeek avatar Jun 06 '25 14:06 jegpeek

We are actively working on improving performance related to multiple images/subsets in imviz, but I'm not sure that those immediate efforts will be sufficient for 100+ subsets on most personal machines. We are also considering alternatives to glue-subsets that are lighter for certain use-cases. What is your use-case here where you are wanting to use so many subsets? Are you doing aperture photometry on these selections, pull out the data in the selection, or using them to markup the image, etc?

kecnry avatar Jun 06 '25 15:06 kecnry

I'm masking out background galaxies in a very complex foreground

jegpeek avatar Jun 06 '25 15:06 jegpeek

ok, and to do that you're adding multiple selections to the same subset and then pulling the mask out into the notebook? Maybe we need to consider a dedicated mask editing capability. Subsets do seem like the most obvious tool here, especially if there are multiple linked images, but there could be options to "collapse" those subsets down into a masked state at points to relieve the overhead of so many subsets/subset subcomponents.

kecnry avatar Jun 06 '25 16:06 kecnry

@jegpeek could you elaborate on the workflow? Are you drawing subsets on background objects to exclude and then doing photometry on the foreground?

bmorris3 avatar Jun 06 '25 16:06 bmorris3

There are current inefficiencies in glue if one tries to build one subset from the OR combination of hundreds of individual selections, but that might not be too difficult to solve if this is the use case here.

astrofrog avatar Jun 13 '25 10:06 astrofrog

@bmorris3 I do the selection for that reason and then export the regions to make a mask for feeding into a separate workflow

jegpeek avatar Jun 16 '25 15:06 jegpeek