Python EEG Analysis Example - PowerPoint PPT Presentation

lei
python eeg analysis example n.
Skip this Video
Loading SlideShow in 5 Seconds..
Python EEG Analysis Example PowerPoint Presentation
Download Presentation
Python EEG Analysis Example

play fullscreen
1 / 11
Download Presentation
Python EEG Analysis Example
168 Views
Download Presentation

Python EEG Analysis Example

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. PythonEEG Analysis Example From Think Python How to Think Like a Computer Scientist

  2. EEG Data Collection

  3. Their Test Bench

  4. Generates a CSV FileLooks like the following in Excel Channels sample number

  5. Looking at it in Notepad++

  6. Suppose we just want channel 2 and none of the other data. We will use Python to extract that column only. Once it is extracted we can graph it.

  7. Open the file and read it. • File=open("eegdata.csv",'r') • File.readline(); # Get rid of the first line. • # It contains only header data • for line in File: • print line • # The above should open the file and print it out one line at a time. • # As soon as this works we can then process each line

  8. Remember SPLIT? • If we have a string (or line) that is a CSV string we can split it into pieces and place the result into a list. • Example : str = “34,23,65,77,12” • a = str.split(‘,’) • print a • ['34', '23', '65', '77', '12'] • But these are strings in a list and not numbers. So. • a[2] is ‘65’ . Can we convert this guy to a float? • float(a[2]) is now 65 Capice?!

  9. The Script • File=open("eegdata.csv",'r') • File.readline(); • channel = [] • for line in File: • list=line.split(',') • channel.append(float(list[2])) • print channel • plot (channel[0:128)) # only plot the first 128 samples

  10. What about multiple graphs • File=open("eegdata.csv",'r') • File.readline(); • channel = [] • for line in File: • list=line.split(',') • channel.append(float(list[2])) • print channel • figure(1) • plot(channel[:128]) • figure(2) • plot(channel[128:256])