Export 5D image sequence in tif (and HDF5) formats
1 view (last 30 days)
Show older comments
I'm looking for a way to export 5D image sequences in the tif and HDF5 formats. Sequences are made of RGB images and contain depth and time information. For example a movie contains 10 time frames and in each time frame there are 5 "slices" in depth, for a total of 50 images. For now the best I can do is export individual stacks on their own, but not as a single file containing everything which could be opened with ImageJ for example. In other words, I get 10 image sequences of 5 images each whereas I would like one single file containing the 50 images in the right order. Is there a clever way to do this? In a near future I would also like to export in the HDF5 format; would the method be pretty much similar? Thanks a lot.
Here is the code I'm using for exporting individual stacks:
[fileName,pathName] = uiputfile({'*.tiff'},'Select the folder in which to save the files');
MovieToExport = zeros(ImageHeight,ImageWidth,3,TotalZSliceNumber,TotalTFrameNumber); % The sequence is a 5D matrix containing RGB images, hence the 3 as the 3rd dimension.
[~,~,ext] = fileparts(fileName);
cd(pathName);
MovieToExport = uint16(MovieToExport);
% remove .tiff, otherwise the name of the file is incorrect
fileName = regexprep(fileName,'\.tiff','');
for i= 1:TotalTFrameNumber % i.e. number of T frames...10 in my example above.
ExportedName = sprintf('%s%d.tif',fileName,i);
for k =1:TotalZSliceNumber % number of individual planes in each stack
MovieToExport(:,:,:,k,i) = MovieMatrix{i,k}; % MovieMatrix is a cell array containing the image sequence.
imwrite(MovieToExport(:,:,:,k,i),ExportedName,'tif','WriteMode', 'append', 'Compression','none');
end
end
0 Comments
Answers (0)
See Also
Categories
Find more on HDF5 in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!