Stimic - Analysis - Stim count

jeu. 08 novembre 2018 by Martin Deudon

Download the notebook : stimic_stim_count.py

Count Stim

This notebook show how to count the number of stimulations in function of the different stimulation paremeters from the Stimulation Event File

In [1]:
%matplotlib inline
import matplotlib
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_context('paper')
sns.set()
import re
In [2]:
stim_spreadsheet_path = r'..\data\p42_KR01_stimulations_all.xlsx'
patient_id = 'KR01'

Read the Excel sheet with pandas

In [3]:
pd.set_option('display.width', 500)
df = pd.read_excel(stim_spreadsheet_path)
df.style.set_properties(**{'font-size':'5'})
df.head()
Out[3]:
ID file type time channelind channelname freq intensity duration effect channelname_bipolar time-micro channelname-micro channelind-micro filepath-micro
0 P42_KR01 KR01_stim1_clean_clean_raw Stim 1 Hz 174.4736 96 EEG GC1 1 1.5 10 RAS EEG GC1-EEG GC2 217.1523 [] [] path\to\file
1 P42_KR01 KR01_stim1_clean_clean_raw Stim 1 Hz 174.4834 97 EEG GC2 1 1.5 10 RAS EEG GC1-EEG GC2 217.1621 [] [] path\to\file
2 P42_KR01 KR01_stim1_clean_clean_raw Stim 1 Hz 234.5498 97 EEG GC2 1 2.0 10 RAS EEG GC2-EEG GC3 277.2285 [] [] path\to\file
3 P42_KR01 KR01_stim1_clean_clean_raw Stim 1 Hz 234.5566 98 EEG GC3 1 2.0 10 RAS EEG GC2-EEG GC3 277.2353 [] [] path\to\file
4 P42_KR01 KR01_stim1_clean_clean_raw Stim 1 Hz 274.1533 98 EEG GC3 1 3.0 20 RAS EEG GC3-EEG GC4 316.8320 [] [] path\to\file

Plot the number of stimulation in function of the frequency, intensity and channel :

In [4]:
f = plt.figure(figsize=(16, 12))
ax1 = f.add_subplot(131)
sns.countplot(df['freq'], ax=ax1)
ax2 = f.add_subplot(132)
sns.countplot(df['intensity'], ax=ax2)
ax2.set(title=patient_id)
ax3 = f.add_subplot(133)
sns.countplot(y='channelname', data=df, orient='h', ax=ax3)
Out[4]:
<matplotlib.axes._subplots.AxesSubplot at 0xb0de668>

Another way to count the stimulations, in function of the channel and frequency :

In [5]:
f = plt.figure(figsize=(13, 13))
ax = f.add_subplot(111)
ax.set(title=patient_id)
sns.countplot(y='channelname_bipolar', hue='freq', data=df, orient='h', ax=ax)
Out[5]:
<matplotlib.axes._subplots.AxesSubplot at 0xb1b06a0>