Comments (7)
thoughts?
I actually have no memory of supporting multi-arrays at all, that's neat! 😜
I think we can be a little more proactive in the iteration — we should only iterate directories in that list comprehension. So:
for subpath is sorted(os.listdir(path))
if not subpath.startswith('.')
and os.path.isdir(path)
and (os.path.exists(os.path.join(path, '.zarray'))
or os.path.exists(os.path.join(path, '.zgroup')))
At this point I think wrap path
in a pathlib.Path
to make that whole thing less of a mouthful, but you get my drift. Basically, only recurse subdirectories and only if they are actually zarr arrays or nested groups.
from napari.
for reference, in zarr-python
right now, contains_group
and contains_array
both do what you would expect for checking if a path denotes a group or array.
Once you have a handle to a group, you can iterate over its sub-groups / sub-arrays with Group.items()
(because Group
is a MutableMapping
, or just sub-arrays with Group.arrays
, or just sub-groups with Group.groups
.
Note that some of this will change in v3, but not too drastically -- e.g., we might make contains_array
/ contains_group
take a zarr_format
keyword argument, since zarr v3 and zarr v2 arrays can co-exist in the same directory.
from napari.
Great well, that should be an easy PR!
@imagejan if you are at all interested in contributing this fix yourself, let us know and we can guide you through it. Otherwise one of the core team will get to it as soon as we can!
from napari.
Is there any reason to not use the zarr-python
api for listing groups and arrays here?
In zarr v3, .zarray and .zgroup are gone, and so this code will need to handle the names of the new metadata document (zarr.json). But if instead this code uses zarr-python
to abstract over the names of the metadata documents, things are a lot simpler for napari, IMO
from napari.
Is there any reason to not use the zarr-python api for listing groups and arrays here?
ignorance! 😂 Since @imagejan already opened #6857 which is strictly better than the current situation, I suggest we merge that, then iterate. Thanks for the suggestion @d-v-b, that's indeed the right path forward.
from napari.
Thanks for reporting. I agree with the suggested expected behavior.
There's a couple builtins
issues, looks like that part of napari needs a closer look.
from napari.
The problem code is here. It tries to read everything in the directory that doesn't start with a .
. We should either try..except
this and only raise later if the image
is empty, or find a better way to identify the arrays than paths that don't start with a .
. @jni thoughts?
from napari.
Related Issues (20)
- Polygon faces in Shapes layer are not shown in 3D if not contained in an *axis-orthogonal* plane HOT 1
- layer.events.current_symbol callback raises exception in when a widget is launched from the plugin menu HOT 2
- [test-bot] pip install --pre is failing HOT 1
- [test-bot] pip install --pre is failing
- When using 4D data for a mesh an IndexError happens when the selected Shape layer doesn't have any points at the current frame. HOT 1
- [test-bot] pip install --pre is failing
- Surface without points in the current time frame raise "AttributeError: 'NoneType' object has no attribute 'shape'" on main branch. HOT 2
- HiLO LUT HOT 4
- Window leveling and Opacity mapping HOT 3
- Shift camera when drawing HOT 2
- add Shape selection event HOT 1
- [ui/ux] Enabling locking Layer controls, preventing accidental changes HOT 1
- Transform mode of Labels layer pivots wrong when non-empty Shapes/Points present HOT 7
- Default to adding a newline for everything before the `extra_tooltip_text` when binding an action to a button HOT 3
- CI Ubuntu latest py 3.9, pyqt5, pyside 6 hash mismatch HOT 5
- Out-of-slice display of points with scale/size is inconsistent HOT 3
- Napari crashes with lazy segmentation HOT 9
- How to handle headless app-model actions HOT 4
- Shapes layer: `3` keybinding to delete shape is not great and cannot be changed HOT 8
- [Points, vispy] Traceback when toggling Points layer to 3D
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from napari.