Page 1 of 1

Turning off CZI autostitching using the MATLAB bftools

PostPosted: Tue Aug 07, 2018 3:19 pm
by jmorgan
Hello:

I apologize in advance if I am posting this question in the wrong place, this is my first time using the forum, but I couldn't find this question, or a similar question, answered elsewhere.

I am attempting to incorporate MATLAB into my workflow for a tiled image saved in Zeiss' CZI format.

If I open the image in ImageJ with the Bio-Formats toolbox, the default behavior is to open it as "auto-stitched", that is, to use the stage position to automatically stitch the image with 100 tiles into a single tile. In ImageJ, I can disable this behavior by changing the Autostitch option in Bio-Formats Plugins Configuration\Zeiss CZI. In this case, I will open each tile as a series (resulting in 100 series), rather than opening it as a single tile.

My question is, can I repeat this functionality (turning OFF Autostitching) in MATLAB? Right now, calling bfopen() in MATLAB results in pulling a single large tile, as does using bfGetReader() followed by bfGetPlane.

I'm not sure how to approach this, or if it is possible with the MATLAB implementation.

Thank you.

Re: Turning off CZI autostitching using the MATLAB bftools

PostPosted: Wed Aug 08, 2018 10:43 am
by dgault
Yes, you should be able to set the reader options using the API in MATLAB. IF you use bfGetReader to return the reader then you should be able to set it using the following:

Code: Select all
options = javaObject('loci.formats.in.DynamicMetadataOptions');
options.setBoolean(java.lang.String('zeissczi.autostitch'), java.lang.Boolean('FALSE'));
reader.setMetadataOptions(options);


David Gault

Re: Turning off CZI autostitching using the MATLAB bftools

PostPosted: Wed Aug 08, 2018 6:33 pm
by jmorgan
David:

Thank you for your reply. Using the following:

Code: Select all
% Create a reader
reader = bfGetReader(image_name);

options = javaObject('loci.formats.in.DynamicMetadataOptions');
options.setBoolean(java.lang.String('zeissczi.autostitch'), java.lang.Boolean('FALSE'));
reader.setMetadataOptions(options);

reader.getSeriesCount()


I get a return of 6 (which is the number of series created by the autostitched image pyramids), instead of 100, which is the number of tiles/series in the unstitched image.

I have found a work-around, however. It seems like v5.0.0 doesn't have the autostitching functionality, or it is off by default, such that:

Code: Select all
reader = bfGetReader(image_name);
reader.getSeriesCount()


Returns 100 and allows me to access the individual tiles. So my problem seems "solved".
Do you think this is a bug that I should report? Or is it probably something minor I'm doing wrong that I shouldn't worry about since a legacy version works for me?

Thank you,
Josh

Re: Turning off CZI autostitching using the MATLAB bftools

PostPosted: Wed Aug 08, 2018 7:58 pm
by sbesson
Hi Josh,

you will need to pass the options object to the reader before initializing it.
Can you try the following code snippet with your pyramid CZI file?

Code: Select all
% Create a reader but do not initialize it
reader = bfGetReader();

% Create the options and pass it to the reader
options = javaObject('loci.formats.in.DynamicMetadataOptions');
options.setBoolean(java.lang.String('zeissczi.autostitch'), java.lang.Boolean('FALSE'));
reader.setMetadataOptions(options);

% Initialize the reader
reader.setId(image_name);

reader.getSeriesCount()


Best,
Sebastien

Re: Turning off CZI autostitching using the MATLAB bftools

PostPosted: Sat Aug 11, 2018 12:11 am
by jmorgan
Works perfectly! Thank you!