Saturday, November 04, 2017

3D Rotative Graph from a CSV file using Python

There are several modules in Python to create different types of graphs. "The Python Graph Gallery" brings together several examples, as rotating 3D chart, created from a data file in CSV format. The next code, from Yan Holtz, save 70 PNG images in the "filename" folder. Then you just need to convert them to GIF format using, for example, gifmaker.meThis code can easily be adapted to read EEG data files.

# library
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns

# Get the data (csv file is hosted on the web)
url = 'https://python-graph-gallery.com/wp-content/uploads/volcano.csv'
data = pd.read_csv(url)

# Transform it to a long format
df=data.unstack().reset_index()
df.columns=["X","Y","Z"]

# And transform the old column name in something numeric
df['X']=pd.Categorical(df['X'])
df['X']=df['X'].cat.codes

# We are going to do 20 plots, for 20 different angles
for angle in range(70,210,2):

   # Make the plot
   fig = plt.figure()
   ax = fig.gca(projection='3d')
   ax.plot_trisurf(df['Y'], df['X'], df['Z'], cmap=plt.cm.viridis, linewidth=0.2)

   # Set the angle of the camera
   ax.view_init(30,angle)

   # Save it
   filename='PNG/ANIMATION/Volcano_step'+str(angle)+'.png'
   plt.savefig(filename, dpi=96)
   plt.gca()

For more information about BCI/EEG press here.


Friday, November 03, 2017

Brain-Computer Interface online free course

Christian Kothe, from SCCN/UCSD, presents an online course on BCI designed with a focus on modern methods. It includes basics of EEG, BCI, signal processing, machine learning, and also contains tutorials on using BCILAB and the lab streaming layer software. Although it was published in 2012 it maintains several BCI principles.


For more information about BCI/EEG press here.