title: How to generate valid HyperStack ImageJ data files from Matlab?
body: <p>ImageJ HyperStacks have a data type (8-32 bit), a width, a height, a number of channels, a number of slices and a number of frames. They represent 5D (XYCZT) data sets. ImageJ stores them as multipage tiff files where number of channels times number of slices times number of frames 2D (XY) images are stored. The first image seems to have two custom tags with IDs 50838 and 50839.</p>
  
  <p>I want to create tif files containing 5D data from Matlab that can be read by ImageJ as a valid 5D HyperStack.</p>
  
  <p>I can store a number of 2D images in a multipage tiff file in Matlab using <code>imwrite(matrix, file, 'WriteMode','append')</code> but ImageJ will read that as 3D (XYZ) image stack only. The information about the channels, slices and frames is not contained.</p>
  
  <p>I guess I could look at the ImageJ sources to find out where they store this missing information, then use Matlab's wrapper of LibTIFF to recreate the meta information of ImageJ. If you, however, already know what to do or if there is an alternative, I would like to hear it.</p>