Skip to content

Commit

Permalink
Add instance_id to .obs before required in ShapesModel
Browse files Browse the repository at this point in the history
  • Loading branch information
LLehner committed Aug 4, 2023
1 parent c341044 commit 7a8ab20
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/spatialdata_io/readers/seqfish.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,6 @@ def seqfish(
for x in range(1, n + 1)
}

radii = np.sqrt(adata.obs[SeqfishKeys.AREA].to_numpy() / np.pi)
shapes = {
f"{SeqfishKeys.REGION.value}_{section}": ShapesModel.parse(
adata.obsm[SeqfishKeys.SPATIAL_KEY],
geometry=0,
radius=radii,
index=adata.obs[SeqfishKeys.INSTANCE_KEY_TABLE],
)
for section, adata in adatas.items()
}

adata = ad.concat(adatas)
adata.obs[SeqfishKeys.REGION_KEY] = SeqfishKeys.REGION
adata.obs[SeqfishKeys.REGION_KEY] = adata.obs[SeqfishKeys.REGION_KEY].astype("category")
Expand All @@ -135,6 +124,17 @@ def seqfish(
instance_key=SeqfishKeys.INSTANCE_KEY_TABLE.value,
)

radii = np.sqrt(adata.obs[SeqfishKeys.AREA].to_numpy() / np.pi)
shapes = {
f"{SeqfishKeys.REGION.value}_{section}": ShapesModel.parse(
adata.obsm[SeqfishKeys.SPATIAL_KEY],
geometry=0,
radius=radii,
index=adata.obs[SeqfishKeys.INSTANCE_KEY_TABLE],
)
for section, adata in adatas.items()
}

sdata = SpatialData(images=images, labels=labels, points=points, table=table, shapes=shapes)

return sdata

0 comments on commit 7a8ab20

Please sign in to comment.