Ingredients

Libraries

In [22]:
import numpy as np, scipy, matplotlib.pyplot as plt, pandas as pd, seaborn as sns
sns.set(style='whitegrid')
plt.rcParams['figure.figsize'] = (20.0, 10.0)
import IPython.display as ipd
%run detect_peaks.py
plt.rcParams['figure.figsize'] = [10, 5]
%matplotlib inline

Data

In [36]:
data = pd.DataFrame.from_csv('./HackLab_Vol1_Excerpts/HackLab_Vol1_Excerpts/Vol1_P2_1_Exrpt.csv')
data = data.drop('Sample',axis=1)
In [85]:
samples = pd.DataFrame.from_csv('./HackLab_Vol1_Excerpts/HackLab_Vol1_Excerpts/Vol1_P2_1_Exrpt.csv')
samples = samples['Sample']
In [37]:
data.plot(figsize = (16,10))
Out[37]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f8f3fece690>

Preparations

In [26]:
from scipy import signal
In [40]:
sig = data['P1']
In [41]:
len(sig)
Out[41]:
901
In [42]:
f,ax = plt.subplots(5,2,figsize = (32,20), sharex=True)
ax[0,0].plot(data['P1'],color = 'red')
ax[1,0].plot(data['P2'],color = 'orange')
ax[2,0].plot(data['P3'],color = 'yellow')
ax[3,0].plot(data['P4'],color = 'green')
ax[4,0].plot(data['P5'],color = 'brown')
ax[0,1].plot(data['P6'],color = 'blue')
ax[1,1].plot(data['P7'],color = 'grey')
ax[2,1].plot(data['P8'],color = 'purple')
ax[3,1].plot(data['P9'],color = 'black')
Out[42]:
[<matplotlib.lines.Line2D at 0x7f8f3ff89990>]
In [46]:
data.hist(figsize=(16,10))
Out[46]:
array([[<matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3f003c50>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3eff73d0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3efbc110>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3ef4fc50>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3eec9650>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3ee85610>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3ee500d0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3ee1f110>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3eddfb90>]],
      dtype=object)
In [63]:
from pandas.plotting import scatter_matrix
scatter_matrix(data, alpha=0.2, figsize=(16, 16), diagonal='kde')
Out[63]:
array([[<matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3ca17f10>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3ceeb790>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c9a9ad0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c80ae10>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c87d750>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c971690>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c93b150>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c885190>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c7c7c10>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c8e3c10>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3d5109d0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3da5fc50>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c7440d0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c70d190>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c73e590>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c68d050>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c6a96d0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c61b590>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c697dd0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c5a2290>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c56e2d0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c539390>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c4fae10>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c4b8550>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c4614d0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c3c7b10>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c3965d0>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c34fa10>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c37a510>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c2dffd0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c2aba90>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c288410>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c232890>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c1832d0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c142d50>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c10ed90>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c0ccad0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c098510>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c056f90>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3c022fd0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f37fdcb90>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f37faf5d0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f37f7d090>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f37ecb0d0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f37ed43d0>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0x7f8f37e47890>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f37e12350>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f37ddf390>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f37d9ed90>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f37d5b9d0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f37d2c410>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f37cca3d0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f37cba7d0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f37cca5d0>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0x7f8f37bc27d0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f37b90290>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f37b50c10>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f37b1dcd0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f37ad9a10>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f37aa64d0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f37a64ed0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f37a32f90>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f379e9ad0>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0x7f8f379bd510>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3797bf90>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f378c8fd0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f378e2210>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f378557d0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f37822190>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f37822e10>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f377b1650>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3776ba10>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0x7f8f377374d0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f37685490>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f37648f10>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f376ec390>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f375cd710>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3759e0d0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f3755eb50>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f37529b10>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f8f374e5ad0>]],
      dtype=object)
In [66]:
emgdesc1
Out[66]:
P1 P2 P3 P4 P5 P6 P7 P8 P9
count 901.000000 901.000000 901.000000 901.000000 901.000000 901.000000 901.000000 901.000000 901.000000
mean 19.605993 3.872919 6.068313 5.182364 54.426526 0.782675 2.198613 16.472829 10.629956
std 6.151543 0.139780 3.986588 2.339354 0.191358 0.663637 3.443335 25.871947 0.328572
min 14.000000 3.490000 2.450000 3.770000 53.800000 0.485000 1.080000 0.404000 9.990000
25% 17.700000 3.790000 3.570000 4.200000 54.300000 0.558000 1.390000 1.130000 10.600000
50% 19.200000 3.860000 4.220000 4.340000 54.400000 0.583000 1.520000 2.860000 10.600000
75% 20.800000 3.930000 7.310000 4.670000 54.500000 0.707000 1.690000 17.700000 10.600000
max 141.000000 5.280000 32.100000 24.300000 55.100000 8.250000 45.800000 96.200000 17.100000
In [74]:
data.describe()
desc=data.describe()
desc = desc.drop('count')
In [75]:
desc.plot(figsize=(16,10))
Out[75]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f8f35ee1810>
In [77]:
import seaborn as sns
sns.set_style("whitegrid")             


paper_rc = {'lines.linewidth': 1, 'lines.markersize': 10}     
fig,ax =plt.subplots(figsize=(16, 10))
ax = sns.violinplot(x=desc,
                     split = True,inner="stick",scale="count",bw=.3,palette="RdBu", color_codes=True)
plt.xlabel('Participant',fontsize='32')
plt.ylabel('Profile',fontsize = '28')
# plt.setp(ax.get_legend().get_texts(), fontsize='28') # for legend text
# plt.setp(ax.get_legend().get_title(), fontsize='2') # for legend title
Out[77]:
Text(0,0.5,u'Profile')
In [93]:
sns.jointplot(data['P1'], data['P2'], color="g")
Out[93]:
<seaborn.axisgrid.JointGrid at 0x7f8f3135f110>
In [95]:
data['P1']
Out[95]:
[<matplotlib.lines.Line2D at 0x7f8f32111650>]
In [102]:
%run smooth.py
<matplotlib.figure.Figure at 0x7f8f32262b10>