Skip to content

Registering ROIs across different sessions \ days

eftychios pnevmatikakis edited this page Apr 5, 2017 · 1 revision

A problem that arises in practice is that of registering two different sets of components/ROIs obtained from approximately the same field of view (FOV) over the course of two different experiments/days. The function register_ROIs.m implements a simple method for doing so. It takes as an input two sets of spatial components A1 and A2 and outputs matches between the different sets of components and the components from each set that were not matched. The function operates in the following stages:

1. Alignment of the different FOV with each other

The assumption here is that the two sessions were the in the course of different experiments so that the FOVs were sufficiently different and cannot be processed together for motion correction and source extraction using the pipeline. Even in this case alignment between the FOVs can help minimize the differences and enable better registration results.

To perform the alignment, the templates from the motion correction step template1 and template2 as well as a motion correction parameters structure options_mc are needed. If the templates are not accessible, then the means across time of the motion corrected datasets can be provided. As a first step register_ROIs.m aligns the two templates with each other and computes a displacement field global_shift. This displacement field is then applied to every spatial component of A2 so that these are aligned with the FOV of the first session.

2. Express spatial components as binary masks

Afterwards each spatial component is represented as a binary mask. This is done by thresholding each component at a level equal to options.dist_maxthr times the maximum value of the component. After thresholding connected components are extracted and only the largest one is kept. This terms the two sets of spatial components A1 and A2 into two set of binary masks M1 and M2

3. Calculation of distance matrix between M1 and M2

A distance matrix D is constructed with D(i,j) = dist(M1(:,i),M2(:,j)). As a distance between two components we take the Jaccard index, i.e., D(i,j) = 1 - (|intersection(M1(:,i),M2(:,j))|/|union(M1(:,i),M2(:,j))|)^n, where n is an exponent to control the steepness of the distance, is controlled by options.dist_exp and has default value 1. Distances above options.dist_thr (default value: 0.5) are set automatically to infinity to avoid false registration. Finally if the smallest component has size at least options.dist_overlap_thr times the intersection size (default value: 0.8) then we assume that the smallest component is a subset of the largest component and set the distance to 0.

4. ROI registration through the Hungarian algorithm

Registration occurs by applying the Hungarian algorithm to the distance matrix D. The components are then partitioned into matched pairs and unmatched components from each session.