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: Does not work under Windows 7 #1

Closed drdadr closed 9 years ago

drdadr commented 9 years ago

So I cloned it directly from GitHub and it works fine under MacOS but it won't work under Windows 7. Compiling the Mex functions works, but when I try to access data from the object it errors:

Error using TIFFStack>TS_read_data_Tiff (line 695) *\ TIFFStack: Could not read data from image file.

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

Caused by: Subscripted assignment dimension mismatch.

The Code and the image file is exactly the same on both machines so it's not actually an assignment mismatch or reading error. I tracked the error down to the sub function: <TS_read_Tiff_striped_chunky> in the call to the <tifflib> the error occurs. Again all parameters beside the header number are the same.

DylanMuir commented 9 years ago

Hi, Could you please let me know which versions of matlab you are using on both the OS X and the Windows 7 system (using version)?

drdadr commented 9 years ago

Windows 7: 8.4.0.150421 (R2014b) OS X: 8.5.0.197613 (R2015a) (But I have been using it under the same R2014b successfully)

But I haven't tried the commit you made 3 days ago yet.

drdadr commented 9 years ago

So I tried the latest commit on both R2014b and R2015a on Windows 7 and R2015a on Mac OS X and now it's not working on either one, but I get a different error: ( I did delete and recompile the MEX files, just to be sure, recompiling works fine)

Undefined function or variable "vnRetDataSize".

Error in TIFFStack/subsref (line 367) if (prod(vnRetDataSize) == 0)

DylanMuir commented 9 years ago

Sorry for that reversion. The latest commit should fix that issue.

Could you try again please? And include the matlab command which fails on Windows 7 but not OS X?

Thanks, Dylan.

drdadr commented 9 years ago

So the commit fixed the new error. Now it's working again on Mac but not on Windows. I tested it on another windows machine and the same error occurs.

>> ts = TIFFStack('D:\test_stack2.tif');
>> ts(1)
Error using TIFFStack>TS_read_data_Tiff (line 719)
*** TIFFStack: Could not read data from image file.

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

Caused by:
    Subscripted assignment dimension mismatch.

>> ts(:,:,1)
Error using TIFFStack>TS_read_data_Tiff (line 719)
*** TIFFStack: Could not read data from image file.

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

Caused by:
    Subscripted assignment dimension mismatch.

>> ts(:)
Error using TIFFStack>TS_read_data_Tiff (line 683)
*** TIFFStack: Could not read data from image file.

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

Caused by:
    Subscripted assignment dimension mismatch.

>> ts(1,1,1)
Error using TIFFStack>TS_read_data_Tiff (line 719)
*** TIFFStack: Could not read data from image file.

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

Caused by:
    Subscripted assignment dimension mismatch.

>> 
DylanMuir commented 9 years ago

Ok. Please try ts(end) and let me know.

DylanMuir commented 9 years ago

What are the dimensions of your stack? (i.e. size ts)?

drdadr commented 9 years ago

Here you go

>> size(ts)

ans =

   512   512    88

>> ts(end)
Error using TIFFStack>TS_read_data_Tiff (line 719)
*** TIFFStack: Could not read data from image file.

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

Caused by:
    Subscripted assignment dimension mismatch.

>> 
DylanMuir commented 9 years ago

Ok. Please pull the latest commit, create your stack, type diagnostic(ts), and send me the output.

drdadr commented 9 years ago
>> ts = TIFFStack('D:\test_stack2.tif');
--- TIFFStack: Compiling MEX functions.
Building with 'Microsoft Visual C++ 2013 Professional (C)'.
MEX completed successfully.
>> diagnostic(ts)
  512x512x88 TIFFStack array with properties:

         bInvert: 0
     strFilename: 'D:\test_stack2.tif'
      sImageInfo: [88x1 struct]
    strDataClass: 'uint16'

Private properties:
   bUseTiffLib: 1
   fhReadFun: TS_read_Tiff_striped_chunky
   vnDimensionOrder: [1 2 3 4 ]
   fhRepSum: mapped_tensor_repsum
>> 
DylanMuir commented 9 years ago

Please comment out lines 234 and 236, leaving line 235 in:

           % if (verLessThan('matlab', '8.3'))
              strReadFun = [strReadFun '_pre2014'];
           % end

