Skip to content
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

physical_pixel_sizes is not not updated after changing scene #14

Open
lorenzocerrone opened this issue Sep 10, 2024 · 2 comments
Open
Labels
bug Something isn't working

Comments

@lorenzocerrone
Copy link

Describe the Bug

I have a .lif project with two scenes at a different scale. The physical_pixel_sizes property is not updated unless I manually trigger the Reader._read_immediate() method (or any method that calls ._read_immediate() internally).

Expected Behavior

When changing the scene using the set_scene method, I expected the Reader state to be updated.

Please let me know if you would welcome a contribution to fix this issue. I am happy to draft a PR to fix this issue.

Reproduction

img_bio = BioImage(path, reader=bioio_lif.Reader)
img_bio.set_scene("TileScan 1")
print(f"scene 1: {img_bio.physical_pixel_sizes=}")
img_bio.set_scene("Series001")
print(f"scene 2 before: {img_bio.physical_pixel_sizes=}")
img_bio.set_scene("Series001")
xdata = img_bio.reader._read_immediate()
print(f"scene 2 after: {img_bio.physical_pixel_sizes=}")

Output

scene 1: img_bio.physical_pixel_sizes=PhysicalPixelSizes(Z=None, Y=4.5588235294117645, X=4.5588235294117645)
scene 2 before: img_bio.physical_pixel_sizes=PhysicalPixelSizes(Z=None, Y=4.5588235294117645, X=4.5588235294117645)
scene 2 after: img_bio.physical_pixel_sizes=PhysicalPixelSizes(Z=1.3003362, Y=0.3969663405088063, X=0.3969663405088063)
@lorenzocerrone lorenzocerrone added the bug Something isn't working label Sep 10, 2024
@evamaxfield
Copy link

evamaxfield commented Sep 10, 2024

Wow. Yes. That info needs to be reset on set scene update.

Ping @toloudis @SeanLeRoy have either of you encountered this in other readers?

I just checked bioio-base and in the base reader spec we default return a tuple of None. Which is fine but the base reader spec should probably be the place where we fix this by standardizing the delayed loading of physical pixel sizes and their resetting on scene update.

Thank you for finding and documenting @lorenzocerrone !!

@toloudis
Copy link

toloudis commented Sep 10, 2024

we have a _reset_self that happens in the base class reader on scene change (and on multiresolution level change). But the base reader doesn't expect physical pixel size to be cached, it's up to each reader to get it right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants