Skip to content
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

UnidentifiedImageError when reading in Nanostring CosMx Data #845

Open
keiven-kun opened this issue Jun 26, 2024 · 2 comments
Open

UnidentifiedImageError when reading in Nanostring CosMx Data #845

keiven-kun opened this issue Jun 26, 2024 · 2 comments
Assignees
Labels

Comments

@keiven-kun
Copy link

Hi,

I am receiving the error below when I am loading in Nanostring data. And I found that if I delete the imge folder ("CellComposite", "CellOverlay") and only keep the exprMat, matadata and fov CSV files, the CosMx data loads successfully. But in this way, images are missing. What is causing this issue? Is there anyway to fix it?

Thank you so much for help!

nanostring_dir = "E:/CosMx Data/CosMx_bone_small_full/1117small/20231118_015620_S1"
sample_dir = nanostring_dir + "/CellStatsDir" 
adata = sq.read.nanostring(
    path=sample_dir,
    counts_file="S0_exprMat_file.csv",
    meta_file="S0_metadata_file.csv",
    fov_file="S0_fov_positions_file.csv",
)

UnidentifiedImageError                    Traceback (most recent call last)
Cell In[4], line 4
      1 nanostring_dir = "E:/CosMx Data/CosMx_bone_small_full/1117small/20231118_015620_S1"
      2 sample_dir = nanostring_dir + "/CellStatsDir" 
----> 4 adata = sq.read.nanostring(
      5     path=sample_dir,
      6     counts_file="S0_exprMat_file.csv",
      7     meta_file="S0_metadata_file.csv",
      8     fov_file="S0_fov_positions_file.csv",
      9 )

File D:\Software\anaconda3\Lib\site-packages\squidpy\read\_read.py:260, in nanostring(path, counts_file, meta_file, fov_file)
    258 fov = str(int(pat.findall(fname)[0]))
    259 try:
--> 260     adata.uns[Key.uns.spatial][fov]["images"][kind] = _load_image(path / subdir / fname)
    261 except KeyError:
    262     logg.warning(f"FOV `{str(fov)}` does not exist in {subdir} folder, skipping it.")

File D:\Software\anaconda3\Lib\site-packages\squidpy\read\_utils.py:61, in _load_image(path)
     60 def _load_image(path: PathLike) -> NDArrayA:
---> 61     return np.asarray(Image.open(path))

File D:\Software\anaconda3\Lib\site-packages\PIL\Image.py:3309, in open(fp, mode, formats)
   3307     warnings.warn(message)
   3308 msg = "cannot identify image file %r" % (filename if filename else fp)
-> 3309 raise UnidentifiedImageError(msg)

UnidentifiedImageError: cannot identify image file 'E:\\CosMx Data\\CosMx_bone_small_full\\1117small\\20231118_015620_S1\\CellStatsDir\\CellComposite\\._CellComposite_F028.jpg'

@giovp
Copy link
Member

giovp commented Jul 4, 2024

hi @keiven-kun , I think the nanostring reader has been having issues, possibly due to bugs or new releases of the spec, there are other issues related to it. Unfortuantely, I don't have time to look at it, and would suggest to use https://github.com/scverse/spatialdata-io to read n the data

@giovp giovp added the I/O 💿 label Jul 4, 2024
@keiven-kun
Copy link
Author

hi @keiven-kun , I think the nanostring reader has been having issues, possibly due to bugs or new releases of the spec, there are other issues related to it. Unfortuantely, I don't have time to look at it, and would suggest to use https://github.com/scverse/spatialdata-io to read n the data

Hi @giovp , thank you for responding, I will try to use https://github.com/scverse/spatialdata-io to read the data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants