Exemplo n.º 1
0
def segment(zstat_data):
    """
    Segment a zstats img.

    """
    seg_marker, seg_input, seg_result = bpsegment.watershed(zstat_data, 0, 2.3)
    return seg_marker, seg_result
Exemplo n.º 2
0
    def _watershed(self):
        sigma = self.sigma_edit.text()
        thresh = self.thresh_edit.text()
        sfx = self.sfx_edit.currentText()
        out = self.out_edit.text()

        if not sigma:
            self.sigma_edit.setFocus()
            return
        if not thresh:
            self.thresh_edit.setFocus()
            return
        if not sfx:
            self.sfx_edit.setFocus()
            return
        if not out:
            self.out_edit.setFocus()
            return

        try:
            sigma = float(sigma)
        except ValueError:
            self.sigma_edit.selectAll()
            return
        try:
            thresh = float(thresh)
        except ValueError:
            self.thresh_edit.selectAll()
            return
        try:
            sfx = str(sfx)
        except ValueError:
            self.sfx_edit.setFocus()
            return
        try:
            out = str(out)
        except ValueError:
            self.out_edit.setFocus()
            return

        vol_row = self.vol_combo.currentIndex()
        seed_row = self.seed_combo.currentIndex()
        vol_data = self._model.data(self._model.index(vol_row),
                                    Qt.UserRole + 6)
        if seed_row < self._model.rowCount():
            seed_data = self._model.data(self._model.index(seed_row),
                                         Qt.UserRole + 6)
        else:
            seed_data = None

        if sfx == 'Inverse':
            sfx = segment.inverse_transformation
        elif sfx == 'Gradient':
            sfx = segment.gradient_transformation
        elif sfx == 'Distance':
            sfx = segment.distance_transformation
        else:
            raise ValueError, "Unkown segmentation fucntion"

        new_vol = segment.watershed(vol_data, sigma, thresh, seed_data, sfx)
        self._model.addItem(new_vol[2], None, out,
                            self._model._data[0].get_header(), None, None, 255,
                            'rainbow')
        #self._main_win.new_image_action()
        self.done(0)
Exemplo n.º 3
0
    def _watershed(self):
        sigma = self.sigma_edit.text()
        thresh = self.thresh_edit.text()
        sfx = self.sfx_edit.currentText()
        out = self.out_edit.text()

        if not sigma:
            self.sigma_edit.setFocus()
            return
        if not thresh:
            self.thresh_edit.setFocus()
            return
        if not sfx:
            self.sfx_edit.setFocus()
            return
        if not out:
            self.out_edit.setFocus()
            return
        
        try:
            sigma = float(sigma)
        except ValueError:
            self.sigma_edit.selectAll()
            return
        try:
            thresh = float(thresh)
        except ValueError:
            self.thresh_edit.selectAll()
            return
        try:
            sfx = str(sfx)
        except ValueError:
            self.sfx_edit.setFocus()
            return
        try:
            out = str(out)
        except ValueError:
            self.out_edit.setFocus()
            return

        vol_row = self.vol_combo.currentIndex()
        seed_row = self.seed_combo.currentIndex()
        vol_data = self._model.data(self._model.index(vol_row),
                                    Qt.UserRole + 6)
        if seed_row < self._model.rowCount():
            seed_data = self._model.data(self._model.index(seed_row),
                                         Qt.UserRole + 6)
        else:
            seed_data = None
        
        if sfx == 'Inverse':
            sfx = segment.inverse_transformation
        elif sfx == 'Gradient':
            sfx = segment.gradient_transformation
        elif sfx == 'Distance':
            sfx = segment.distance_transformation
        else:
            raise ValueError, "Unkown segmentation fucntion"

        new_vol = segment.watershed(vol_data, sigma, thresh, seed_data, sfx)
        self._model.addItem(new_vol[2],
                            None,
                            out,
                            self._model._data[0].get_header(),
                            None, None, 255, 'rainbow')
        #self._main_win.new_image_action()
        self.done(0)