DylanMuir / TIFFStack

Load TIFF files into matlab fast, with lazy loading
http://dylan-muir.com/articles/tiffstack/
Other
36 stars 20 forks source link

Resolved: Files with more than 2^16 images cannot be accessed correctly #19

Closed ablot closed 7 years ago

ablot commented 7 years ago

I have a tiff created by scanimage 6 with 4 channels. It's big and in a single file:


ans =

          40         256           1           4       24373

I can load the beginning with no problem

>> size(stack(:,:,1,1,16384))

ans =

    40   256

But after that, nothing can be read:

>> size(stack(:,:,1,1,16385))
Error using TIFFStack>TS_read_data_Tiff (line 1264)
*** TIFFStack: Could not read data from image file.

Error in TIFFStack/subsref (line 680)
                  tfData = TS_read_data_Tiff(oStack, S.subs, bLinearIndexing);

Caused by:
    Error using tifflib
    Input argument out of range.

Maybe not by chance, 16384*4 = 65536

I'm on branch master, commit b083ad97ca64b907cbcbff59babbbcb8ac01dc5d. I have the same problem with dev-different-image-config-in-stack. Can it be a biggtif problem?

ablot commented 7 years ago

I just double checked. ImageJ can read the file properly and if I try to open without interleaving the channels:

>> size(stack_flat)

ans =

          40         256       97492

I have the save problem

>> size(stack_flat(:,:,65536))

ans =

    40   256

>> size(stack_flat(:,:,65537))
Error using TIFFStack>TS_read_data_Tiff (line 1264)
*** TIFFStack: Could not read data from image file.

Error in TIFFStack/subsref (line 680)
                  tfData = TS_read_data_Tiff(oStack, S.subs, bLinearIndexing);

Caused by:
    Error using tifflib
    Input argument out of range.
DylanMuir commented 7 years ago

As of Matlab 2016a, even Matlab can't access frame 65537. Tiff.setDirectory() gives the same error.

ablot commented 7 years ago

great. Revert back to 2015 would be the simplest fix for now?

DylanMuir commented 7 years ago

Been a problem for a while... stackoverflow

DylanMuir commented 7 years ago

Sorry; Matlab even up to 2016a can't do it.

DylanMuir commented 7 years ago

I'm not sure there is a fix possible...

ablot commented 7 years ago

no problem. I'll open with ImageJ and save multiple substacks with less than 2^16 frames each. I'll probably loose the scanimage header information but that's not critical for this example.

Thanks

DylanMuir commented 7 years ago

Hold up a moment. Let me see if using the slower access method works.

DylanMuir commented 7 years ago

There is a trial fix in the dev-different-image-config-in-stack branch. All frames can be accessed using the tiffread code.

ablot commented 7 years ago

Works like a charm :+1:

DylanMuir commented 7 years ago

Now merged into master branch.