Created
          March 10, 2016 01:14 
        
      - 
      
- 
        Save JesseLivezey/744c62e0442cb7d4c654 to your computer and use it in GitHub Desktop. 
    Calculate 1xn corrcoef
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def corrcoef(X, Y): | |
| """ | |
| Return Pearson correlation coefficients between 1 and n variables. | |
| Parameters | |
| ---------- | |
| X : (1 x dim) matrix, single voxel | |
| Y : (n x dim) matrix, other voxels | |
| """ | |
| X_no_mean = X - X.mean(keepdims=True) | |
| Y_no_mean = Y - Y.mean(axis=1, keepdims=True) | |
| return X_no_mean.dot(Y_no_mean.T)/X.std(keepdims=True)/Y.std(axis=1, keepdims=True)/X.shape[1] | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment