You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
Thank you for the wonderful Matlab interface. I found it very useful and only code that worked on my czi file. Other libraries (aicsimageio, pyCZIutils, aicspylibczi,bioformats) didn't work.
If anyone else is wondering how to get a scene from a czi image, here is what I used
%Inputs:
inputczi=/home/user/myczifile.czi
scenenum=5 %5th scene
h=MEXlibCZI('Open',inputczi); % inputczi is a SCZXY file,S=scene,C=channel,Z=number of slices
% z = the z slice to use, 0 based
% channelnum = channel number to use, 0 based
ID=['Z' num2str(z) 'C' num2str(channelnum)];
% Use ZzCc format,Z0C1, Z1C1 etc, 0 based
% scenenum = scene index, 1 based because Matlab struct
b1=MEXlibCZI('GetSingleChannelScalingTileComposite',h,info.sceneBoundingBoxes(scenenum).boundingBox,ID,1); % full zoom=1
% b1 is a YX 2D matrix of uint16. For some reason, GetMultiChannelScalingTileComposite gives uint8.
% b1 dimension is YX as opposed to XY, czi XY is Tif's YX, so need to transpose the file later
MEXlibCZI('Close',h);
Also, it is possible to run this in parallel to obtain multiple channels or scenes (given the disk I/O bound)
% Obtain multiple z slices in parallel and create a 3D volume
temp=cell(1,Z);
scenenum=5; % get 5th scene (1 based)
channelnum=3; % extract 4th channel, 0 based index
parfor z=1:Z
fprintf('Reading Z=%d\n',z);
h=MEXlibCZI('Open',inputczi);
s1=['Z' num2str(z-1) 'C' num2str(channelnum-1)];
% Use ZzCc format,Z1C1,Z2C1 etc, 0 based
b1=MEXlibCZI('GetSingleChannelScalingTileComposite',h,info.sceneBoundingBoxes(scenenum).boundingBox,s1,1);
temp{z}=b1;
MEXlibCZI('Close',h);
end
fprintf('\n');
for z=1:Z
vol(:,:,z)=temp{z};
end
Thank you and I hope this snippet is useful for someone else.
Activity