-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmattonpy.py
36 lines (30 loc) · 1.41 KB
/
mattonpy.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
from scipy.io import loadmat
import numpy as np
mat = loadmat("/home/sami/sami/Dataset/data/test2/test2.mat")
for k, v in (mat.items()):
if 'TD' in k:
matTD = mat['TD']
matX = mat['TD'][:,0]
matY = mat['TD'][:,1]
matP = mat['TD'][:,2]
matT = mat['TD'][:,3].astype('int32')
nEvents = matT.shape[0]
events = np.zeros((nEvents,4))
events[:,0] = matX.flatten()
events[:,1] = matY.flatten()
events[:,3] = matT.flatten()
events[:,2] = matP.flatten()
np.save("/home/sami/sami/Dataset/data/test1/test1.npy",events.astype('int32'))
elif 'events' in k:
matTD = mat['events']
matX = mat['events'][:,0]
matY = mat['events'][:,1]
matP = mat['events'][:,2]
matT = mat['events'][:,3].astype('int32')
nEvents = matT.shape[0]
events = np.zeros((nEvents,4))
events[:,0] = matX.flatten()
events[:,1] = matY.flatten()
events[:,3] = matT.flatten()
events[:,2] = matP.flatten()
np.save("/home/sami/sami/Dataset/data/test1/test1.npy",events.astype('int32'))