def get_contained_labels(self, inplace=True):
        """
        Get the set of unique labels contained in this annotation.
        Returns a pandas dataframe or sets the contained_labels
        attribute of the object.


        Requires the label_store field to be set.

        Function will try to use attributes contained in the order:
        1. label_store
        2. symbol
        3. description

        This function should also be called
        to summarize information about an
        annotation after it has been
        read. Should not be a helper function
        to others except rdann.
        """
        if self.custom_labels is not None:
            self.check_field('custom_labels')

        # Create the label map
        label_map = ann_label_table.copy()

        # Convert the tuple triplets into a pandas dataframe if needed
        if isinstance(self.custom_labels, (list, tuple)):
            custom_labels = label_triplets_to_df(self.custom_labels)
        elif isinstance(self.custom_labels, pd.DataFrame):
            # Set the index just in case it doesn't already match the label_store
            self.custom_labels.set_index(
                self.custom_labels['label_store'].values, inplace=True)
            custom_labels = self.custom_labels
        else:
            custom_labels = None

        # Merge the standard wfdb labels with the custom labels.
        # custom labels values overwrite standard wfdb if overlap.
        if custom_labels is not None:
            for i in custom_labels.index:
                label_map.loc[i] = custom_labels.loc[i]
            # This doesn't work...
            # label_map.loc[custom_labels.index] = custom_labels.loc[custom_labels.index]

        # Get the labels using one of the features
        if self.label_store is not None:
            index_vals = set(self.label_store)
            reset_index = False
            counts = np.unique(self.label_store, return_counts=True)
        elif self.symbol is not None:
            index_vals = set(self.symbol)
            label_map.set_index(label_map['symbol'].values, inplace=True)
            reset_index = True
            counts = np.unique(self.symbol, return_counts=True)
        elif self.description is not None:
            index_vals = set(self.description)
            label_map.set_index(label_map['description'].values, inplace=True)
            reset_index = True
            counts = np.unique(self.description, return_counts=True)
        else:
            raise Exception('No annotation labels contained in object')

        contained_labels = label_map.loc[index_vals, :]

        # Add the counts
        for i in range(len(counts[0])):
            contained_labels.loc[counts[0][i], 'n_occurrences'] = counts[1][i]
        contained_labels['n_occurrences'] = pd.to_numeric(contained_labels['n_occurrences'], downcast='integer')

        if reset_index:
            contained_labels.set_index(contained_labels['label_store'].values,
                                       inplace=True)

        if inplace:
            self.contained_labels = contained_labels
            return
        else:
            return contained_labels
def get_contained_labels ( self , inplace = True ) : if self . custom_labels is not None : self . check_field ( 'custom_labels' ) label_map = ann_label_table . copy ( ) if isinstance ( self . custom_labels , ( list , tuple ) ) : custom_labels = label_triplets_to_df ( self . custom_labels ) elif isinstance ( self . custom_labels , pd . DataFrame ) : self . custom_labels . set_index ( self . custom_labels [ 'label_store' ] . values , inplace = True ) custom_labels = self . custom_labels else : custom_labels = None if custom_labels is not None : for i in custom_labels . index : label_map . loc [ i ] = custom_labels . loc [ i ] if self . label_store is not None : index_vals = set ( self . label_store ) reset_index = False counts = np . unique ( self . label_store , return_counts = True ) elif self . symbol is not None : index_vals = set ( self . symbol ) label_map . set_index ( label_map [ 'symbol' ] . values , inplace = True ) reset_index = True counts = np . unique ( self . symbol , return_counts = True ) elif self . description is not None : index_vals = set ( self . description ) label_map . set_index ( label_map [ 'description' ] . values , inplace = True ) reset_index = True counts = np . unique ( self . description , return_counts = True ) else : raise Exception ( 'No annotation labels contained in object' ) contained_labels = label_map . loc [ index_vals , : ] for i in range ( len ( counts [ 0 ] ) ) : contained_labels . loc [ counts [ 0 ] [ i ] , 'n_occurrences' ] = counts [ 1 ] [ i ] contained_labels [ 'n_occurrences' ] = pd . to_numeric ( contained_labels [ 'n_occurrences' ] , downcast = 'integer' ) if reset_index : contained_labels . set_index ( contained_labels [ 'label_store' ] . values , inplace = True ) if inplace : self . contained_labels = contained_labels return else : return contained_labels
Get the set of unique labels contained in this annotation.
        Returns a pandas dataframe or sets the contained_labels
        attribute of the object.


        Requires the label_store field to be set.

        Function will try to use attributes contained in the order:
        1. label_store
        2. symbol
        3. description

        This function should also be called
        to summarize information about an
        annotation after it has been
        read. Should not be a helper function
        to others except rdann.