Frame counts is the core of all the counting operations.  It counts on a per-frame/per-region basis.

        Args:
            subsets (list): a list of Subset Objects.  if not specified, the phenotypes are used.

        Returns:
            pandas.DataFrame: A dataframe of count data

def frame_counts(self,subsets=None):
        """
        Frame counts is the core of all the counting operations.  It counts on a per-frame/per-region basis.

        Args:
            subsets (list): a list of Subset Objects.  if not specified, the phenotypes are used.

        Returns:
            pandas.DataFrame: A dataframe of count data
        """
        mergeon = self.cdf.frame_columns+['region_label']
        if subsets is None:
            cnts = self.groupby(mergeon+['phenotype_label']).count()[['cell_index']].\
                rename(columns={'cell_index':'count'})
            mr = self.measured_regions
            mr['_key'] =  1
            mp = pd.DataFrame({'phenotype_label':self.measured_phenotypes})
            mp['_key'] = 1
            mr = mr.merge(mp,on='_key').drop(columns='_key')
            cnts = mr.merge(cnts,on=mergeon+['phenotype_label'],how='left').fillna(0)
        else:
             # Use subsets
            if isinstance(subsets,SL): subsets=[subsets]
            cnts = []
            labels = set([s.label for s in subsets])
            for x in subsets: 
                if x.label is None: raise ValueError("Subsets must be named")
            if len(labels) != len(subsets): raise ValueError("Subsets must be uniquely named.")
            seen_labels = []
            for sl in subsets:
                if sl.label in seen_labels: raise ValueError("cannot use the same label twice in the subsets list")
                seen_labels.append(sl.label)

                df = self.cdf.subset(sl)
                df = df.groupby(mergeon).count()[['cell_index']].\
                    rename(columns={'cell_index':'count'}).reset_index()
                df = self.measured_regions.merge(df,on=mergeon,how='left').fillna(0)
                df['phenotype_label'] = sl.label
                cnts.append(df)
            cnts = pd.concat(cnts)
        cnts = cnts[mergeon+['region_area_pixels','phenotype_label','count']]
        cnts['region_area_mm2'] = cnts.apply(lambda x: 
            (x['region_area_pixels']/1000000)*(self.microns_per_pixel*self.microns_per_pixel),1)
        cnts['density_mm2'] = cnts.apply(lambda x: np.nan if x['region_area_mm2'] == 0 else x['count']/x['region_area_mm2'],1)
        # make sure regions of size zero have counts of np.nan
        cnts.loc[cnts['region_area_pixels']<self.minimum_region_size_pixels,['count','density_mm2']] = np.nan
        return cnts