Skip to content

Commit dd3b29d

Browse files
Merge pull request #191 from scverse/fix/points_zero_len_cosmx
Disallow points with zero lenght cosmx
2 parents 13852de + 7854596 commit dd3b29d

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

src/spatialdata_io/readers/cosmx.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -271,17 +271,18 @@ def cosmx(
271271
sub_table[CosmxKeys.INSTANCE_KEY] = sub_table[CosmxKeys.INSTANCE_KEY].astype("category")
272272
# we rename z because we want to treat the data as 2d
273273
sub_table.rename(columns={"z": "z_raw"}, inplace=True)
274-
points[f"{fov}_points"] = PointsModel.parse(
275-
sub_table,
276-
coordinates={"x": CosmxKeys.X_LOCAL_TRANSCRIPT, "y": CosmxKeys.Y_LOCAL_TRANSCRIPT},
277-
feature_key=CosmxKeys.TARGET_OF_TRANSCRIPT,
278-
instance_key=CosmxKeys.INSTANCE_KEY,
279-
transformations={
280-
fov: Identity(),
281-
"global": aff,
282-
"global_only_labels": aff,
283-
},
284-
)
274+
if len(sub_table) > 0:
275+
points[f"{fov}_points"] = PointsModel.parse(
276+
sub_table,
277+
coordinates={"x": CosmxKeys.X_LOCAL_TRANSCRIPT, "y": CosmxKeys.Y_LOCAL_TRANSCRIPT},
278+
feature_key=CosmxKeys.TARGET_OF_TRANSCRIPT,
279+
instance_key=CosmxKeys.INSTANCE_KEY,
280+
transformations={
281+
fov: Identity(),
282+
"global": aff,
283+
"global_only_labels": aff,
284+
},
285+
)
285286

286287
# TODO: what to do with fov file?
287288
# if fov_file is not None:

0 commit comments

Comments
 (0)