Skip to content

Commit

Permalink
read_precomputed: add limit parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
schlegelp committed Jan 11, 2024
1 parent 2f0ccf5 commit 2d40bd3
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions navis/io/precomputed_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ def read_precomputed(f: Union[str, io.BytesIO],
include_subdirs: bool = False,
fmt: str = '{id}',
info: Union[bool, str, dict] = True,
limit: Optional[int] = None,
parallel: Union[bool, int] = 'auto',
**kwargs) -> 'core.NeuronObject':
"""Read skeletons and meshes from neuroglancer's precomputed format.
Expand All @@ -213,8 +214,8 @@ def read_precomputed(f: Union[str, io.BytesIO],
----------
f : filepath | folder | zip file | bytes
Filename, folder or bytes. If folder, will import all
files. If a ``.zip`` archive will read all files in the
file.
files. If a ``.zip``, ``.tar`` or ``.tar.gz`` file will
read all files in the archive. See also ``limit`` parameter.
datatype : "auto" | "skeleton" | "mesh"
Which data type we expect to read from the files. If
"auto", we require a "info" file in the same directory
Expand Down Expand Up @@ -251,6 +252,11 @@ def read_precomputed(f: Union[str, io.BytesIO],
- ``False`` = do not use/look for `info` file
- ``str`` = filepath to `info` file
- ``dict`` = already parsed info file
limit : int, optional
If reading from a folder you can use this parameter to
read only the first ``limit`` files. Useful if
wanting to get a sample from a large library of
skeletons/meshes.
parallel : "auto" | bool | int
Defaults to ``auto`` which means only use parallel
processing if more than 200 files are imported. Spawning
Expand Down Expand Up @@ -335,7 +341,7 @@ def read_precomputed(f: Union[str, io.BytesIO],
else:
reader = PrecomputedMeshReader(fmt=fmt, attrs=kwargs)

return reader.read_any(f, include_subdirs, parallel)
return reader.read_any(f, include_subdirs, parallel, limit=limit)


class PrecomputedWriter(base.Writer):
Expand Down

0 comments on commit 2d40bd3

Please sign in to comment.