@@ -61,6 +61,7 @@ def xenium(
6161 transcripts : bool = True ,
6262 morphology_mip : bool = True ,
6363 morphology_focus : bool = True ,
64+ aligned_images : bool = True ,
6465 imread_kwargs : Mapping [str , Any ] = MappingProxyType ({}),
6566 image_models_kwargs : Mapping [str , Any ] = MappingProxyType ({}),
6667 labels_models_kwargs : Mapping [str , Any ] = MappingProxyType ({}),
@@ -107,9 +108,11 @@ def xenium(
107108 transcripts
108109 Whether to read transcripts.
109110 morphology_mip
110- Whether to read morphology mip.
111+ Whether to read the morphology mip image (available in versions < 2.0.0) .
111112 morphology_focus
112- Whether to read morphology focus.
113+ Whether to read the morphology focus image.
114+ aligned_images
115+ Whether to also parse, when available, additional H&E or IF aligned images.
113116 imread_kwargs
114117 Keyword arguments to pass to the image reader.
115118 image_models_kwargs
@@ -190,17 +193,17 @@ def xenium(
190193 labels_name = "cell_labels" ,
191194 labels_models_kwargs = labels_models_kwargs ,
192195 )
193- if cell_labels_indices_mapping is not None :
194- if not pd .DataFrame .equals (cell_labels_indices_mapping ["cell_id" ], table .obs [str (XeniumKeys .CELL_ID )]):
195- warnings .warn (
196- "The cell_id column in the cell_labels_table does not match the cell_id column derived from the cell "
197- "labels data. This could be due to trying to read a new version that is not supported yet. Please "
198- "report this issue." ,
199- UserWarning ,
200- stacklevel = 2 ,
201- )
202- else :
203- table .obs ["cell_labels" ] = cell_labels_indices_mapping ["label_index" ]
196+ if cell_labels_indices_mapping is not None :
197+ if not pd .DataFrame .equals (cell_labels_indices_mapping ["cell_id" ], table .obs [str (XeniumKeys .CELL_ID )]):
198+ warnings .warn (
199+ "The cell_id column in the cell_labels_table does not match the cell_id column derived from the cell "
200+ "labels data. This could be due to trying to read a new version that is not supported yet. Please "
201+ "report this issue." ,
202+ UserWarning ,
203+ stacklevel = 2 ,
204+ )
205+ else :
206+ table .obs ["cell_labels" ] = cell_labels_indices_mapping ["label_index" ]
204207
205208 if nucleus_boundaries :
206209 polygons ["nucleus_boundaries" ] = _get_polygons (
@@ -302,9 +305,10 @@ def filter(self, record: logging.LogRecord) -> bool:
302305 sdata = SpatialData (** elements_dict )
303306
304307 # find and add additional aligned images
305- aligned_images = _add_aligned_images (path , imread_kwargs , image_models_kwargs )
306- for key , value in aligned_images .items ():
307- sdata .images [key ] = value
308+ if aligned_images :
309+ extra_images = _add_aligned_images (path , imread_kwargs , image_models_kwargs )
310+ for key , value in extra_images .items ():
311+ sdata .images [key ] = value
308312
309313 return sdata
310314
0 commit comments