How to calculate spatial correlations between two distinct maps

Dear Neurostar community,

I have come across numerous papers thats state that they conducted spatial correlations between two distinct maps, to quantify the spatial correspondence between such maps. From the articles I’ve read, there is usually a single correlation value that is provided for quantifying the correlation between two maps.

However, I am unable to find how this is done in such articles.

Can anyone provide any ideas as to how these correlations are done?

Best,
Paul

If you have two maps (img_file1 and img_file2) and a brain mask (mask_file), then, in Python, one method to do this would be:

import numpy as np
from nilearn import masking
# Load data as 1D (# voxels) arrays
data1 = masking.apply_mask(img_file1, mask_file)
data2 = masking.apply_mask(img_file2, mask_file)
# Calculate correlations
correlations = np.corrcoef(data1, data2)
# Grab correlation between data1 and data2 from cross-correlation matrix
corr = correlations[0, 1]

Thank you tsalo for your response!

I am confused as to what is being correlated itself. How is a single correlation value being derived from two different maps? I am having trouble understanding the logic behind it all. Any insight would be great!

Let’s say your maps are both 3D (91x109x91 voxels), and your mask is the same size, with 228453 voxels that are “brain”. When you apply the masker to your images, it unravels the data and you end up with two 1D vectors of 228453 values. You then just correlate those two vectors.

Hey guys. I actually wrote a post here on that subject matter http://www.bcblab.com/BCB/Coding/Coding.html

Hope it helps
Mich

Hello, I also encountered this problem, and I found that different articles have different calculation methods, such as calculation of Pearson correlation (r), calculation of coefficient of determination (R2, I am not clear how to calculate). So have you solve this problem?

Greetings,

I’m definitely not an expert in this exact topic, but I would say in regards to what’s most common, I would say Pearson’s correlation (R) is from what I have seen.

From what I understand, you are essentially performing a correlation where each brain region is acting like a sample. Let’s say you had two maps with both having the same parcellation (e.g., 100 regions). You would then correlate it in a way where the regions themselves are acting as the “samples”. So you would have one 100 x 1 vector from one map, and another 100 x 1 vector from the other map, and you’d simply take the correlation between the two.

This is my understanding as someone who has limited experience with this type of work, but I hope that helps.

Hi,
Thanks for your reply. Indeed, I am calculating the correlation of brain region or brain functional network between two maps. What I have seen is that for discrete data, such as parcellation, cluster evaluation indexes such as Dice coefficient or Rand Index can be used. For continuous data such as functional connectivity, Pearson’s correlation (R) is generally used. Like this article, Lynch CJ, etc. Cell Rep. 2020. What do you think?