We're Hiring!

[Matlab] How to retrieve Tile and Position infor from .CZI?

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.

[Matlab] How to retrieve Tile and Position infor from .CZI?

Postby StefanoMas » Tue Sep 13, 2016 2:55 pm

Hi everyone,

I am trying to use the BioFormat Matlab wrapper to open and read the images included in a .CZI file.
The file consists of 405 images, each one of them with 3 channels and of size 512 X 512 pixels. The images are tiled in a 15 X 9 rectangular grid. And there are 3 positions, each one made of 135 images (15x9).

Reading all the images with bfGetReader and related methods I was able to extract the position of each tile in the (even though I got some weird values), but I couldn't find anywhere information about the number of positions in the file (3 in this case), nor could I find in the OME metadata information about the overlap percentage between tiles, or the size of the rectangular grid.

Does anybody know of a way of getting this information? For simpler file (just one "position", and accurate X and Y information about each tile) I was able to infer the grid size as well as the overlap between tiles, but this approach doesn't work now.

Here's what some information I got from ZEN:
Dimensions: x: 4198, y: 6963, positions: 3, channels: 3, 12-bit
Tile scan: tiles: 135, overlap in percent: 10.0, tiling mode: rectangular grid


If you want to check the file, I uploaded it here: http://qa.openmicroscopy.org.uk/qa/feed ... 93297ce80e

Thanks in advance! :-)
StefanoMas
 
Posts: 6
Joined: Tue Sep 13, 2016 12:22 pm

Re: [Matlab] How to retrieve Tile and Position infor from .C

Postby bramalingam » Wed Sep 14, 2016 1:35 pm

Hi,

Thank you for submitting your issue.

We are currently not populating the seriesMetadata with the 'scene'(position) information, properly for each tile.
I have filed a ticket on this regard,
http://trac.openmicroscopy.org/ome/ticket/13290#ticket

We look forward to tackling this issue at the earliest.
Hope that helps.

Best,
Balaji
User avatar
bramalingam
 
Posts: 70
Joined: Tue Jan 14, 2014 12:01 pm

Re: [Matlab] How to retrieve Tile and Position infor from .C

Postby StefanoMas » Mon Sep 19, 2016 9:49 am

Hi Balaji,

thanks for the reply. I hope it will get fixed soon, then. Ideally it would be nice to have a method to extract the total number of scenes/positions in the file, as well as a modified getIndex method that accepts as input not only the stack, time and channel number but also the scene/position.

Somehow related to the question: what is the best way to retrieve the X-Y position of each plane in the file? And to retrieve the overlap between planes?

Thanks a lot in advance!
StefanoMas
 
Posts: 6
Joined: Tue Sep 13, 2016 12:22 pm

Re: [Matlab] How to retrieve Tile and Position infor from .C

Postby bramalingam » Wed Sep 21, 2016 3:48 pm

Hi,

Thank you for your suggestions.
The ticket is primarily targeted towards making the "seriesMetadata” populated appropriately (ex: scenes/positions).

We normally add api methods, when they are generic enough for multiple formats and we will review the modified getIndex() case and see if it can be made available.

The XY position list can be extracted from the omeMetadata(MetadataRetrieve) object as follows,
omeMetadata = reader.getMetadataStore();
XYvec=[];
for imageCount=1:omeMetadata.getImageCount()
for planeCount=1:omeMetadata.getPlaneCount(imageCount-1)
X = omeMetadata.getPlanePositionX(imageCount-1,planeCount-1).value.doubleValue;
Y = omeMetadata.getPlanePositionY(imageCount-1,planeCount-1).value.doubleValue;
XYvec = [XYvec ; imageCount, planeCount, X, Y];
end
end

