Exemple #1
0
    def apply_roi(self, roi, override_mode=None):

        # Force redraw to get rid of ROI. We do this because applying the
        # subset state below might end up not having an effect on the viewer,
        # for example there may not be any layers, or the active subset may not
        # be one of the layers. So we just explicitly redraw here to make sure
        # a redraw will happen after this method is called.
        self.redraw()

        # TODO Does subset get applied to all data or just visible data?

        if self.state._layout is None:
            return

        if not roi.defined():
            return

        if len(self.layers) == 0:
            return

        if isinstance(roi, PointROI):

            x, y = roi.x, roi.y

            xs, ys = self.state._layout.xy
            parent_ys = ys[1::3]
            xs, ys = xs[::3], ys[::3]

            delt = np.abs(x - xs)
            delt[y > ys] = np.nan
            delt[y < parent_ys] = np.nan

            if np.isfinite(delt).any():
                select = np.nanargmin(delt)
                if self.state.select_substruct:
                    parent = self.state.reference_data[self.state.parent_att]
                    select = _substructures(parent, select)
                select = np.asarray(select, dtype=np.int)
            else:
                select = np.array([], dtype=np.int)

            subset_state = CategorySubsetState(
                self.state.reference_data.pixel_component_ids[0], select)

            self.apply_subset_state(subset_state)

        else:

            raise TypeError("Only PointROI selections are supported")
Exemple #2
0
    def apply_roi(self, roi, override_mode=None):

        # Force redraw to get rid of ROI. We do this because applying the
        # subset state below might end up not having an effect on the viewer,
        # for example there may not be any layers, or the active subset may not
        # be one of the layers. So we just explicitly redraw here to make sure
        # a redraw will happen after this method is called.
        self.redraw()

        # TODO Does subset get applied to all data or just visible data?

        if self.state._layout is None:
            return

        if not roi.defined():
            return

        if len(self.layers) == 0:
            return

        if isinstance(roi, PointROI):

            x, y = roi.x, roi.y

            xs, ys = self.state._layout.xy
            parent_ys = ys[1::3]
            xs, ys = xs[::3], ys[::3]

            delt = np.abs(x - xs)
            delt[y > ys] = np.nan
            delt[y < parent_ys] = np.nan

            if np.isfinite(delt).any():
                select = np.nanargmin(delt)
                if self.state.select_substruct:
                    parent = self.state.reference_data[self.state.parent_att]
                    select = _substructures(parent, select)
                select = np.asarray(select, dtype=np.int)
            else:
                select = np.array([], dtype=np.int)

            subset_state = CategorySubsetState(self.state.reference_data.pixel_component_ids[0], select)

            self.apply_subset_state(subset_state)

        else:

            raise TypeError("Only PointROI selections are supported")
Exemple #3
0
    def apply_roi(self, roi, use_current=False):

        # TODO Does subset get applied to all data or just visible data?

        if self.state._layout is None:
            return

        if not roi.defined():
            return

        if len(self.layers) == 0:  # Force redraw to get rid of ROI
            return self.redraw()

        if isinstance(roi, PointROI):

            x, y = roi.x, roi.y

            xs, ys = self.state._layout.xy
            parent_ys = ys[1::3]
            xs, ys = xs[::3], ys[::3]

            delt = np.abs(x - xs)
            delt[y > ys] = np.nan
            delt[y < parent_ys] = np.nan

            if np.isfinite(delt).any():
                select = np.nanargmin(delt)
                if self.state.select_substruct:
                    parent = self.state.reference_data[self.state.parent_att]
                    select = _substructures(parent, select)
                select = np.asarray(select, dtype=np.int)
            else:
                select = np.array([], dtype=np.int)

            subset_state = CategorySubsetState(
                self.state.reference_data.pixel_component_ids[0], select)

            self.apply_subset_state(subset_state)

        else:

            raise TypeError("Only PointROI selections are supported")
Exemple #4
0
    def apply_roi(self, roi, use_current=False):

        # TODO Does subset get applied to all data or just visible data?

        if self.state._layout is None:
            return

        if not roi.defined():
            return

        if len(self.layers) == 0:  # Force redraw to get rid of ROI
            return self.redraw()

        if isinstance(roi, PointROI):

            x, y = roi.x, roi.y

            xs, ys = self.state._layout.xy
            parent_ys = ys[1::3]
            xs, ys = xs[::3], ys[::3]

            delt = np.abs(x - xs)
            delt[y > ys] = np.nan
            delt[y < parent_ys] = np.nan

            if np.isfinite(delt).any():
                select = np.nanargmin(delt)
                if self.state.select_substruct:
                    parent = self.state.reference_data[self.state.parent_att]
                    select = _substructures(parent, select)
                select = np.asarray(select, dtype=np.int)
            else:
                select = np.array([], dtype=np.int)

            subset_state = CategorySubsetState(self.state.reference_data.pixel_component_ids[0], select)

            self.apply_subset_state(subset_state)

        else:

            raise TypeError("Only PointROI selections are supported")