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 'brainsync.py'

Download

   1 import scipy as sp
   2 """
   3 BrainSync: An Orthogonal Transform for Syncronize the subject fMRI data to the reference fMRI data
   4 Authors: Anand A Joshi, Minqi Chong, Jian Li, Richard M. Leahy
   5 Based on 
   6 AA Joshi, M Chong, RM Leahy, BrainSync: An Orthogonal Transformation for Synchronization of fMRI Data Across Subjects, Proc. MICCAI 2017.
   7 
   8 
   9 """
  10 
  11 def normalizeData(pre_signal):
  12     """
  13      normed_signal, mean_vector, std_vector = normalizeData(pre_signal)
  14      This function normalizes the input signal to have 0 mean and unit
  15      variance in time.
  16      pre_signal: Time x Original Vertices data
  17      normed_signal: Normalized (Time x Vertices) signal
  18      mean_vector: Vertices x 1 mean for each time series
  19      std_vector : Vertices x 1 std dev for each time series
  20     """
  21     if sp.any(sp.isnan(pre_signal)):
  22         print('there are NaNs in the data matrix, synchronization\
  23 may not work')
  24 
  25     pre_signal[sp.isnan(pre_signal)] = 0
  26     mean_vector = sp.mean(pre_signal, axis=0, keepdims=True)
  27     normed_signal = pre_signal - mean_vector
  28     std_vector = sp.std(normed_signal, axis=0, keepdims=True)
  29     std_vector[std_vector == 0] = 1
  30     normed_signal = normed_signal / std_vector
  31 
  32     return normed_signal, mean_vector, std_vector
  33 
  34 
  35 def brainSync(X, Y):
  36     """
  37    Input:
  38        X - Time series of the reference data (Time x Vertex)
  39        Y - Time series of the subject data (Time x Vertex)
  40 
  41    Output:
  42        Y2 - Synced subject data with respect to reference data (Time x Vertex)
  43        R - The orthogonal rotation matrix (Time x Time)
  44 
  45    Please cite the following publication:
  46        AA Joshi, M Chong, RM Leahy, BrainSync: An Orthogonal Transformation
  47        for Synchronization of fMRI Data Across Subjects, Proc. MICCAI 2017,
  48        in press.
  49        """
  50     if X.shape[0] > X.shape[1]:
  51         print('The input is possibly transposed. Please check to make sure \
  52 that the input is time x vertices!')
  53 
  54     C = sp.dot(X, Y.T)
  55     U, _, V = sp.linalg.svd(C)
  56     R = sp.dot(U, V)
  57     Y2 = sp.dot(R, Y)
  58     return Y2, R

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