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.You are not allowed to attach a file to this page.