@@ -23,7 +23,7 @@ def iss(
2323 raw_relative_path : str | Path ,
2424 labels_relative_path : str | Path ,
2525 h5ad_relative_path : str | Path ,
26- instance_key : str ,
26+ instance_key : str | None = None ,
2727 dataset_id : str = "region" ,
2828 multiscale_image : bool = True ,
2929 multiscale_labels : bool = True ,
@@ -51,8 +51,9 @@ def iss(
5151 h5ad_relative_path
5252 Relative path to the counts and metadata file.
5353 instance_key
54- The name of the column that contains the instance identifiers.
55- Must be specified to link the table with the labels image (e.g. `cell_id`).
54+ Which column of the `AnnData` table (in the `obs` `DataFrame`) contains the instance identifiers
55+ (e.g. a `'cell_id'` column); if not specified, such information is assumed to be contained in the index of the
56+ `AnnData` object.
5657 dataset_id
5758 Dataset identifier.
5859 multiscale_image
@@ -75,15 +76,17 @@ def iss(
7576 path = Path (path )
7677
7778 adata = ad .read (path / h5ad_relative_path )
78- adata .obs [instance_key ] = adata .obs .index .astype (int )
79+ if instance_key is None :
80+ instance_key = "instance_id"
81+ adata .obs [instance_key ] = adata .obs .index .astype (int )
7982 adata .var_names_make_unique ()
8083 adata .obs [REGION_KEY ] = REGION
8184 table = TableModel .parse (adata , region = REGION , region_key = REGION_KEY , instance_key = instance_key )
8285
8386 transform_original = Identity ()
8487
8588 labels_image = imread (path / labels_relative_path , ** imread_kwargs ).squeeze ()
86- labels_image = DataArray (labels_image [2 , :, :], dims = ("y" , "x" ))
89+ labels_image = DataArray (labels_image [:, :], dims = ("y" , "x" ))
8790
8891 labels_image_parsed = Labels2DModel .parse (
8992 labels_image ,
0 commit comments