Page 1 of 1

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

PostPosted: Tue Sep 13, 2016 2:55 pm
by StefanoMas
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! :-)

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

PostPosted: Wed Sep 14, 2016 1:35 pm
by bramalingam
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

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

PostPosted: Mon Sep 19, 2016 9:49 am
by StefanoMas
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!

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

PostPosted: Wed Sep 21, 2016 3:48 pm
by bramalingam
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

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

PostPosted: Fri Nov 04, 2016 2:04 pm
by vjanve
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

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

PostPosted: Wed Nov 09, 2016 4:39 pm
by i.munro
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

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

PostPosted: Mon Dec 05, 2016 3:50 pm
by StefanoMas
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