-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvisualize_data.py
87 lines (59 loc) · 2.79 KB
/
visualize_data.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
from __future__ import print_function
import os
import sys
import numpy as np
import scipy.io as sio
import matplotlib.pyplot as plt
################################################################################
################################ LOAD DATA #####################################
################################################################################
dir_name = 'processed_data/expressive_data/'
density = '08'
# load train data
fname = 'x_train_expressive_density_' + density + '.mat'
filename = os.path.join(os.getcwd(),dir_name,fname)
x_train_mat = sio.loadmat(filename)['x_train_expressive_mat']
x_train_mat = np.float32(x_train_mat)
fname = 'y_train_expressive_density_' + density + '.mat'
filename = os.path.join(os.getcwd(),dir_name,fname)
y_train_mat = sio.loadmat(filename)['y_train_expressive_mat']
y_train_mat = np.float32(y_train_mat)
# load test data
fname = 'x_test_expressive_density_' + density + '.mat'
filename = os.path.join(os.getcwd(),dir_name,fname)
x_test_mat = sio.loadmat(filename)['x_test_expressive_mat']
x_test_mat = np.float32(x_test_mat)
fname = 'y_test_expressive_density_' + density + '.mat'
filename = os.path.join(os.getcwd(),dir_name,fname)
y_test_mat = sio.loadmat(filename)['y_test_expressive_mat']
y_test_mat = np.float32(y_test_mat)
print('x_train_shape:',x_train_mat.shape)
print('x_test_shape:',x_test_mat.shape)
print('y_train_shape:',y_train_mat.shape)
print('y_test_shape:',y_test_mat.shape)
# Form training and testing data
x_train = np.zeros((x_train_mat.shape[2],116,116,1),dtype=np.float32)
y_train = np.zeros((x_train_mat.shape[2],1),dtype=np.float32)
x_test = np.zeros((x_test_mat.shape[2],116,116,1),dtype=np.float32)
y_test = np.zeros((x_test_mat.shape[2],1),dtype=np.float32)
for i in range(x_train_mat.shape[2]):
x_train[i,:,:,0] = x_train_mat[:,:,i]
y_train[i,0] = y_train_mat[i,0] # EXPRESSIVE SCORE
for i in range(x_test_mat.shape[2]):
x_test[i,:,:,0] = x_test_mat[:,:,i]
y_test[i,0] = y_test_mat[i,0] # EXPRESSIVE SCORE
################################################################################
################################################################################
##################################################################################
############################### DEFINE RN MODEL ##################################
##################################################################################
# Reshape input
print(x_train.shape)
x_train = x_train.reshape(x_train.shape[0], x_train.shape[1], x_train.shape[2], 1)
x_test = x_test.reshape(x_test.shape[0], x_test.shape[1], x_test.shape[2], 1)
input_shape = (x_train.shape[1], x_train.shape[2], 1)
plt.figure()
plt.imshow(x_train[15,:,:,0])
#plt.title('EP connectome with density'+' '+density)
plt.colorbar()
plt.show()