Wiki

Clone wiki

TwoPhotonAnalysis / NewFormats

How to integrate a new data format into FocusStack

Permitting FocusStack to seamlessly load a new binary data format requires two tasks:

  1. Mapping the binary data to memory, in a way that FocusStack can access; and
  2. Loading available metadata and assigning it to the stack.

The function FocusStack/OpenFiles is responsible for both of these tasks, and must be modified to load a new data format. Sub-functions are provided to open data files generated by Focus, Helioscan (and TIFF files in general), and binary Helioscan files with a sidecar XML meta-data file. We recommend creating a new function for each custom data format, which will then require the addition of only a few lines to FocusStack\OpenFiles to call the new function.

These sub-functions are responsible for opening a single data file, reading any meta-data, checking meta-data validity against the existing stack data, assiging the meta-data to the stack, and mapping the binary file to memory.

Mapping a binary data format to memory

FocusStack includes two utility classes for mapping common data formats into memory: TIFFStack (for handling exclusively TIFF files) and MappedTensor (which can handle arbitrary frame-based binary formats). Alternatively, the matlab memmapfile functionality can be used.

Each FocusStack contains a private property vhMemMapFileHandles, which is a cell array, with the number of elements equal to the number of data files in the stack. Each element contains the mapped data from one file.

Each file should be mapped to a tensor, with the dimensions [nChannels x nPixels x nFrames]. The low-level implementation uses linear pixel indexing, so that a 32x32 pixel stack with 100 frames and 2 channels would be mapped to a tensor with dimensions [2 x 1024 x 100].

Updated