-
Notifications
You must be signed in to change notification settings - Fork 13
Fix channel as second dim problem #52
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
Conversation
|
Hi @acorbat, Thanks for fix! Do you think would it be more precise to do this? As you say the BytesInc is accumulating, but the number does not include the byte increase of that channel itself. Please let me not your thoughts! Sincerely yours, |
|
Hi, I'm wondering about the right way... I don't have an image to test this right now. I am wondering if cytes_inc_z is also the first byte. Can these be the same in any case? Are they the same when channel is NOT the second dimension? I'm sorry I can't check this right now. On the other hand, I was wondering if you can get the step size in bytes from channel_bytes_inc_list[0] or channel_bytes_inc_list[1] as the first element might be the step size as well and you already have it. Best, |
|
Hi Agustin, Sorry for the late response. Just want to share my thoughts regarding the this issue.
I am not quite sure what you mean here, but I really would like to learn about this more from you if possible. Not quite sure where the evidence comes from, but It seems he is confident the stack order is either "CZTM" or "ZCTM" with
I totally agree with your approach on this with the premise that all the channels have the same byte jump with the same size and byte depth. Best, |
|
Hi Alan, Regarding channel order, I understood the same thing you did. Apparently Leica used either "MTCZYX" or "MTZCYX" as dimension order (going from slowest to fastest dimension). Previously I run into this problem that C and Z dimensions were swapped so I could not read them correctly. I am not sure if dimension order is inside the metadata, but the "hack-y" solution was to look for the start byte position in the metadata and find which one is highest, we can see whether C or Z is the second dimension. For the last point, I agree with you that the safe choice is to calculate the Byte step as you suggest. I was proposing a lazy way as it should always be the same size. Cheers, |
|
Hi Alan, was this PR ok? Should we revisit it? Cheers, |
|
Hi Agus, It looks perfect to me! I think we just need to wait for Nick to grant the request now! Thanks! |
|
@acorbat thanks for working on this! I wanted to let you know that Nick has recently transferred ownership of this repo to Arcadia Science, since we have the bandwidth to maintain this package. We're working on going through the open PRs and issues and hope to get this PR reviewed and merged in the next week or so! Thanks again, and let me know if you have any questions. |
|
Hi @keithchev, any news on this pull request? We're currently opening lif files using |
|
@imagejan so sorry for the late reply! Would you be willing to share an example of a LIF file that cannot be read with In the meantime, we'll get this PR reviewed and merged asap. (It's passing the existing tests, but I'd like to try to understand the change made here myself before merging it.) |
|
Hi @keithchev ! Thank you for pushing this forward. The images I was working with were not mine. I can privately share one of them with you. I'm getting in touch with the person who acquired the images to see if there is one that can be publicly shared. |
|
Edit: (Thanks to @Lplantard for acquiring the file!) Try the following: from pathlib import Path
from readlif.reader import LifFile
path = Path("20250130_4Channels_5planes.lif")
img = LifFile(path)
image = img.get_image()
# Should be set to False, but currently opens as True
assert not image.channel_as_second_dimI can confirm that the current PR loads the image with |
|
@imagejan thanks for sharing that file! This is super helpful. I think I understand this PR now. For the sake of expediency, let's merge this as-is now, and add tests in a later PR. Thanks so much for your patience! |
Following on Issue #44, I believe that the problem is that the hacky way of guessing whether Channels is the second dimension or not is summing over all the bytes of every channel, instead of looking only for the maximum. BytesInc is already accumulating the Bytes of each channel, and we should only compare the maximum with the one from the channels.
I do not have lots of images to test if this modification breaks the behaviour with other images, but it does fix the problem with my images.