def build_spot_traces_exact_match(spot_results: SpotFindingResults, **kwargs) -> IntensityTable: """ Combines spots found in matching x/y positions across rounds and channels of an ImageStack into traces represented as an IntensityTable. Parameters ----------- spot_results: SpotFindingResults Spots found across rounds/channels of an ImageStack """ # create IntensityTable with same x/y/z info accross all r/ch spot_attributes = list(spot_results.values())[0].spot_attrs intensity_table = IntensityTable.zeros( spot_attributes=spot_attributes, round_labels=spot_results.round_labels, ch_labels=spot_results.ch_labels, ) for r, c in spot_results.keys(): value = spot_results[{ Axes.ROUND: r, Axes.CH: c }].spot_attrs.data[Features.INTENSITY] # if no exact match set value to 0 value = 0 if value.empty else value intensity_table.loc[dict(c=c, r=r)] = value return intensity_table
def build_traces_sequential(spot_results: SpotFindingResults, **kwargs) -> IntensityTable: """ Build spot traces without merging across channels and imaging rounds. Used for sequential methods like smFIsh. Parameters ---------- spot_results: SpotFindingResults Spots found across rounds/channels of an ImageStack Returns ------- IntensityTable : concatenated input SpotAttributes, converted to an IntensityTable object """ all_spots = pd.concat([sa.data for sa in spot_results.values()], sort=True) intensity_table = IntensityTable.zeros( spot_attributes=SpotAttributes(all_spots), ch_labels=spot_results.ch_labels, round_labels=spot_results.round_labels, ) i = 0 for (r, c), attrs in spot_results.items(): for _, row in attrs.data.iterrows(): selector = dict(features=i, c=c, r=r) intensity_table.loc[selector] = row[Features.INTENSITY] i += 1 return intensity_table