I am trying to extract a python numpy array of euclidean distances. I already have the values properly imported and distances calculated, and they are already in a visual heat map, but I do not know how to extract the values in a simple array to do further analyses on.
This is the code for creating a 5 (regions) x 4 (condition) matrix for all subjects:
import matplotlib.pyplot as plt
import seaboard as sns
for i in range (0, 41):
subject=result[i]
sns.heatmap(subject, annot=True, cmap='RdYlBu_r, yticklabels=['Anxiety', 'Empathy', 'Dominance', 'Unlabeled'],xticklabels=['Cuneus','SPL','Lingual','Cingulate', 'IFG'])
plt.show()
This is the code for calculating the Euclidean distance between each condition in 5 dimensional space for each subject:
for i in range(0,41):
subject=result[i]
s_rdm=pdist(subject, 'euclidean')
squareform(s_rdm)
sns.heatmap(squareform(s_rdm), annot = True, cmpa="RdYlBu_r', yticklabels=['Anxiety', 'Empathy','Dominance','Unlabeled'], xticklabels=['Anxiety', 'Empathy','Dominance','Unlabeled'])
plt.show()
I am not getting errors—these correctly calculate the distances for each subject. By including "annot = True", each matrix cell has the corresponding value. What I do NOT know how to do is save these distances in an array for future analyses.