and try again with diagnostic(ts), ts(1) and ts(end).

drdadr commented 9 years ago
>> ts = TIFFStack('D:\test_stack2.tif');
>> diagnostic(ts)
  512x512x88 TIFFStack array with properties:

         bInvert: 0
     strFilename: 'D:\test_stack2.tif'
      sImageInfo: [88x1 struct]
    strDataClass: 'uint16'

Private properties:
   bUseTiffLib: 1
   fhReadFun: TS_read_Tiff_striped_chunky_pre2014
   vnDimensionOrder: [1 2 3 4 ]
   fhRepSum: mapped_tensor_repsum
>> ts(1)
Error using TIFFStack>TS_read_data_Tiff (line 729)
*** TIFFStack: Could not read data from image file.

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

Caused by:
    Subscripted assignment dimension mismatch.

>> ts(end)
Error using TIFFStack>TS_read_data_Tiff (line 729)
*** TIFFStack: Could not read data from image file.

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

Caused by:
    Subscripted assignment dimension mismatch.

>> 
DylanMuir commented 9 years ago

Please comment out line 671 (try) and lines 688--694 (catch to end), try ts(1) and send me the error message.

drdadr commented 9 years ago

I did that but note that the error gets thrown in Line 719, so the result stays the same:

>> ts = TIFFStack('D:\test_stack2.tif');
>> diagnostic(ts)
  512x512x88 TIFFStack array with properties:

         bInvert: 0
     strFilename: 'D:\test_stack2.tif'
      sImageInfo: [88x1 struct]
    strDataClass: 'uint16'

Private properties:
   bUseTiffLib: 1
   fhReadFun: TS_read_Tiff_striped_chunky_pre2014
   vnDimensionOrder: [1 2 3 4 ]
   fhRepSum: mapped_tensor_repsum
>> ts(1)
Error using TIFFStack>TS_read_data_Tiff (line 729)
*** TIFFStack: Could not read data from image file.

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

Caused by:
    Subscripted assignment dimension mismatch.

>> 

So I did additionally comment out the try-catch statements for the block in which the error get actually thrown (712-731) and this is the result:

>> ts = TIFFStack('D:\test_stack2.tif');
>> diagnostic(ts)
  512x512x88 TIFFStack array with properties:

         bInvert: 0
     strFilename: 'D:\test_stack2.tif'
      sImageInfo: [88x1 struct]
    strDataClass: 'uint16'

Private properties:
   bUseTiffLib: 1
   fhReadFun: TS_read_Tiff_striped_chunky_pre2014
   vnDimensionOrder: [1 2 3 4 ]
   fhRepSum: mapped_tensor_repsum
>> ts(1)
Subscripted assignment dimension mismatch.

Error in TIFFStack>TS_read_Tiff_striped_chunky_pre2014 (line
933)
      tfImageBuffer(row_inds,:,:) =
      tifflib('readEncodedStrip', tlStack, stripNum);

Error in TIFFStack>TS_read_data_Tiff (line 721)
            [tfData(vbThesePixels), tfImage] =
            oStack.fhReadFun(tfImage, tlStack, spp, w, h,
            rps, tw, th,
            vnFrameLinearIndices(vbThesePixels));

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

>> 
DylanMuir commented 9 years ago

Great, thanks. Please revert lines 234 and 236 and try again.

drdadr commented 9 years ago
>> ts = TIFFStack('D:\test_stack2.tif');
>> diagnostic(ts)
  512x512x88 TIFFStack array with properties:

         bInvert: 0
     strFilename: 'D:\test_stack2.tif'
      sImageInfo: [88x1 struct]
    strDataClass: 'uint16'

Private properties:
   bUseTiffLib: 1
   fhReadFun: TS_read_Tiff_striped_chunky
   vnDimensionOrder: [1 2 3 4 ]
   fhRepSum: mapped_tensor_repsum
>> ts(1)
Subscripted assignment dimension mismatch.

Error in TIFFStack>TS_read_Tiff_striped_chunky (line 853)
      tfImageBuffer(row_inds,:,:) =
      tifflib('readEncodedStrip', tlStack, stripNum-1);

