File size: 873 Bytes
5fdbc81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

import mne
import streamlit as st
import matplotlib.pyplot as plt



def preprocessing_and_plotting(raw):
    # Select the first channel
    channel = raw.ch_names[0]
    st.write(f"Selected channel: {channel}")

    # Plot the first channel
    fig, ax = plt.subplots()
    ax.plot(raw.times, raw[channel][0].T)
    ax.set_xlabel("Time (s)")
    ax.set_ylabel("Amplitude (µV)")
    ax.set_title(f"EEG signal of {channel}")
    st.pyplot(fig)

def read_file(edf_file):
    # To read file as bytes:
    bytes_data = edf_file.getvalue()
    # Open a file named "output.bin" in the current directory in write binary mode
    with open('edf_file.edf', "wb") as f:
        # Write the bytes data to the file
        f.write(bytes_data)
    
    raw = mne.io.read_raw_edf('edf_file.edf')
    st.write(f"Loaded {edf_file.name} with {raw.info['nchan']} channels")
    return raw