And if you need more information on the same, please follow the documentation page below:
http://www.openmicroscopy.org/site/supp ... b-dev.html
(specifically : http://downloads.openmicroscopy.org/bio ... rieve.html for the MetadataRetrieve object)

Hope that helps.

Best,
Balaji
User avatar
bramalingam
 
Posts: 70
Joined: Tue Jan 14, 2014 12:01 pm

Re: [Matlab] How to retrieve Tile and Position infor from .C

Postby vjanve » Fri Nov 04, 2016 2:04 pm

HI Balaji and Stefanomas,

I too am having issue reading the stitched(stitched in ZEN blue, advanced tile module) image data from a .czi tiled(10x10, 10% overlap, rectangular grid) zstacks(45-zplanes) at specified positions(11) and with 2 channels.

the bfopen() and reader method (reader = bfGetReader(filename); ... ) both are not retrieving the whole image data set.

The position retrieval code provided earlier did not work for me.
However, I am able to get position related function. I am posting the code I used in case some else needed it. Will work on image retrieval when I get chance currently tiff export is working from Zen just adds more steps.

img_data_single_zstacks = bfopen(czi_image_path); % series Data is not read correctly
metadata = data{1, 2};
Xscale = metadata.get('Global Experiment|AcquisitionBlock|AcquisitionModeSetup|ScalingX #1');
Yscale = metadata.get('Global Experiment|AcquisitionBlock|AcquisitionModeSetup|ScalingY #1');

% # of tiles/Scenes
n_scenes = str2double((metadata.get('Global Information|Image|SizeS #1')));
pos_scenes = zeros(n_scenes,3);
for i_scene =1:n_scenes
x_key=sprintf('%s%.2d','Global Information|Image|S|Scene|Position|X #',i_scene);
y_key=sprintf('%s%.2d','Global Information|Image|S|Scene|Position|Y #',i_scene);
z_key=sprintf('%s%.2d','Global Information|Image|S|Scene|Position|Z #',i_scene);

xpos = str2double(metadata.get(x_key));
ypos = str2double(metadata.get(y_key));
zpos = str2double(metadata.get(z_key));
if(troubleshoot ==1)
disp([xpos, ypos, zpos])
end
pos_scenes(i_scene,:)= [xpos, ypos, zpos];
end

Cheers,
Vaibhav
vjanve
 
Posts: 1
Joined: Fri Nov 04, 2016 11:28 am

Re: [Matlab] How to retrieve Tile and Position infor from .C

Postby i.munro » Wed Nov 09, 2016 4:39 pm

Dear Stefanomas

I just tried opening the .czi file, that you uploaded, using the bio-formats importer in Fiji to display the metadata and I see the following fields:

Information|Image|S|Scene|Position|X #1 -48113.6
Information|Image|S|Scene|Position|X #2 0
Information|Image|S|Scene|Position|X #3 0
Information|Image|S|Scene|Position|Y #1 13724
Information|Image|S|Scene|Position|Y #2 -0
Information|Image|S|Scene|Position|Y #3 -0
Information|Image|S|Scene|Position|Z #1 163.245
Information|Image|S|Scene|Position|Z #2 0
Information|Image|S|Scene|Position|Z #3 0

Is this the information that you need to access from Matlab?
My apologies if this is a naive question, I am new to this file format.

Best Wishes

Ian
i.munro
 
Posts: 50
Joined: Thu Apr 25, 2013 1:01 pm

Re: [Matlab] How to retrieve Tile and Position infor from .C

Postby StefanoMas » Mon Dec 05, 2016 3:50 pm

Dear Ian, Vaibhav,

thanks for the kind reply.

Ian: yes, basically I'd need a method that returns the toal number of series in the file. I couldn't find any from the OME metadata, but apparently Vaibhav found one in the CZI metadata.

In the end I built my own CZI file reader, based on the CZI file specification, without resorting on BioReader. For our purposes it seem to work fine, I could share the matlab files if anybody needs them.

Best,
Stefano
StefanoMas
 
Posts: 6
Joined: Tue Sep 13, 2016 12:22 pm


Return to User Discussion [Legacy]

Who is online

Users browsing this forum: No registered users and 0 guests