Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Unable to Read N5 Files #175

@william-silversmith

Description

@william-silversmith
  • pyn5 version: 1.1.1
  • Python version: 3.9
  • Operating System: MacOS 12.3

Description

Trying to read an existing N5 image chunk, but unable to figure out how to read in bytes. I was also unable to read in an existing file.

What I Did

import pyn5
from io import BytesIO

f = open("synapses_dt_reblocked_s5_14_8_5 14-10-08-526.n5", "rb")
binary = f.read()
b = BytesIO(b)
n5file = pyn5.File(b, mode=pyn5.Mode.READ_ONLY)

Output:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/wms/.virtualenvs/cv/lib/python3.9/site-packages/pyn5/file_group.py", line 180, in __init__
    super().__init__(name, mode)
  File "/Users/wms/.virtualenvs/cv/lib/python3.9/site-packages/h5py_like/file.py", line 12, in __init__
    self.filename: Path = Path(name).resolve()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/pathlib.py", line 1082, in __new__
    self = cls._from_parts(args, init=False)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/pathlib.py", line 707, in _from_parts
    drv, root, parts = self._parse_args(args)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/pathlib.py", line 691, in _parse_args
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not BytesIO

I also tried to read from a file:

import pyn5

n5file = pyn5.File("synapses_dt_reblocked_s5_14_8_5 14-10-08-526.n5", mode=pyn5.Mode.READ_ONLY)

Output:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/USER/.virtualenvs/cv/lib/python3.9/site-packages/pyn5/file_group.py", line 181, in __init__
    self._require_dir(self.filename)
  File "/Users/USER/.virtualenvs/cv/lib/python3.9/site-packages/pyn5/file_group.py", line 206, in _require_dir
    raise FileExistsError("File found at desired location of directory")
FileExistsError: File found at desired location of directory

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions