-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathread_file.py
More file actions
55 lines (46 loc) · 1.38 KB
/
Copy pathread_file.py
File metadata and controls
55 lines (46 loc) · 1.38 KB
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
'''
Script to read and display information on the EDF files
'''
# Import built-in Packages
import os
# Import 3rd party package
import mne
import xlsxwriter
# Import authorship info
import init
# Read the files
def read_edf():
path = os.getcwd() + '\\data\\'
files = []
print("Reading files...")
for f in os.listdir(path):
files.append(mne.io.read_raw_edf(path+f))
print(f"Reading {f} now..")
print('Reading successfully completed!')
return files
# Display the information
def get_info(files):
for index, item in enumerate(files):
print(f"> Record Information of patient {index+1}:\n{item.info}")
print("-"*40)
print('Information generated!')
return True
def get_channel_names(files):
row = 0
column = 0
workbook = xlsxwriter.Workbook('Channelnames.xlsx')
worksheet = workbook.add_worksheet("Names of Channels")
for _, item in enumerate(files):
worksheet.write(row, column, len(item.info['chs']))
l = 0
while(l < len(item.info['chs'])):
worksheet.write(row+l+1, column, item.info['ch_names'][l])
l += 1
column += 1
workbook.close()
print('Writing Channel Names Complete!')
return True
if __name__ == "__main__":
files = read_edf()
get_info(files)
get_channel_names(files)