# BrainSync Transform

BrainSync is an orthogonal transformation that allows comparison of resting fMRI (rfMRI) time series across subjects. For this purpose, we exploit the geometry of the rfMRI signal space to conjecture the existence of anorthogonal transformation that synchronizes fMRI time series across sessions andsubjects. The method is based on the observation that rfMRI data exhibit similar connectivity patterns across subjects, as reflected in the pairwise correlations between different brain regions. The orthogonal transformation that performs the synchronization is unique, invertible, efficient to compute, and preserves the connectivity structure of theoriginal data for all subjects. Similarly to image registration, where we spatially align the anatomical brain images, this synchronization of brain signals across a population or within subject across sessions facilitates longitudinal and cross-sectional studies of rfMRI data.

The BrainSync concept is illustrated below:

Please refer to our publications below for detailed explanation and examples.

The following video shows the rfMRI signal of a (left) subject brain; (middle) a reference brain and (right) synced subject.

## Software

The input is assumed to be two time x vertices datasets, one is denoted as subject and second as target. In order to generate the preprocessed time series on the cortical surface, the preprocessing that we do is described in our publications below. Specifically, we recommend using tNLM filtering as denoising done by tNLM helps in obtaining a much better synchronization.

It is highly recommened that the input is normalized to have unit varaince. Please use the functions provided below before applying BrainSync as follows.

### Matlab

The matlab source code for BrainSync can be downloaded below.

As an input we assume data matrices (Time x Vertices) of two scans, referred to as sub and ref. First the data should be normalized to 0 mean and unit variance by running:

sub = normalizeData(sub) % Do the data normalization for subject brain ref = normalizeData(ref) % Do the data normalization for the reference brain

and then the data can be synchronized using the following code.

% subSynced is the synched data for the subject and % O is the associated orthogonal transform [subSynced, O] = brainSync(ref, sub)

### Python

The python source code for BrainSync can be downloaded below.

As an input we assume data as numpy arrays (Time x Vertices) of two scans, referred to as sub and ref. First the data should be normalized to 0 mean and unit variance by running:

from brainsync import brainSync, normalizeData sub, _, _ = normalizeData(sub) # Do the data normalization for subject brain ref, _, _ = normalizeData(ref) # Do the data normalization for the reference brain

and then the data can be synchronized using the following code.

# subSynced is the synched data for the subject and # O is the associated orthogonal transform subSynced, O = brainSync(ref, sub)