We're Hiring!

Turning off CZI autostitching using the MATLAB bftools

Historical discussions about the Bio-Formats library. Please look for and ask new questions at https://forum.image.sc/tags/bio-formats
Please note:
Historical discussions about the Bio-Formats library. Please look for and ask new questions at https://forum.image.sc/tags/bio-formats

If you are having trouble with image files, there is information about reporting bugs in the Bio-Formats documentation. Please send us the data and let us know what version of Bio-Formats you are using. For issues with your code, please provide a link to a public repository, ideally GitHub.

Turning off CZI autostitching using the MATLAB bftools

Postby jmorgan » Tue Aug 07, 2018 3:19 pm

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.
jmorgan
 
Posts: 3
Joined: Mon Aug 06, 2018 10:55 pm

Re: Turning off CZI autostitching using the MATLAB bftools

Postby dgault » Wed Aug 08, 2018 10:43 am

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
User avatar
dgault
Team Member
 
Posts: 208
Joined: Fri Aug 14, 2015 2:56 pm

Re: Turning off CZI autostitching using the MATLAB bftools

Postby jmorgan » Wed Aug 08, 2018 6:33 pm

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
jmorgan
 
Posts: 3
Joined: Mon Aug 06, 2018 10:55 pm

Re: Turning off CZI autostitching using the MATLAB bftools

Postby sbesson » Wed Aug 08, 2018 7:58 pm

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
User avatar
sbesson
Team Member
 
Posts: 421
Joined: Tue Feb 28, 2012 7:20 pm

Re: Turning off CZI autostitching using the MATLAB bftools

Postby jmorgan » Sat Aug 11, 2018 12:11 am

Works perfectly! Thank you!
jmorgan
 
Posts: 3
Joined: Mon Aug 06, 2018 10:55 pm


Return to User Discussion [Legacy]

Who is online

Users browsing this forum: No registered users and 1 guest