|
a |
|
b/load_deap.py |
|
|
1 |
import cPickle |
|
|
2 |
import os |
|
|
3 |
from multiprocessing import Pool |
|
|
4 |
import sys |
|
|
5 |
import numpy as np |
|
|
6 |
chan = ['Fp1','AF3','F3','F7','FC5','FC1','C3','T7','CP5','CP1','P3','P7','PO3','O1','Oz','Pz','Fp2','AF4','Fz','F4','F8','FC6','FC2','Cz','C4','T8','CP6','CP2','P4','P8','PO4','O2'] |
|
|
7 |
nLabel, nTrial, nUser, nChannel, nTime = 4, 40, 32, 32, 8064 |
|
|
8 |
print "Program started \n" |
|
|
9 |
fout_labels0 = open("labels_0.dat",'w') |
|
|
10 |
fout_labels1 = open("labels_1.dat",'w') |
|
|
11 |
fout_labels2 = open("labels_2.dat",'w') |
|
|
12 |
fout_labels3 = open("labels_3.dat",'w') |
|
|
13 |
for i in range(nUser):#4, 40, 32, 32, 8064 |
|
|
14 |
if i < 10: |
|
|
15 |
name = '%0*d' % (2,i+1) |
|
|
16 |
else: |
|
|
17 |
name = i+1 |
|
|
18 |
fname = "/data_preprocessed_python/data_preprocessed_python/s"+str(name)+".dat" |
|
|
19 |
x = cPickle.load(open(fname, 'rb')) |
|
|
20 |
print fname |
|
|
21 |
for tr in range(nTrial): |
|
|
22 |
fout_data = open("features_raw.csv",'w') |
|
|
23 |
for ch in chan: |
|
|
24 |
fout_data.write(ch+",") |
|
|
25 |
fout_data.write("\n") |
|
|
26 |
for dat in range(nTime): |
|
|
27 |
for ch in range(nChannel): |
|
|
28 |
if ch <32: |
|
|
29 |
if ch == 31: |
|
|
30 |
fout_data.write(str(x['data'][tr][ch][dat])); |
|
|
31 |
else: |
|
|
32 |
fout_data.write(str(x['data'][tr][ch][dat])+","); |
|
|
33 |
fout_data.write("\n"); |
|
|
34 |
fout_labels0.write(str(x['labels'][tr][0]) + "\n"); |
|
|
35 |
fout_labels1.write(str(x['labels'][tr][1]) + "\n"); |
|
|
36 |
fout_labels2.write(str(x['labels'][tr][2]) + "\n"); |
|
|
37 |
fout_labels3.write(str(x['labels'][tr][3]) + "\n"); |
|
|
38 |
fout_data.close() |
|
|
39 |
os.system('python creating_vector.py') |
|
|
40 |
print "user "+ str(i) +" trail"+ str(tr) |
|
|
41 |
fout_labels0.close() |
|
|
42 |
fout_labels1.close() |
|
|
43 |
fout_labels2.close() |
|
|
44 |
fout_labels3.close() |
|
|
45 |
print "\n"+"Print Successful" |