Neuroimage
  • Comments
  • Menu
    • Attachments
    • Info
    • Raw Text
    • Print View
  • Login

Research

  • Home

  • Molecular Imaging

  • Brain Imaging & Connectivity

  • Image Analysis

Software

  • Brainstorm

  • BrainSuite

  • DigiMouse

  • Resources

Publications

  • Journal

  • Conference

People

  • Group Members

  • Alumni

  • Contact

Attachment 'brain_sync.m'

Download

   1 function [ sync_signal, rotation_matrix ] = brain_sync( reference_signal, moving_signal, mean_0_norm_1 )
   2 %%  BRAIN_SYNC: AA Joshi, M Chong, RM Leahy, 2017
   3 %
   4 %   Syncronize the moving signal to the reference signal, using BrainSync.
   5 %
   6 %   Input:
   7 %       reference_signal: Time series as the reference of BrainSync (vertices
   8 %       x time)
   9 %       moving_signal: Time series (individual, e.g.) to be rotated to sync
  10 %       with reference (vertices x time)
  11 %       mean_0_norm_1: Flag to indicate if the signal is already
  12 %       pre-processed to be zero mean and unit norm. (binary, default 0)
  13 %   Output:
  14 %       sync_signal: Syncronized time series, with respect to reference
  15 %       signal (vertices x time)
  16 %       rotation_matrix: The rotation matrix that syncronize the two time
  17 %       series (time x time)
  18 %       
  19 %   
  20 %   Please cite the following publication:
  21 %       AA Joshi, M Chong, RM Leahy, BrainSync: An Orthogonal Transformation for Synchronization of fMRI Data Across Subjects,, Proc. MICCAI 2017, in press.
  22 %
  23 %% Pre-Processing
  24 if ~(exist('mean_0_norm_1', 'var'))
  25     mean_0_norm_1 = 0 ;
  26 end
  27 if ~(mean_0_norm_1)
  28     [reference_signal, reference_mean, reference_std] = brain_sync_pre(reference_signal) ;
  29     [moving_signal, ~, ~] = brain_sync_pre(moving_signal) ;
  30 end
  31 
  32 
  33 %% BrainSync
  34 cross_corr = moving_signal' * reference_signal ;
  35 [U, ~, V] = svd(cross_corr) ;
  36 rotation_matrix = V * U' ;
  37 sync_signal = moving_signal * rotation_matrix' ;
  38 
  39 
  40 %%
  41 % Map back if necessary
  42 if ~(mean_0_norm_1)
  43     sync_signal = brain_sync_back(sync_signal, reference_mean, reference_std) ;
  44 end
  45 
  46 end
  47 
  48 
  49 
  50 %% Auxillary functions
  51 % To normalize signal to zero mean and unit norm
  52 function [normed_signal, mean_vector, std_vector] = brain_sync_pre(pre_signal)
  53     ones_vector = ones(1, size(pre_signal, 2)) ;
  54     pre_signal(isnan(pre_signal)) = 0 ;
  55     mean_vector = mean(pre_signal, 2) ;
  56     normed_signal = pre_signal - mean_vector * ones_vector ;
  57     std_vector = std(normed_signal, 1, 2) ;
  58     std_vector(std_vector == 0) = 1 ;
  59     normed_signal = normed_signal ./ (std_vector * ones_vector) ;
  60 end
  61 
  62 % Map the signal back to match the reference signal norm and mean
  63 function [back_signal] = brain_sync_back(normed_signal, mean_vector, std_vector)
  64     ones_vector = ones(1, size(normed_signal, 2)) ;
  65     back_signal = normed_signal .* (std_vector * ones_vector) ;
  66     back_signal = back_signal + mean_vector * ones_vector ;
  67 end

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2017-07-11 21:49:56, 1.9 KB) [[attachment:BrainSyncMatlab.zip]]
  • [get | view] (2017-07-12 20:55:36, 1.3 KB) [[attachment:BrainSyncMatlab_Ver1.01.zip]]
  • [get | view] (2017-07-11 22:55:50, 1.4 KB) [[attachment:BrainSyncMatlab_ver1.0.zip]]
  • [get | view] (2017-07-22 22:52:03, 1.3 KB) [[attachment:BrainSync_Matlab_Ver1.02.zip]]
  • [get | view] (2017-07-12 20:55:41, 1.1 KB) [[attachment:BrainSync_Python_Ver1.01.zip]]
  • [get | view] (2017-07-22 22:52:10, 1.1 KB) [[attachment:BrainSync_Python_Ver1.02.zip]]
  • [get | view] (2017-07-25 19:14:13, 1.1 KB) [[attachment:BrainSync_Python_Ver1.1.zip]]
  • [get | view] (2017-07-25 19:19:50, 1.1 KB) [[attachment:BrainSync_Python_Ver1.11.zip]]
  • [get | view] (2017-07-11 18:48:27, 2.4 KB) [[attachment:brain_sync.m]]
  • [get | view] (2017-07-12 18:30:52, 2.0 KB) [[attachment:brainsync.py]]
  • [get | view] (2017-07-11 22:17:35, 317.8 KB) [[attachment:fig1_webpage.svg.png]]
 All files | Selected Files: delete move to page

You are not allowed to attach a file to this page.

  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01