-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to read a whole slide image into sopa #137
Comments
I had a similar error message on a file system used by an apple computer which wrote an empty file starting with a dot into the directory. Sent from my iPadOn 8. Oct 2024, at 20:17, asmitaL99 ***@***.***> wrote:
Description
I am trying to use the sopa.io.wsi function to read a ome.tif file
Reproducing the issue
image = sopa.io.wsi("Xenium_V1_hPancreas_Cancer_Add_on_FFPE_he_image.ome.tif", as_image=True)
Expected behavior
A clear and concise description of what you expected to happen.
the image should be read !
System
OS: [e.g. Linux]
Python version [e.g. 3.9.7]
Dependencies versions
Paste here what 'pip list' gives you.
Error : ValueError Traceback (most recent call last)
Cell In[21], line 2
1 # reading the H&E image
----> 2 image = sopa.io.wsi("Xenium_V1_hPancreas_Cancer_Add_on_FFPE_he_image.ome.tif", as_image=True)
File ~/.local/lib/python3.10/site-packages/sopa/io/reader/wsi.py:55, in wsi(path, chunks, as_image, backend)
52 images[f"scale{key}"] = scale_image
54 multiscale_image = DataTree.from_dict(images)
---> 55 sdata = SpatialData(images={image_name: multiscale_image})
56 sdata[image_name].attrs["metadata"] = slide_metadata
57 sdata[image_name].attrs["backend"] = backend
File ~/.local/lib/python3.10/site-packages/spatialdata/_utils.py:261, in _deprecation_alias..deprecation_decorator..wrapper(*args, **kwargs)
259 raise ValueError("version for deprecation must be specified")
260 rename_kwargs(f.name, kwargs, alias_copy, class_name, library, version)
--> 261 return f(*args, **kwargs)
File ~/.local/lib/python3.10/site-packages/spatialdata/_core/spatialdata.py:142, in SpatialData.init(self, images, labels, points, shapes, tables)
140 if images is not None:
141 for k, v in images.items():
--> 142 self.images[k] = v
144 if labels is not None:
145 for k, v in labels.items():
File ~/.local/lib/python3.10/site-packages/spatialdata/_core/_elements.py:62, in Images.setitem(self, key, value)
61 def setitem(self, key: str, value: Raster_T) -> None:
---> 62 self._check_key(key, self.keys(), self._shared_keys)
63 schema = get_model(value)
64 if schema not in (Image2DModel, Image3DModel):
File ~/.local/lib/python3.10/site-packages/spatialdata/_core/_elements.py:44, in Elements._check_key(key, element_keys, shared_keys)
42 @staticmethod
43 def _check_key(key: str, element_keys: Iterable[str], shared_keys: set[str | None]) -> None:
---> 44 Elements._check_valid_name(key)
45 if key in element_keys:
46 warn(f"Key {key} already exists. Overwriting it in-memory.", UserWarning, stacklevel=2)
File ~/.local/lib/python3.10/site-packages/spatialdata/_core/_elements.py:40, in Elements.check_valid_name(name)
38 raise ValueError("Name cannot be an empty string.")
39 if not all(c.isalnum() or c in "-" for c in name):
---> 40 raise ValueError("Name must contain only alphanumeric characters, underscores, and hyphens.")
ValueError: Name must contain only alphanumeric characters, underscores, and hyphens.ValueError Traceback (most recent call last)
Cell In[21], line 2
1 # reading the H&E image
----> 2 image = sopa.io.wsi("Xenium_V1_hPancreas_Cancer_Add_on_FFPE_he_image.ome.tif", as_image=True)
File ~/.local/lib/python3.10/site-packages/sopa/io/reader/wsi.py:55, in wsi(path, chunks, as_image, backend)
52 images[f"scale{key}"] = scale_image
54 multiscale_image = DataTree.from_dict(images)
---> 55 sdata = SpatialData(images={image_name: multiscale_image})
56 sdata[image_name].attrs["metadata"] = slide_metadata
57 sdata[image_name].attrs["backend"] = backend
File ~/.local/lib/python3.10/site-packages/spatialdata/_utils.py:261, in _deprecation_alias..deprecation_decorator..wrapper(*args, **kwargs)
259 raise ValueError("version for deprecation must be specified")
260 rename_kwargs(f.name, kwargs, alias_copy, class_name, library, version)
--> 261 return f(*args, **kwargs)
File ~/.local/lib/python3.10/site-packages/spatialdata/_core/spatialdata.py:142, in SpatialData.init(self, images, labels, points, shapes, tables)
140 if images is not None:
141 for k, v in images.items():
--> 142 self.images[k] = v
144 if labels is not None:
145 for k, v in labels.items():
File ~/.local/lib/python3.10/site-packages/spatialdata/_core/_elements.py:62, in Images.setitem(self, key, value)
61 def setitem(self, key: str, value: Raster_T) -> None:
---> 62 self._check_key(key, self.keys(), self._shared_keys)
63 schema = get_model(value)
64 if schema not in (Image2DModel, Image3DModel):
File ~/.local/lib/python3.10/site-packages/spatialdata/_core/_elements.py:44, in Elements._check_key(key, element_keys, shared_keys)
42 @staticmethod
43 def _check_key(key: str, element_keys: Iterable[str], shared_keys: set[str | None]) -> None:
---> 44 Elements._check_valid_name(key)
45 if key in element_keys:
46 warn(f"Key {key} already exists. Overwriting it in-memory.", UserWarning, stacklevel=2)
File ~/.local/lib/python3.10/site-packages/spatialdata/_core/_elements.py:40, in Elements.check_valid_name(name)
38 raise ValueError("Name cannot be an empty string.")
39 if not all(c.isalnum() or c in "-" for c in name):
---> 40 raise ValueError("Name must contain only alphanumeric characters, underscores, and hyphens.")
ValueError: Name must contain only alphanumeric characters, underscores, and hyphens.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
were you able to solve it ? |
First see if you have such „hidden“ files in the directory.
In the code of the reader I added a filter for files that start with a dot and have the .tif ending and exclude these from reading.
… Am 09.10.2024 um 17:17 schrieb asmitaL99 ***@***.***>:
were you able to solve it ?
—
Reply to this email directly, view it on GitHub <#137 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABJLP3746KAUNOP7E4WC73LZ2VCKJAVCNFSM6AAAAABPS26AHSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMBSGYZTEMBXG4>.
You are receiving this because you commented.
|
Hello @asmitaL99, sorry for the delay! Also, what would you like to do with this H&E image: align it to the other spatial elements? Or perform an analysis only on this H&E image? There are some functions to operate on all Xenium modalities directly, so let me know if you need more details! |
Description
I am trying to use the sopa.io.wsi function to read a ome.tif file
Reproducing the issue
image = sopa.io.wsi("Xenium_V1_hPancreas_Cancer_Add_on_FFPE_he_image.ome.tif", as_image=True)
Expected behavior
A clear and concise description of what you expected to happen.
the image should be read !
System
Dependencies versions
Paste here what 'pip list' gives you.
Error : ValueError Traceback (most recent call last)
Cell In[21], line 2
1 # reading the H&E image
----> 2 image = sopa.io.wsi("Xenium_V1_hPancreas_Cancer_Add_on_FFPE_he_image.ome.tif", as_image=True)
File ~/.local/lib/python3.10/site-packages/sopa/io/reader/wsi.py:55, in wsi(path, chunks, as_image, backend)
52 images[f"scale{key}"] = scale_image
54 multiscale_image = DataTree.from_dict(images)
---> 55 sdata = SpatialData(images={image_name: multiscale_image})
56 sdata[image_name].attrs["metadata"] = slide_metadata
57 sdata[image_name].attrs["backend"] = backend
File ~/.local/lib/python3.10/site-packages/spatialdata/_utils.py:261, in _deprecation_alias..deprecation_decorator..wrapper(*args, **kwargs)
259 raise ValueError("version for deprecation must be specified")
260 rename_kwargs(f.name, kwargs, alias_copy, class_name, library, version)
--> 261 return f(*args, **kwargs)
File ~/.local/lib/python3.10/site-packages/spatialdata/_core/spatialdata.py:142, in SpatialData.init(self, images, labels, points, shapes, tables)
140 if images is not None:
141 for k, v in images.items():
--> 142 self.images[k] = v
144 if labels is not None:
145 for k, v in labels.items():
File ~/.local/lib/python3.10/site-packages/spatialdata/_core/_elements.py:62, in Images.setitem(self, key, value)
61 def setitem(self, key: str, value: Raster_T) -> None:
---> 62 self._check_key(key, self.keys(), self._shared_keys)
63 schema = get_model(value)
64 if schema not in (Image2DModel, Image3DModel):
File ~/.local/lib/python3.10/site-packages/spatialdata/_core/_elements.py:44, in Elements._check_key(key, element_keys, shared_keys)
42 @staticmethod
43 def _check_key(key: str, element_keys: Iterable[str], shared_keys: set[str | None]) -> None:
---> 44 Elements._check_valid_name(key)
45 if key in element_keys:
46 warn(f"Key
{key}
already exists. Overwriting it in-memory.", UserWarning, stacklevel=2)File ~/.local/lib/python3.10/site-packages/spatialdata/_core/_elements.py:40, in Elements.check_valid_name(name)
38 raise ValueError("Name cannot be an empty string.")
39 if not all(c.isalnum() or c in "-" for c in name):
---> 40 raise ValueError("Name must contain only alphanumeric characters, underscores, and hyphens.")
ValueError: Name must contain only alphanumeric characters, underscores, and hyphens.ValueError Traceback (most recent call last)
Cell In[21], line 2
1 # reading the H&E image
----> 2 image = sopa.io.wsi("Xenium_V1_hPancreas_Cancer_Add_on_FFPE_he_image.ome.tif", as_image=True)
File ~/.local/lib/python3.10/site-packages/sopa/io/reader/wsi.py:55, in wsi(path, chunks, as_image, backend)
52 images[f"scale{key}"] = scale_image
54 multiscale_image = DataTree.from_dict(images)
---> 55 sdata = SpatialData(images={image_name: multiscale_image})
56 sdata[image_name].attrs["metadata"] = slide_metadata
57 sdata[image_name].attrs["backend"] = backend
File ~/.local/lib/python3.10/site-packages/spatialdata/_utils.py:261, in _deprecation_alias..deprecation_decorator..wrapper(*args, **kwargs)
259 raise ValueError("version for deprecation must be specified")
260 rename_kwargs(f.name, kwargs, alias_copy, class_name, library, version)
--> 261 return f(*args, **kwargs)
File ~/.local/lib/python3.10/site-packages/spatialdata/_core/spatialdata.py:142, in SpatialData.init(self, images, labels, points, shapes, tables)
140 if images is not None:
141 for k, v in images.items():
--> 142 self.images[k] = v
144 if labels is not None:
145 for k, v in labels.items():
File ~/.local/lib/python3.10/site-packages/spatialdata/_core/_elements.py:62, in Images.setitem(self, key, value)
61 def setitem(self, key: str, value: Raster_T) -> None:
---> 62 self._check_key(key, self.keys(), self._shared_keys)
63 schema = get_model(value)
64 if schema not in (Image2DModel, Image3DModel):
File ~/.local/lib/python3.10/site-packages/spatialdata/_core/_elements.py:44, in Elements._check_key(key, element_keys, shared_keys)
42 @staticmethod
43 def _check_key(key: str, element_keys: Iterable[str], shared_keys: set[str | None]) -> None:
---> 44 Elements._check_valid_name(key)
45 if key in element_keys:
46 warn(f"Key
{key}
already exists. Overwriting it in-memory.", UserWarning, stacklevel=2)File ~/.local/lib/python3.10/site-packages/spatialdata/_core/_elements.py:40, in Elements.check_valid_name(name)
38 raise ValueError("Name cannot be an empty string.")
39 if not all(c.isalnum() or c in "-" for c in name):
---> 40 raise ValueError("Name must contain only alphanumeric characters, underscores, and hyphens.")
ValueError: Name must contain only alphanumeric characters, underscores, and hyphens.
The text was updated successfully, but these errors were encountered: