Exemplo n.º 1
0
    def __init__(self, feature_names, gallery_dtype, colors, size):

        self.gallery = None
        self.bbox = None
        self.features = None
        self.images = None
        self.contours = defaultdict(list)
        self.colors = colors
        self.image_size = size
        self._images = list()
        self._treatment = list()

        self.feature_names = feature_names
        self._dt_gallery = gallery_dtype
        self._dt_bbox = [('treatment', "S128"), ('label', np.uint32),
                         ('x', np.uint16), ('y', np.uint16), ('top', np.uint16),
                         ('bottom', np.uint16), ('left', np.uint16),
                         ('right', np.uint16)]

        self._dt_features = [(str(n), np.float32) for n in feature_names]
        self._dt_contours = h5py.special_dtype(vlen=np.uint16)
        self._dt_groups = [('feature', "S64")] + \
            [(str(g), "S64") for g in FeatureGroups.keys()]

        # setup the table of feature groups
        self.fgroups = np.empty((len(feature_names), ), dtype=self._dt_groups)
        for i, fname in enumerate(feature_names):
            line = [fname]

            for v in FeatureGroups.values():
                fname2 = cn.splitFeatureName(fname)[1]
                line.append(v.inverse[fname2])
            line = tuple([str(l) for l in line])

            self.fgroups[i] = np.array(line, dtype=self._dt_groups)
Exemplo n.º 2
0
 def currentFeatureNames(self):
     features = list()
     prefix = cn.abreviate(self.gbox.title())
     layout = self.gbox.layout()
     for i in xrange(layout.count()):
         cb = layout.itemAt(i).widget()
         if cb.isChecked():
             ftrs = ("%s-%s" %(prefix, f) for f in self._table[cb.text()])
             features.extend(ftrs)
     return features
Exemplo n.º 3
0
 def currentFeatureNames(self):
     features = list()
     prefix = cn.abreviate(self.gbox.title())
     layout = self.gbox.layout()
     for i in xrange(layout.count()):
         cb = layout.itemAt(i).widget()
         if cb.isChecked():
             ftrs = ("%s-%s" % (prefix, f) for f in self._table[cb.text()])
             features.extend(ftrs)
     return features
Exemplo n.º 4
0
    def featureGroups(self, region=None):
        """Return the feature groups as nested dictionaries.
        e.g. {channel: {meta_group: { group: (feature_list)}}}"""
        fg = self[self.dmodel.feature_groups]

        ftrs = fg.dtype.names[0]
        groups = fg.dtype.names[1:]

        channels = self.channelNames
        ch_groups = OrderedDict()

        for channel in channels:
            meta_group = OrderedDict()
            for group in groups:
                fgroup = FGroup(group, [(g, []) for g in np.unique(fg[group])])
                meta_group[group] = fgroup
            ch_groups[channel] = meta_group

        for line in fg:
            channel, fname = cn.splitFeatureName(line[0])
            channel = cn.validFromShort(channel)
            for i, group in enumerate(groups):
                ch_groups[channel][group][line[i+1]].append(fname)
        return ch_groups
Exemplo n.º 5
0
    def featureGroups(self, region=None):
        """Return the feature groups as nested dictionaries.
        e.g. {channel: {meta_group: { group: (feature_list)}}}"""
        fg = self[self.dmodel.feature_groups]

        ftrs = fg.dtype.names[0]
        groups = fg.dtype.names[1:]

        channels = self.channelNames
        ch_groups = OrderedDict()

        for channel in channels:
            meta_group = OrderedDict()
            for group in groups:
                fgroup = FGroup(group, [(g, []) for g in np.unique(fg[group])])
                meta_group[group] = fgroup
            ch_groups[channel] = meta_group

        for line in fg:
            channel, fname = cn.splitFeatureName(line[0])
            channel = cn.validFromShort(channel)
            for i, group in enumerate(groups):
                ch_groups[channel][group][line[i + 1]].append(fname)
        return ch_groups
Exemplo n.º 6
0
    def __init__(self, title, table, *args, **kw):
        super(AtChannelFeatureGroupsWidget, self).__init__(*args, **kw)
        self.setLayout(QtWidgets.QVBoxLayout())
        self.gbox = QtWidgets.QGroupBox(self)

        self.gbox.setLayout(QtWidgets.QVBoxLayout())
        self.layout().addWidget(self.gbox)
        self.layout().setContentsMargins(0, 0, 0, 0)
        self.layout().setSpacing(1)

        self.gbox.layout().setContentsMargins(1, 1, 1, 1)
        self.gbox.layout().setSpacing(1)

        self.gbox.setTitle(cn.display(title))

        self._table = table

        for group, names in self._table.iteritems():
            self.addFeatureGroup(group, names)
Exemplo n.º 7
0
    def __init__(self, title, table, *args, **kw):
        super(AtChannelFeatureGroupsWidget, self).__init__(*args, **kw)
        self.setLayout(QtWidgets.QVBoxLayout())
        self.gbox = QtWidgets.QGroupBox(self)

        self.gbox.setLayout(QtWidgets.QVBoxLayout())
        self.layout().addWidget(self.gbox)
        self.layout().setContentsMargins(0, 0, 0, 0)
        self.layout().setSpacing(1)

        self.gbox.layout().setContentsMargins(1, 1, 1, 1)
        self.gbox.layout().setSpacing(1)

        self.gbox.setTitle(cn.display(title))

        self._table = table

        for group, names in self._table.iteritems():
            self.addFeatureGroup(group, names)
Exemplo n.º 8
0
    def __init__(self, feature_names, gallery_dtype, colors, size):

        self.gallery = None
        self.bbox = None
        self.features = None
        self.images = None
        self.contours = defaultdict(list)
        self.colors = colors
        self.image_size = size
        self._images = list()
        self._treatment = list()

        self.feature_names = feature_names
        self._dt_gallery = gallery_dtype
        self._dt_bbox = [('file', 'S128'),
                         ('treatment', "S128"), ('label', np.uint32),
                         ('x', np.uint16), ('y', np.uint16), ('top', np.uint16),
                         ('bottom', np.uint16), ('left', np.uint16),
                         ('right', np.uint16),
                         ('angle', np.float32), ('eccentricity', np.float32)]

        self._dt_features = [(str(n), np.float32) for n in feature_names]
        self._dt_contours = h5py.special_dtype(vlen=np.uint16)
        self._dt_groups = [('feature', "S64")] + \
            [(str(g), "S64") for g in FeatureGroups.keys()]

        # setup the table of feature groups
        self.fgroups = np.empty((len(feature_names), ), dtype=self._dt_groups)
        for i, fname in enumerate(feature_names):
            line = [fname]

            for v in FeatureGroups.values():
                fname2 = cn.splitFeatureName(fname)[1]
                line.append(v.inverse[fname2])
            line = tuple([str(l) for l in line])

            self.fgroups[i] = np.array(line, dtype=self._dt_groups)