1 / 11

Python EEG Analysis Example

Python EEG Analysis Example. From Think Python How to Think Like a Computer Scientist. EEG Data Collection. Their Test Bench. Generates a CSV File Looks like the following in Excel. Channels. sample number. Looking at it in Notepad++.

lei
Download Presentation

Python EEG Analysis Example

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

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])

More Related