Skip to content

Commit

Permalink
WIP: Use data_collection and MaskSubsetState
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
pllim committed May 25, 2021
1 parent a15c49d commit c7fe641
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions jdaviz/configs/imviz/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import numpy as np
from glue.core import BaseData
from glue.core.subset import ElementSubsetState
from glue.core.subset import MaskSubsetState

from jdaviz.core.helpers import ConfigHelper

Expand Down Expand Up @@ -71,10 +71,11 @@ def load_regions(self, regions, data_label, viewer_reference='viewer-1',
mask = region.to_mask(**kwargs)
im = mask.to_image(data.shape)

# TODO: This is not registering to GUI. Also breaks get_regions().
# ValueError: Several subsets are present, specify which one to retrieve with subset_id=
state = ElementSubsetState(indices=np.where((im > 0).flat)[0])
data.new_subset(state, label=subset_label)
# TODO: This breaks get_regions() in 2 ways.
# ValueError: Several subsets are present, specify which one to retrieve with subset_id
# NotImplementedError: Subset states of type MaskSubsetState are not supported
state = MaskSubsetState(im, data.pixel_component_ids)
self.app.data_collection.new_subset_group(subset_label, state)

def get_regions(self):
"""Return regions defined in the viewer.
Expand Down

0 comments on commit c7fe641

Please sign in to comment.