SWC-Advanced-Microscopy / StitchIt

Stitching of large tiled datasets
GNU Lesser General Public License v3.0
16 stars 7 forks source link

Benchmark larger ScanImage stacks #114

Open raacampbell opened 6 years ago

raacampbell commented 6 years ago

It seems to me that accessing SI TIFFS with, say, 8 depth and 3 channels at 1024 x 1024 is slower than I'd expect. So I should look into approaches for speeding this up.

raacampbell commented 6 years ago

I think this is the problem:

% CLEARED CACHE HERE
% Load all depths from one channel
>> tic;for ii=1:3; IM=stitchit.tools.loadTiffStack('rawData/ERAB13_1d-0001/ERAB13_1d-0001_00010.tif','frames',ii:3:24);end;toc
Elapsed time is 0.660667 seconds.

% CLEARED CACHE HERE
% Load all depths from all channels
>> tic; IM=stitchit.tools.loadTiffStack('rawData/ERAB13_1d-0001/ERAB13_1d-0001_00010.tif','frames',1:1:24);toc                 
Elapsed time is 0.329538 seconds.

% CLEARED CACHE HERE
% Load one tile at a time
>> tic;for ii=1:24; IM=stitchit.tools.loadTiffStack('rawData/ERAB13_1d-0001/ERAB13_1d-0001_00010.tif','frames',ii);end;toc      
Elapsed time is 1.815034 seconds.

So we could hugely decrease stitching time by loading into RAM all depths from all channels. This is because we are loading one frame at a time from each stack with tileLoad. So on a typical acquisition it takes 20 seconds load 140 tiles from one depth. So that would take 20*3*8=480 480 seconds to load 3 channels and 8 depths which that section is comprised of. If we do:

>> tic;for ii=1:140;IM{ii}=stitchit.tools.loadTiffStack(f(ii).name);end;toc
Elapsed time is 65.149497 seconds.

It's therefore over 7 times faster loading data.

>> tic;parfor ii=1:140;IM{ii}=stitchit.tools.loadTiffStack(f(ii).name,'supressParallelLoading',true);end;toc                       
Elapsed time is 46.985979 seconds.

And here over 10 times faster.

Of course all this assumes no caching.

>> tic;tileLoad([1,1,0,0,2]);toc
Elapsed time is 18.504647 seconds.
>> tic;tileLoad([1,1,0,0,2]);toc
Elapsed time is 2.449667 seconds.
>> 

So whether it's worth implementing all this isn't clear since data will have been cached during pre-processing before stitching. I suspect it is worth doing because during pre-processing we are taking ages loading data in any case.

raacampbell commented 5 years ago

Let's see if the BigTiffReader class helps to speed things up.