Skip to content

Commit

Permalink
fix how spot_ids are handled by build_traces_sequential and Label._as…
Browse files Browse the repository at this point in the history
…sign() (#1872)

* Made build_traces_sequential reassign unique spot_ids to every feature after concatenating PerImageSliceResults. Also made Label._assign() explicitly label features by spot_id instead of row number, ensuring that labeling is accurate even when spot_ids do not match row_numbers in an IntensityTable. Spot_ids must still be unique for accurate labeling though.
  • Loading branch information
mattcai authored May 7, 2020
1 parent 0aafaaf commit 7f15413
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion starfish/core/spots/AssignTargets/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ def _assign(
selectors['z'] = in_bbox.z
in_mask = mask.sel(**selectors)
spot_ids = in_bbox[Features.SPOT_ID][in_mask.values]
decoded_intensities[Features.CELL_ID].loc[spot_ids] = mask.name
decoded_intensities[Features.CELL_ID].loc[
decoded_intensities[Features.SPOT_ID].isin(spot_ids)] = mask.name

return decoded_intensities

Expand Down
5 changes: 4 additions & 1 deletion starfish/core/spots/DecodeSpots/trace_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ def build_traces_sequential(spot_results: SpotFindingResults, **kwargs) -> Inten
"""

all_spots = pd.concat([sa.spot_attrs.data for sa in spot_results.values()], sort=True)
all_spots = pd.concat([sa.spot_attrs.data for sa in spot_results.values()],
ignore_index=True, sort=True)
# reassign spot_ids to index number so they are unique
all_spots['spot_id'] = all_spots.index

intensity_table = IntensityTable.zeros(
spot_attributes=SpotAttributes(all_spots),
Expand Down

0 comments on commit 7f15413

Please sign in to comment.