Error in TIFFStack>TS_read_data_Tiff (line 721)
            [tfData(vbThesePixels), tfImage] =
            oStack.fhReadFun(tfImage, tlStack, spp, w, h,
            rps, tw, th,
            vnFrameLinearIndices(vbThesePixels));

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

>> 
DylanMuir commented 9 years ago

Please send a copy of the matlab toolbox file Tiff.m, from the Windows 7 machine, by attaching it to this issue. Or you can mail it to me if you prefer.

Thanks for your willingness to help debug!

drdadr commented 9 years ago

Github doesn't allow attaching anything but images. I've emailed you the file. I appreciate your dedication getting this to run.

DylanMuir commented 9 years ago

Ok, it's seriously weird. Please run with dbstop error, and when it breaks, please send me this output:

r
rps
h
row_inds
strip_num
size(tfImageBuffer)
drdadr commented 9 years ago
>> ts = TIFFStack('D:\test_stack2.tif');
>> dbstop error
>> ts(1)
Subscripted assignment dimension mismatch.

Error in TIFFStack>TS_read_Tiff_striped_chunky (line 853)
      tfImageBuffer(row_inds,:,:) =
      tifflib('readEncodedStrip', tlStack, stripNum-1);

Error in TIFFStack>TS_read_data_Tiff (line 721)
            [tfData(vbThesePixels), tfImage] =
            oStack.fhReadFun(tfImage, tlStack, spp, w, h,
            rps, tw, th,
            vnFrameLinearIndices(vbThesePixels));

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

853       tfImageBuffer(row_inds,:,:) = tifflib('readEncodedStrip', tlStack, stripNum-1);
K>> save('D:\error_workspace.mat')

I have sent you the mat file per email

DylanMuir commented 9 years ago

All the values look reasonable. Last thing to check is what's coming our of tifflib. Please replace line 853 with:

tfTmp = tifflib('readEncodedStrip', tlStack, stripNum-1);
tfImageBuffer(row_inds,:,:) = tfTmp;

and then please send me the workspace again.

drdadr commented 9 years ago
>> dbstop error
>> ts = TIFFStack('D:\test_stack2.tif');
>> ts(1)
Subscripted assignment dimension mismatch.

Error in TIFFStack>TS_read_Tiff_striped_chunky (line 855)
      tfImageBuffer(row_inds,:,:) = tfTmp;

Error in TIFFStack>TS_read_data_Tiff (line 721)
            [tfData(vbThesePixels), tfImage] = oStack.fhReadFun(tfImage,
            tlStack, spp, w, h, rps, tw, th,
            vnFrameLinearIndices(vbThesePixels));

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

855       tfImageBuffer(row_inds,:,:) = tfTmp;
DylanMuir commented 9 years ago

Could you please send a copy of the offending tiff file, from the windows machine?

drdadr commented 9 years ago

I've sent you a shared link to a google drive folder containing the file.

DylanMuir commented 9 years ago

This bug should now be fixed in the latest commit. Please pull the latest changes and check.

imfinfo reported a different number of rows per strip than tifflib, only on Windows. The number reported by tifflib was correct. TIFFStack now checks for this inconsistency, and uses the tifflib value.

Thanks again for helping out with debugging.

drdadr commented 9 years ago

Thanks for your commitment to resolving my issue. Works fine now.

DylanMuir commented 9 years ago

Great, thanks for letting me know.

YishGene commented 7 years ago

Hello, I'm trying to use your TIFFStack library and getting errors like this on stacks taken on scanimage system. I can ready the first channel in the first image, but any attempt to get further than that gives me the error:

Error using TIFFStack>TS_read_data_Tiff (line 1327)
*** TIFFStack: Could not read data from image file.
Error in TIFFStack/subsref (line 685)
                  tfData = TS_read_data_Tiff(oStack, S.subs, bLinearIndexing);
Caused by:
    Subscripted assignment dimension mismatch. 

i.e. this works:

t = TIFFStack('file.tiff', [], 2); 
a = t(:, :, 1,1)

but this not: a = t(:,:,2,1)

Thanks! Yishai

DylanMuir commented 7 years ago

Extra comment moved to new issue #26