readlif icon indicating copy to clipboard operation
readlif copied to clipboard

Unexpected behavior of get_frame args

Open ginnocentiCST opened this issue 3 years ago • 3 comments

Hi Nick,

Thank you for creating this! I'm not a trained programmer and I apologize if I'm simply misusing your package. Here's my issue:

Create a basic object and load the second series:

lif = './data/LIF_FILE_TWO.lif'
raw_data = LifFile(lif)
img_1 = raw_data.get_image(1)

The following should display a grayscale image of the first channel of the first z-slice in my series, and it does: img_1.get_frame(z=0, t=0, c=0, m=0).show()

Changing c=0 to c=1 does not display the second channel. What I see is the second z-slice of the first channel. img_1.get_frame(z=0, t=0, c=1, m=0).show()

In order to see the second channel, I need to increment the value for z=*. img_1.get_frame(z=1, t=0, c=0, m=0).show()

I wasn't able to upload my LIF file, likely due to size, but I'd be happy to share it with you.

ginnocentiCST avatar Dec 08 '21 14:12 ginnocentiCST

Likewise...

lif = './data/LIF_FILE_TWO.lif'
raw_data = LifFile(lif) 
img_1 = raw_data.get_image(1)

channel_list = [i for i in img_1.get_iter_c(t=0, z=0, m=0)]

for i in range(len(channel_list)):
    channel_list[i].show()

Shows four sequential z-slices of channel 0 in a four channel LIF series.

EDIT: Apologies, still learning. I should have looked at the source code; get_iter_c simply calls get_frame.

ginnocentiCST avatar Dec 09 '21 16:12 ginnocentiCST

Thanks for the bug report! No issue on your end, but I think this is a result of the file being organized differently than expected. I'm wondering if this is the same issue described in #19. I made a workaround for that specific situation, but without more examples I didn't know how to generalize the solution.

If you wouldn't mind sharing the file, a fix could probably be made! If you don't want to share the file publicly, you can send me a twitter DM (find that in my profile).

nimne avatar Dec 09 '21 18:12 nimne

To add, if you need to work on your data quickly, the python-bioformats package should be feature complete. Although the memory and install requirements are greater.

nimne avatar Dec 09 '21 18:12 nimne