Clone wiki

TwoPhotonAnalysis / Home


This is the public website for FocusStack, a Matlab toolbox for analysis of two-photon calcium imaging data. The toolbox is designed with a small memory footprint, so that analysis of arbitrarily large stacks can be performed on consumer-level hardware. The toolbox is stimulus-aware, and takes care of common low-level analysis tasks such as derandomization of stimulus order. FocusStack presents a simple interface, where two-photon stacks appear as Matlab tensors. This means that many existing analysis functions can seamlessly use FocusStack objects without modification. However, FocusStack also provides a sophisticated interface that makes use of knowledge about an imaging experiment.

Contributions to the toolbox are very welcome, as are suggestions for improvement.

If you use this toolbox, please cite our article in lieu of thanks:

Muir and Kampa, "FocusStack and StimServer: A new open source MATLAB toolchain for visual stimulation and analysis of two-photon calcium neuronal imaging data", Frontiers in Neuroinformatics 8 85.

Getting started

Quick introduction

FocusStack maps one or more binary two-photon stacks, stored on disk, to a Matlab tensor. To create a new stack:

% - Map two TIFF stacks to a FocusStack object
fs = FocusStack({block1.tif, block2.tif})

fs = 

  FocusStack object, class [uint8], dimensions [128 128 1402 2].

  Stack properties:
    cstrFilenames: {2 file(s)}
    bWritable: false (read-only)
    mfFrameShifts: (unaligned)
    fPixelsPerUM: 0.2188 (4.57 um per pixel)
    tFrameDuration: 0.1280 (7.81 Hz)
    fZStep: 0.0000 um per frame

  Data extraction:
    Internal data class: uint8
    Blank frames not assigned.
    bConvertToDFF: false (no dF/F conversion)
    bSubtractBlank: false (do not subtract blank)
    vfBlackTrace: (no black trace assigned)
    bSubtrackBlack: false (do not subtract black trace)

  Stimulus information:
    tBlankTime: 4.00 sec
    vnStimulusIDs: [2] (extracted)
    nNumStimuli: 17 in sequence
    cvnSequenceIDs: (extracted)
    vtStimulusDurations: (unassigned)
    vtStimulusStartTimes: (automatic)
    vtStimulusEndTimes: (automatic)
    mtStimulusUseTimes: (automatic)

To extract a single frame or pixel trace, reference this object using Matlab syntax:

% - Display a frame (all X and Y pixels), frame number 4, channel number 1
imagesc(fs(:, :, 4, 1));

% - Display a trace of a single pixel, using linear frame referencing
%   Pixel 192, all frames, channel 1
plot(fs(192, :, 1));

FocusStack objects also contain detailed frame-specific stimulus meta-data, accessible using the FrameStimulusInfo method:

[vtGlobalTime, ...
   vnBlockIndex, vnFrameInBlock, vtTimeInBlock, ...
   vnStimulusSeqID, vtTimeInStimPresentation, ...
   vnPresentationIndex, vbUseFrame] = ...

To extract derandomized calcium responses from a set of regions of interest (ROIs):

[vfBlankStds, mfStimMeanResponses, mfStimStds, mfRegionTraces, ...
   tfTrialResponses, tnFramesInSample, cvfTrialTraces] = ...
      ExtractRegionResponses(fs, sRegions, nBlankStimID);