-
-
Notifications
You must be signed in to change notification settings - Fork 410
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
[builtins] handle reading mixed layer directories (e.g. with .csv) #6890
base: main
Are you sure you want to change the base?
[builtins] handle reading mixed layer directories (e.g. with .csv) #6890
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6890 +/- ##
==========================================
- Coverage 92.49% 92.44% -0.05%
==========================================
Files 612 612
Lines 55169 55207 +38
==========================================
+ Hits 51027 51035 +8
- Misses 4142 4172 +30 ☔ View full report in Codecov by Sentry. |
@psobolewskiPhD so sorry for the delay in getting to this... I've been playing with it today and I have some comments. With With this PR, the tiffs don't stack, and I think that's a significant change. What do you think about stacking tiffs but reading csvs individually, since as you mention in the issue, csvs don't stack. In general I'm worried about always trying to read in the csvs, but I totally see what you're saying about fixing reading for things we save out. @jni thoughts? I think maybe this is better than nothing, with yet another comment on us needing to do a bigger I/O overhaul... |
@DragaDoncila I should update the issue, but the bug you observe is something that came up recently when working with an end user that had 2 tifs (image, labels), and a csv (points). |
Yeah I'm fully onboard with this goal, I'm just concerned that this changes behavior for all folders, not just those saved by napari. If people are relying on the stacking, it could be pretty grim to now get 600 layers trying to open because you have timelapse data with one tiff per frame (this is what I work with so it's close to my heart 😆 ). Maybe we do want to associate some metadata when we save... 😬 That's basically the only way we can guarantee a return trip |
Is there any case where napari currently works "as expected" but this would break that? Edit: but yes, in general there is no way for us to figure out intent without some .file with metadata or a modal dialog saying "do you want this to be stacked or what?" |
Right, I guess it's unaffected so long as it doesn't happen to have a csv in it, I just think storing features etc. in these folders is kinda common? But maybe that's just me being messy 😆 |
Could adda heuristic that if there are more than Edit: 30+ channels are totally possible now, so i dunno |
@psobolewskiPhD yeahhh I thought along those lines too but it immediately spiked my blood pressure and I shied back away 😆 . Would be good to get more input from folks. |
Other option: |
This would work, but we'd have to change the drag and drop behavior too, probs by also using |
That sounds reasonable though, makes it consistent -- dragging a batch of files or a folder of the same files should work identically, with the same options. |
Yeah I think that sounds sorta reasonable... |
OK, ill put this in draft and poke around.
For the stack case, do we just ignore non-image files? or error if there are more then 2 extension? |
Of course zarr and other things will be annoying to handle or explain. 😡 |
if we use the system file browsing dialogs I think there's basically no way to tell them to open a zarr folder from the |
@DragaDoncila I spent some time on this but as far as I can tell npe2 readers don't get |
Gahhhh yes I think you're right. There was a push at once stage to get that through to the readers but hasn't been exposed. Currently the "idea" is that if you get a list of images you're supposed to stack them, and if you get just one folder you're not. But I don't know to what extent, if at all, that convention is followed. We should update the manifest, it's just a matter of what that's going to mean for older readers that can't take the |
Any thoughts where that leaves this PR? |
🤣 I will insta-merge a PR adding this modal 😂
I think yes.
zarr v3 should help here because the files will be zarr.json instead of .zarray/.zgroup/.zattrs. So we could instruct people to open zarr.jsons and not the containing folder. In the meantime, it has to be a folder, indeed.
Wow it's super tricky. 😂 One idea: provide two different plugins, builtins-layers and builtins-stack? Another idea (more out there): when we save all layers to folder, we save a napari-layers.yaml file within the folder that contains all the layer info (this file makes up this layer etc) and tells the builtins plugin to do the right thing? (And/or maybe we instruct users to open that file directly?) |
References and relevant issues
Closes #5460
Description
This PR handles reading the output of
write_layer_data_with_plugins
('Save to folder' in the GUI).If a directory is passed to the reader, then a check is made whether it contains .csv files. If so, it reads each file in the directory using either the csv reader or the magic imreader.
The layer names are set to the file names (but source will still show the folder name).
If a file type cannot be handled, it is skipped with a notification.
Otherwise, the behavior is left unchanged.
The goal here is not universal handling of complex folder structures, just handling the common case of folders saved by napari containing layers.
I added a test to reflect this.