Skip to content

View in biofile finder#436

Merged
will-moore merged 19 commits intoome:masterfrom
will-moore:view_in_biofile_finder
Apr 15, 2025
Merged

View in biofile finder#436
will-moore merged 19 commits intoome:masterfrom
will-moore:view_in_biofile_finder

Conversation

@will-moore
Copy link
Copy Markdown
Member

@will-moore will-moore commented Feb 14, 2025

With $ ome_zarr view my_image.zarr we can view a single zarr image (or plate etc) in the ome-ngff-validator by serving the image from a local python server.

But this PR allows you to browse a collection of images in your local filesystem with:

$ ome_zarr finder path/to/my_data_folder/

This command will traverse your local filesystem, looking for zarr images (only .zattrs for now - can add zarr v3 support as a follow-up) and collect them into a CSV. This CSV is then served by the localhost python server and opened in BioFile Finder, allowing you to browse your local zarr images which are also served in the same way (and see thumbnails, copy URL etc).

Then in Bio-File Finder, you can "Group By" > "Folders" and you'll get a "tree" of all your folders containing images.

Screenshot 2025-02-14 at 12 44 58

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 14, 2025

Codecov Report

Attention: Patch coverage is 80.00000% with 26 lines in your changes missing coverage. Please review.

Project coverage is 85.48%. Comparing base (1e3e3e2) to head (786602d).
Report is 80 commits behind head on master.

Files with missing lines Patch % Lines
ome_zarr/utils.py 79.83% 24 Missing ⚠️
ome_zarr/cli.py 81.81% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #436      +/-   ##
==========================================
+ Coverage   85.45%   85.48%   +0.03%     
==========================================
  Files          13       13              
  Lines        1540     1654     +114     
==========================================
+ Hits         1316     1414      +98     
- Misses        224      240      +16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@will-moore will-moore marked this pull request as ready for review March 8, 2025 23:19
@will-moore will-moore requested a review from joshmoore March 11, 2025 18:01
@joshmoore
Copy link
Copy Markdown
Member

Could definitely use some help under -h:

usage: ome_zarr view [-h] [--port PORT] path

positional arguments:
  path

options:
  -h, --help   show this help message and exit
  --port PORT

Should the CSVs support file:///?

Also, some failure on HCS data:

Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/mambaforge/base/envs/ome-zarr-py/bin/ome_zarr", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/ome-zarr-py/ome_zarr/cli.py", line 180, in main
    ns.func(ns)
  File "/opt/ome-zarr-py/ome_zarr/cli.py", line 37, in view
    zarr_view(args.path, args.port)
  File "/opt/ome-zarr-py/ome_zarr/utils.py", line 171, in view
    zarrs = list(walk(Path(input_path)))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/ome-zarr-py/ome_zarr/utils.py", line 155, in walk
    yield from walk(p)
  File "/opt/ome-zarr-py/ome_zarr/utils.py", line 153, in walk
    yield from find_multiscales(p)
               ^^^^^^^^^^^^^^^^^^^
  File "/opt/ome-zarr-py/ome_zarr/utils.py", line 70, in find_multiscales
    print("well", wells[0])
                  ~~~~~^^^
TypeError: 'NoneType' object is not subscriptable

@will-moore
Copy link
Copy Markdown
Member Author

@joshmoore - Thanks. I fixed the help and handling of plates with no wells.

Not sure what you mean by "Should the CSVs support file:///?"
I don't think BFF in the browser will be able to load anything via file:///?

@joshmoore
Copy link
Copy Markdown
Member

Nothing I tried previously got to a BFF screen -- I was trying to setup my own CSV.

@will-moore
Copy link
Copy Markdown
Member Author

will-moore commented Mar 24, 2025

Any errors?
Does this work?

$ mkdir test && cd test
$ ome_zarr download https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0062A/6001240.zarr
$ ome_zarr download https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0101A/13457539.zarr
$ cd ../
$ ome_zarr view test
Screenshot 2025-03-24 at 22 11 48
$ cat test/biofile_finder.csv 
File Path,File Name,Folders
http://localhost:8000/test/13457539.zarr,13457539.zarr,.
http://localhost:8000/test/6001240.zarr,6001240.zarr,.

@will-moore
Copy link
Copy Markdown
Member Author

@joshmoore If you want to create your own CSV then you can open it in BFF using their File picker (CSV doesn't need to be served by a server). But ome_zarr open my_dir does everything all for you (creates the csv and opens it in BFF).

@joshmoore
Copy link
Copy Markdown
Member

Ok, with the caveat that the CSV above requires something to be serving those files on localhost (right?), the above works for me. I think though that'd I'd feel better about this if the current view failed for non-Zarrs and then said, please use the command ome_zarr finder or something to not be too much of a surprise.

@will-moore
Copy link
Copy Markdown
Member Author

Phew - finally got codecov down to only -0.05% change, so we're green again!

Now, $ ome_zarr view ... will always open validator (even for a collection like ome_zarr view bioformats2raw/images.zarr.

Similarly, $ ome_zarr finder ... will always open BFF, even for a single image, or bf2raw.zarr or directory (unless no images found).

@joshmoore
Copy link
Copy Markdown
Member

ome_zarr view /tmp/test (from above)

No .zattrs or zarr.json at http://localhost:8000/test: File not found

👍 for this PR, but we could consider improving it as things evolve, e.g., could view detect this before opening and suggest finder?

ome_zarr finder /tmp/test

👍

ome_zarr finder /tmp/test/13457539.zarr

👍 (possible to start with the thumbnail view?)

@will-moore
Copy link
Copy Markdown
Member Author

@joshmoore That should address the last comments:

  • Opens BFF with small thumbnails view
  • Handle $ ome_zarr view dir with no images:
$ ome_zarr view data/boats.zarr/
No OME-Zarr images found in data/boats.zarr/. Try $ ome_zarr finder data/boats.zarr/

@will-moore will-moore merged commit 542cbe4 into ome:master Apr 15, 2025
10 checks passed
@will-moore will-moore deleted the view_in_biofile_finder branch April 15, 2025 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants