| Literature DB >> 25653614 |
Dylan R Muir1, Björn M Kampa2.
Abstract
Two-photon calcium imaging of neuronal responses is an increasingly accessible technology for probing population responses in cortex at single cell resolution, and with reasonable and improving temporal resolution. However, analysis of two-photon data is usually performed using ad-hoc solutions. To date, no publicly available software exists for straightforward analysis of stimulus-triggered two-photon imaging experiments. In addition, the increasing data rates of two-photon acquisition systems imply increasing cost of computing hardware required for in-memory analysis. Here we present a Matlab toolbox, FocusStack, for simple and efficient analysis of two-photon calcium imaging stacks on consumer-level hardware, with minimal memory footprint. We also present a Matlab toolbox, StimServer, for generation and sequencing of visual stimuli, designed to be triggered over a network link from a two-photon acquisition system. FocusStack is compatible out of the box with several existing two-photon acquisition systems, and is simple to adapt to arbitrary binary file formats. Analysis tools such as stack alignment for movement correction, automated cell detection and peri-stimulus time histograms are already provided, and further tools can be easily incorporated. Both packages are available as publicly-accessible source-code repositories.Entities:
Keywords: Matlab; analysis toolbox; neuronal responses; open source; small memory footprint; two-photon calcium imaging; visual stimulus generation
Year: 2015 PMID: 25653614 PMCID: PMC4299654 DOI: 10.3389/fninf.2014.00085
Source DB: PubMed Journal: Front Neuroinform ISSN: 1662-5196 Impact factor: 4.081
Figure 1Overview of visual stimulation, stack acquisition and analysis in Matlab. (A) StimServer is used to generate and present visual stimuli to an animal, under the control of a calcium imaging system, over a network link. Data is stored in a binary format. (B) A FocusStack object is created in Matlab, to access several sequential data blocks as a single concatenated stack. (C) The FocusStack object “fs” can now be accessed as a Matlab tensor, and passed into Matlab functions. (D) Extracting a single frame is as simple as referencing a Matlab tensor. (E) Extracting the response trace through time of a single pixel is equally simple.
Figure 3Information flow of a . Additional analysis steps can easily be added (see text).
Figure 2Stimulus information and other meta-data associated with each frame. A series of drifting grating stimuli were presented in randomized order (see values of nStimulusSeqID), over several repeats (see values of nBlockIndex). Using FocusStack.FrameStimulusInfo, the stimulus meta-data associated with each frame can be accessed (meta-data is listed for the frame indicated by the arrow). In addition, each frame is associated with a mis-alignment shift (mfFrameShifts), a “black” level (vfBlackTrace), and a per-pixel baseline distribution (insets at top right). Colors at top left indicate the corresponding traces of meta-data values in the time-series plot.
List of meta-data provided by a .
| Spatial calibration of the stack (X and Y), in pixels per μm | |
| Acquisition time per frame, in seconds | |
| Z spacing between subsequent frames, in μm | |
| Misalignment shifts for each frame, in fractional pixels. Assigned manually, or using alignment method | |
| Black set-point value for each frame, in raw units. Assigned manually, or using utility method | |
| Blank time between episodic visual stimuli | |
| List of stimuli presented (one stimulus ID per data file). Each stimulus ID can contain a sequence of several individual stimuli | |
| (Read-only)Total number of individual stimulus sequence IDs presented in the entire stack | |
| Cell array, each element containing a vector of stimulus sequence IDs in the order they were presented | |
| Vector of stimulus sequence ID durations, in seconds. Each entry specifies the duration of the corresponding stimulus sequence ID | |
| Vector of onset times for each individual stimulus presentation, as an offset in seconds from the first frame of the stack. Assigned manually, or computed automatically | |
| Vector of end times for each individual stimulus presentation, as an offset in seconds from the first frame of the stack. Assigned manually, or computed automatically | |
| Matrix of times indicating which periods of stimulus presentation should be used for analysis. Each row corresponds to a stimulus sequence ID, and is a row vector | |
All the parameters listed here are FocusStack class properties, and should be assigned from meta-data stored with the data file, whenever possible.
List of meta-data provided by a .
| The time in seconds since the first frame in the stack. (FSI) | |
| The index of the block (data file) the associated frame falls within. (FSI) | |
| The index of the associated frame within the block, with the first frame given index 1. (FSI) | |
| The time in seconds since the first frame in the block. (FSI) | |
| The stimulus sequence ID associated with each frame. (FSI) | |
| The time in seconds of the associated frame since the onset of the stimulus in which the frame falls. (FSI) | |
| The index of the current stimulus presentation in the entire stack. The first stimulus is given index 1. (FSI) | |
| A boolean value associated with each frame, indicating whether that frame should be used for analysis. (FSI) | |
| Mean and standard deviation distribution of the baseline distribution assigned to a stack. Obtained by referencing a stack using | |
| The baseline distribution is assigned using the | |
Parameters listed that specify “FSI” for access are obtained using the FocusStack/FrameStimulusInfo class method, and are computed from the parameters given in Table 1.
Creating a .
Assigning stimulus durations and extracting derandomized calcium traces. Note that the order of stimulus presentation can and should be stored as meta-data by the two-photon acquisition system. If meta-data is present in the data files, then .
Creating and accessing MappedTensor objects.
Creating and accessing .
Timing the loading of a stack using .
Timing the loading of a TIFF file using .
Memory storage and time benchmarks for .
| Data size on disk | 241 MB | |
| Time to create | ≈350 ms | |
| Time to read in data for entire stack | 16–17 s | |
| Memory usage within Matlab | 108 kB | |
| 230 MB | ||
| 1.8 GB | ||
| Data size on disk | 958 MB | |
| Time to create stack | ≈280 ms | |
| ≈230 ms | ||
| Time to read in data for entire stack | 18–25 s | |
| 6.5–7.4 s | ||
| 12–17 s | ||
| 57–68 s | ||
| Memory usage within Matlab | 33 MB | |
| 900 MB | ||
| 900 MB | ||
| 3.5 GB | ||
| Data size on disk | 116 MB | |
| Time required to load data, align stack and extract calcium responses | 150 s | |
| 470 s | ||
| Memory usage within Matlab | 230 kB | |
| 116 MB | ||
128 × 128 × 7378 × 2 pixels, 8-bit data across 7 files.
512 × 512 × 900 × 1 pixels, 16-bit data across 2 files.
Memory usage by FocusStack for TIFF data is mostly consumed by caching of image header information within TIFFStack objects.
128 × 128 × 7378 × 1 pixels, 8-bit data across 7 files.
Initialization of the .
Configuring a set of stimuli and starting the .
Figure 4Example dialogue between . Commands are sent over the command channel (red); talkback notifications are sent of the talkback channel (blue).
Stimuli provided out of the box by .
| Blank stimulus | |
| Group a set of other stimuli into a randomizable sequence | |
| Drifting and rotating masked sinusoidal grating | |
| Drifting and rotating plaid composed of two additively combined sinusoidal gratings, with arbitrary relative orientations | |
| Drifting and rotating masked square-wave grating | |
| Drifting and rotating plaid composed of two additively combined square-wave gratings, with arbitrary relative orientations | |
| Static oriented square-wave grating that oscillates in contrast | |
| Static plaid composed of two oriented square-wave gratings that oscillate in contrast and phase | |
| Sparse noise composed of pixels arranged in a grid | |
| Sparse noise composed of pixels that oscillate in contrast | |
| Sparse noise, where each pixel is a masked square-wave grating that drifts and rotates | |
| Spatially- and temporally-filtered white noise | |
| Random dot kinematogram stimulus | |
| A sequence of flashed arbitrary images | |
| A field of Gabors with arbitrary locations and arbitrary individual parameters, that drift in phase and rotate | |
| A regular grid of Gabors with arbitrary individual parameters, that drift in phase and rotate | |
| Present an arbitrary movie from a file, with a circular mask |
Figure 5Overview of A list of stimuli and stimulus sequences is constructed (see Listing 8). (B) StartStimulusServer is called from the Matlab command line. (C) If the Instrument Control Toolbox is used for network communication (green), control returns to the Matlab command line (i.e., non-blocking network listening). If PNET is used for network communication then StimServer enters a blocking poll loop (blue). When a presentation command is received (D), the stimulus-defined presentation function is called (E). Commands shown in orange are modular, and can be replaced to introduce new stimulus classes.
Figure 6Example analyses conducted with An RF localization experiment, where a sparse random stimulus is presented over a 5×5 mesh. (B) Measuring preferred orientation using drifting gratings. (C) Recording single-neuron and population responses to natural movie stimuli. (D) Single-trial single-neuron calcium responses to sparse noise stimuli. (E) Single-trial single-neuron responses to drifting high-contrast gratings. (F) Single-trial single-neuron calcium responses to a natural movie stimulus. (G) and (H) show the estimated RF location for the neuron shown in (D). (I) The trial-averaged direction tuning curve for the neuron shown in (E). (J) The population distribution of lifetime (L.T.) and population (Pop.) sparseness, from responses imaged simultaneously with the neuron shown in (F). Stimulus onset in all traces (D, E, F) is indicated by a vertical tick mark. Data provided by M. Roth.