Skip to content

03 Data Processing

Jane Ling edited this page Oct 31, 2023 · 2 revisions

Initial Screening

In each pixel, the maximum delta F over F was estimated from the maximum and median of the raw fluorescence intensity.

A top-hat filter was used to correct for the uneven illumination in the field of view. The correction might not be obvious to the eyes in the image, but it improved the segmentation.

The function graythresh was used to identify regions of interest. It computes a global threshold using Otsu's method.

The following figures show the initial steps of segmentation.

image image image image

Filtering to Remove Noise

There were two steps of filtering. The first step was to remove pixels with a small signal-to-noise ratio (SNR). Since event detection was done with slope detection, SNR was calculated as the maximum slope divided by the standard deviation. Pixels with SNR smaller than ops.SNR_thres will be removed.

The second step was to remove pixels with a drifting baseline. This was done by calculating the error between the baseline and its linear fit and comparing it to the threshold ops.BL_drift_thres. The figure below shows an example of the errors in each pixel in a trial.

image

Detecting Events for Each Pixel

Parallel computing is recommended for this part. If the computer does not allow parallel processing, modify parfor in the script to for.

An event in each pixel was defined with the following criteria:

  1. Rising slope > threshold defined by ops.m_mode and ops.m_thres, currently set as 'SD' and 3

  2. DFoF > 3 * SD

  3. If the previous peak is within ops.maxISI, the event would be included.

  4. If the duration of the rising slope is within ops.rising_time_thres, the event would be included.

Pixels with no event detected were removed. The following figure shows the mask after the above steps of processing. Most of the elongated structures in the previous step have been removed.

image

Defining Regions of Interest (ROI)

ROIs were defined using the built-in MATLAB function regionprops. The first figure below shows the label mask after defining ROI. The second figure below shows the DFoF for each pixel in an ROI. The third figure below shows the average delta F for the ROI. Any event that only occurs in 1 pixel, within an ROI of more than 1 pixel, will be excluded from the analysis.

image image image

Clustering Events

For any ROI of an area of more than 1 pixel, the location of each event was determined on the map of delta F. A 2D Median filter was used to smooth out noise in the spatial domain before applying the findpeaks_2d function. If only one or no spatial peak was detected (due to a small area), a weighted average approach would be used to determine the location of the event. The following figures show examples of an ROI with two synapses firing individually/ at the same time.

image image image image image image image image

The following figure shows the clustering of the above event locations into two synapses. Clustering was based on the distance between centroids of two clusters, with a cutoff value set by ops.cutoff.

image

Calculating Event Statistics

Before calculating event statistics, It is recommended to check that event clusters are segmented correctly and there are no spike trains in your dataset. This can be done by going through the .png in the folder ROI_signal. Make necessary editing with the functions provided according to 04 Post‐Processing.

After checking the events and ROIs, running the part event statistics would give the following fields in the structure stats:

  • N_syn : (int) number of synapses (event clusters)

  • n_spikes_total : (int) the total number of events

  • dff_all : (1, n_spikes_total) array containing delta F over F of each event for all the synapses

  • dfft_all : (1, n_spikes_total) array containing the timing of each event for all the synapses

Synchronous firing can be checked from the following graphs.

image image

Clone this wiki locally