Skip to content

add a bffile datasource and bioformats load path in image.py#1652

Open
barentine wants to merge 1 commit intopython-microscopy:masterfrom
barentine:bffile
Open

add a bffile datasource and bioformats load path in image.py#1652
barentine wants to merge 1 commit intopython-microscopy:masterfrom
barentine:bffile

Conversation

@barentine
Copy link
Copy Markdown
Member

Addresses issue #bioformats installation. Posting as a draft for discussion - unclear if this is a direction we're interested in or not, but it was helpful for me to load some nd2 files from a collaborator.

Is this a bugfix or an enhancement?
enhancement
Proposed changes:

  • add option to load using bffile

loading tested with

  • single-channel nd2 file
  • multi-channel nd2 file

untested
-time series

  • other file types

@David-Baddeley
Copy link
Copy Markdown
Contributor

Sounds good to me. Is installing bffile relatively painless? Is it painless enough that w might consider adding it to our dependencies?

@David-Baddeley
Copy link
Copy Markdown
Contributor

I especially like the fact that it has a lazy loader (although the terminology is slightly misleading - asarray would usually imply forcing into memory ...)

@barentine barentine marked this pull request as ready for review March 12, 2026 17:02
@barentine
Copy link
Copy Markdown
Member Author

Super painless to install over my recent 3.11 numpy 2.4 install via pip install bffile. If memory serves the install was fast, but the first time you call it from code it pulls java jars. Doesn't take long, but small oddity to note.
I think it would be pretty reasonable to add as a dependency.

@csoeller
Copy link
Copy Markdown
Contributor

Hi @barentine, I have played around with this a little, very nice! Trying to use it to get metadata for confocal planes/stacks loaded from .msr files and it works in principle. I wanted to note a couple of small caveats I came across when (a) installing and (b) using it.

On the mac I tried pip install bffile which initially failed, first because of missing java JDK which I solved with sudo port install openjdk17 (I am a macport user) and then it complained about missing ant which I similar could solve with sudo port install apache-ant. Both of these were triggerd by the dependency build of JPype1. Not sure if this can be bypassed with a conda install or if you have other tips.

@csoeller
Copy link
Copy Markdown
Contributor

csoeller commented Apr 14, 2026

Second small issue I came across is the orientation of loaded images/stacks. Here I get some swapping of x/y axes and orientations as compared to the MINFLUX coordinate data (x and y coordinates).

Interestingly, this was done "correctly" by using the existing _loadOBF functionality which uses the obf_support.py we have in the dist and is a pure-python version to open some parts of OBFs and .msrs. Not sure which of the implementations does it right by the book but certainly for the MINFLUX/PYME coordinate conventions, obf_support.py seems to do the right thing (possibly by chance?).

Finally, I do need to fall back to bffile to get at the metadata. I believe the current _loadBioformatsBFF has a small issue there since using MetaDataHandler.OMEXMLMDHandler to get at the OME metadata as this always seems to grab the info from the first image in the long bf.ome_xml block if containing an image series, regardless which one you load.

For my own use I need to get at the per image metadata which I can apparently get with bf.core_metadata(series=ds.stack_number) and indeed this works but the metadata may be non standard.

Not sure how what is the right way here to go forward, looking for suggestions and would be happy to assist if useful.

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.

3 participants