-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_pre.py
33 lines (30 loc) · 941 Bytes
/
data_pre.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
import scipy.io
import numpy as np
import torch
class DATASET(object):
def read_data(self):
HC = scipy.io.loadmat('./HC.mat')['A']
ANI = scipy.io.loadmat('./ANI.mat')['A']
import numpy as np
alldata = np.concatenate((HC, ANI), axis=1)
A = np.squeeze(alldata.T)
y1 = np.zeros(70)
y2 = np.ones(67)
y = np.concatenate((y1, y2), axis=0)
series = []
for i in range(len(A)):
signal = A[i]
series.append(signal)
X = np.array(series)#(nsub,time,roi)
# print(X.shape)
return X, y
def __init__(self):
super(DATASET, self).__init__()
X, y = self.read_data()
self.X = torch.from_numpy(X)
self.y = torch.from_numpy(y)
self.n_samples = X.shape[0]
def __len__(self):
return self.n_samples
def __getitem__(self, index):
return self.X[index], self.y[index]