-
Notifications
You must be signed in to change notification settings - Fork 4
/
plot.py
61 lines (49 loc) · 1.54 KB
/
plot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import numpy as np
from scipy.stats import ttest_rel
from sklearn.metrics import mean_absolute_error
from scipy.io import loadmat
import matplotlib.pyplot as plt
import pandas as pd
# read csv file
def readcsv(filename):
data = pd.read_csv(filename)
c = []
data = np.array(data)
for i in range(0,data.shape[0]):
a = data[i][0]
b = np.array(list(a.split(" ")))
c.append(b)
return(np.array(c))
# Plot the connectomes
def show_mtrx(m):
fig, ax = plt.subplots(figsize = (20, 10))
min_val = round((m.min()), 6)
max_val = round((m.max()), 6)
cax = ax.matshow(m, cmap=plt.cm.Spectral)
cbar = fig.colorbar(cax, ticks=[min_val, float((min_val + max_val)/2), max_val])
cbar.ax.set_yticklabels(['< %.2f'%(min_val), '%.2f'%(float((min_val + max_val)/2)), '> %.2f'%(max_val)])
plt.title(label="Source graph")
plt.show()
# put it back into a 2D symmetric array
def to_2d(vector):
size = 35
x = np.zeros((size,size))
c = 0
for i in range(1,size):
for j in range(0,i):
x[i][j] = vector[c]
x[j][i] = vector[c]
c = c + 1
return x
# Display the source matrix of the first subject
pred = readcsv("source_graphs.csv")
SG = to_2d(pred[0])
show_mtrx(SG)
# Display the target graph in the domain 1 of the first subject
pred = readcsv("predicted_graphs_1.csv")
TG1 = to_2d(pred[0])
show_mtrx(TG1)
# Display the target graph in the domain 2 of the first subject
pred = readcsv("predicted_graphs_2.csv")
TG2 = to_2d(pred[0])
show_mtrx(TG2)