Reading .czi files into image arrays

47 views (last 30 days)
William MacTurk
William MacTurk on 13 Oct 2019
I have multichannel Z-stacks taken on a Zeiss LSM700, and wish to process and analyze them in MATLAB. The files are in .czi format, so I installed the bio-formats importer and use bfopen('foo.czi') to attempt to import the images. The example I've been working with has 2 channels, 20 z-slices each, although other files may have up to 4 channels and 60+ slices. When using the bfopen command, I get a warning, but then a window pops up allowing me to manually find the file and select it. output shown here:
>> bfopen('20191001_WM_231_gel1.czi')
log4j:WARN No appenders could be found for logger (loci.formats.ClassList).
log4j:WARN Please initialize the log4j system properly.
Reading series #1
........................................
ans =
1×4 cell array
Columns 1 through 3
{40×2 cell} {327 java.util.Hashtable} {40×40 cell}
Column 4
{1×1 loci.formats.ome.OMEXMLMetadataImpl}
Note that the window asking me to locate the file pops up after the two log4j:.... lines, after which "Reading Series #1..." shows after selecting the file.
Ideally, I want to load these .czi files as matrices with dimension (H x W x Z x C), so for my example Z = 20 z-slices, C = 2 channels, H x W = 1192x1192 pixels per image I'd end up with a workspace array (1192 x 1192 x 20 x 2) or something similar. Other things I've tried include using Fiji/ImageJ to save the stacks as .tifs, but then MATLAB only recognizes the first slice in the stack, returning a single 1192x1192 matrix (which is of no use to me). I've used MATLAB for image processing and analysis before, but never using z-stacks, and the images were already in a common format like .png or .jpeg. While I could manually separate each channel/slice and save them as .tifs or something in fiji, I'd really like to be able to automate the process and use only MATLAB.
I apologize for the generality of the question, but I'm at a loss here. All of my peers do their image processing in Fiji/ImageJ, and the few that use something like MATLAB do so only for strictly numeric applications. I know I can process my images much better by applying linear algebra techniques like PCA and SVD in matlab (c.f. Fiji), but I need to be able to read these stacks into matrices before I can work with them.
V/R
WM

Answers (0)

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!