This pipeline opens the result of ICAalamelodic.m, lets the user interactively label the components that look like neuronal activity (rather than movement artefacts or noise), sort them by label, plots a final summary for the chosen components, and save the reordered maps and time series.


In [1]:
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
from scipy import io
%matplotlib inline 
import pylab

Open time series


In [2]:
import scipy.io as sio

In [3]:
# from http://stackoverflow.com/questions/3579568/choosing-a-file-in-python-with-simple-dialog
from Tkinter import Tk
from tkFileDialog import askopenfilename

Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
filename = askopenfilename() # show an "Open" dialog box and return the path to the selected file
print(filename)


/media/test7/THDDCGCaMP62/100135/100135Final/100135ss2c500regcdFF20sMpsfkfint101Smith0_4_60ICTSROIThresh3.mat

In [6]:
Ua=sio.loadmat(filename)
Ua


Out[6]:
{'TS': array([[-0.00743861, -0.00764834, -0.00519925, ..., -0.02341056,
         -0.0031251 , -0.00293629],
        [-0.0097701 , -0.00993989, -0.00677191, ..., -0.01301194,
         -0.00497266, -0.00037263],
        [-0.00997436, -0.01031365, -0.00786917, ..., -0.00869405,
         -0.0050254 , -0.00326958],
        ..., 
        [-0.00075379,  0.0002038 ,  0.00035841, ..., -0.00698567,
         -0.00280472, -0.00050798],
        [ 0.0001505 ,  0.00031476,  0.00032692, ..., -0.00853232,
         -0.00029262, -0.00316693],
        [ 0.00011005,  0.00023015,  0.00023904, ..., -0.00623869,
         -0.00021396, -0.0023156 ]]),
 '__globals__': [],
 '__header__': 'MATLAB 5.0 MAT-file, Platform: GLNXA64, Created on: Tue Aug 21 23:34:49 2018',
 '__version__': '1.0'}

In [7]:
DT=Ua['TS']

In [8]:
DT.shape


Out[8]:
(10183, 101)

In [9]:
S1=DT.shape

In [10]:
DTmean=np.zeros(S1)
DTvar=np.zeros(S1)
Var=np.zeros(S1[1])

In [11]:
for i in range(S1[1]):
    DTmean[:,i]=DT[:,i]-np.mean(DT[:,i],0)

In [12]:
for i in range(S1[1]):
    Var[i]=np.sqrt(np.var(DTmean[:,i]))
    DTvar[:,i]=DTmean[:,i]/Var[i]

In [13]:
DTvar.shape


Out[13]:
(10183, 101)

open maps


In [14]:
import nibabel as nb

In [15]:
# from http://stackoverflow.com/questions/3579568/choosing-a-file-in-python-with-simple-dialog
from Tkinter import Tk
from tkFileDialog import askopenfilename

Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
filename2 = askopenfilename() # show an "Open" dialog box and return the path to the selected file
print(filename2)


/media/test7/THDDCGCaMP62/100135/100135Final/100135ss2c500regcdFF20sMpsfkfint101Smith0_4_60IC.nii

In [16]:
img1 = nb.load(filename2)

In [17]:
data = img1.get_data()

In [18]:
S=data.shape

In [19]:
S


Out[19]:
(137, 87, 7, 101)

Zscore maps


In [20]:
Demean=np.zeros(S)
Dmaps=np.zeros(S)
Dvar=np.zeros(S)
Var=np.zeros(S[3])
D2=np.zeros([S[0],S[1],5,S[3]])
Tvar=np.zeros(S[3])

Transform the maps to have zero mean


In [21]:
for i in range(S[3]):
    Demean[:,:,:,i]=data[:,:,:,i]-np.mean(np.mean(np.mean(data[:,:,:,i],0),0),0)

Transform the maps to have unit variance and zscore


In [22]:
for i in range(S[3]):
    Dsq=np.reshape(Demean[:,:,:,i],S[0]*S[1]*S[2])
    Var[i]=np.sqrt(np.var(Dsq))
    Dvar=Demean[:,:,:,i]/Var[i]
    Dmaps[:,:,:,i]=Dvar-2.5
Dmaps[Dmaps<0]=0

Order ICs by variance


In [23]:
datao=data
Dmapso=Dmaps

In [24]:
plt.plot(Var)


Out[24]:
[<matplotlib.lines.Line2D at 0x7f923e9adbd0>]

Separate maps in substacks, sort the independent components by brain regions


In [25]:
my_cmap=plt.cm.jet
my_cmap.set_bad(alpha=0)
Good_ICs=np.zeros(S[3])
Label_ICs=[]
pylab.rcParams['figure.figsize'] = (13, 2.5)

In [26]:
Dtemp=data[:,:,:,0]

In [27]:
%%javascript
IPython.OutputArea.auto_scroll_threshold =4000;



In [28]:
if S[2]>5:
    Nstack=5
    Int100=[(i+1)*100/Nstack for i in range(Nstack)]
    Percs=np.percentile(range(S[2]),Int100)
    Indices=np.split(range(S[2]),Percs)
    D1=np.zeros([S[0],S[1],Nstack])
    Dmean=Dtemp[:,:,range(Nstack)]
    for i in range(Nstack):
        Vmean=np.mean(Dtemp[:,:,Indices[i]],2)
        #Dmean[:,:,i]=np.max(Vmean,0)
        Dmean[:,:,i]=Vmean
else:
    Nstack=S[2]
    D1=np.zeros([S[0],S[1],S[2]])
    Dmean=data[:,:,range(S[2])]  
    Dmean=np.squeeze(Dtemp[:,:,:])


/usr/local/lib/python2.7/dist-packages/numpy/lib/shape_base.py:422: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  sub_arys.append(_nx.swapaxes(sary[st:end], axis, 0))

In [29]:
DTvar.shape


Out[29]:
(10183, 101)

In [30]:
S


Out[30]:
(137, 87, 7, 101)

In [31]:
# from http://stackoverflow.com/questions/3579568/choosing-a-file-in-python-with-simple-dialog
Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
filename = askopenfilename() # show an "Open" dialog box and return the path to the selected file
print(filename)


/media/test7/THDDCGCaMP62/100135/100135Final/100135Xk.mat

In [32]:
Ua=sio.loadmat(filename)
Xk=Ua['Xk']
#Xk[1,:]=Ua['Walk']

In [33]:
Xk.shape


Out[33]:
(10183, 6)

In [35]:
# from http://stackoverflow.com/questions/3579568/choosing-a-file-in-python-with-simple-dialog
from Tkinter import Tk
from tkFileDialog import askopenfilename

Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
filenamet = askopenfilename() # show an "Open" dialog box and return the path to the selected file
print(filenamet)
nimt=nb.load(filenamet)
Dtemp=np.squeeze(nimt.get_data())
Dtemp.shape


if S[2]>5:
    Nstack=5
    Int100=[(i+1)*100/Nstack for i in range(Nstack)]
    Percs=np.percentile(range(S[2]),Int100)
    Indices=np.split(range(S[2]),Percs)
    Dmean=np.zeros([S[0],S[1],Nstack])
    #Dmean=np.squeeze(data[:,:,range(Nstack),2])
    for i in range(Nstack):
        Vmean=np.mean(Dtemp[:,:,Indices[i]],2)
        Dmean[:,:,i]=Vmean

plt.imshow(Vmean,cmap=plt.cm.gray)


/media/test7/THDDCGCaMP62/100135/100135Final/MAX_100135ss2c500regcdFF20sMpsfkfint101Smith0_4_60ICthresh3std.nii
Out[35]:
<matplotlib.image.AxesImage at 0x7f9232745390>

In [36]:
Xk=Xk.T

In [38]:
Xksmoothed=np.zeros(Xk.shape)

for i in range(Xk.shape[1]):
    Xksmoothed[:,i]=np.mean(Xk[:,max(0,i-999):min(Xk.shape[1],i+1000)],1)


Xkdff=Xk-Xksmoothed

plt.plot(Xksmoothed.T)
plt.show()

plt.plot(Xkdff.T)
TimeCCMax=np.zeros(S[3])



In [63]:
Label_ICs=[]

In [64]:
for j in range(S[3]):

    if S[2]>5:
        for i in range(Nstack):
            V=Dmaps[:,:,Indices[i],j]
            D1[:,:,i]=np.max(V,2)
        D2[:,:,:,j]=D1
        D1[D1==0]=np.nan
           
    else:
        for i in range(S[2]):
            V=Dmaps[:,:,i,j]
            D1[:,:,i]=V 
            

    print(j)
    for i in range(Nstack):
        plt.subplot(1,5,i+1)
        plt.imshow(Dmean[:,:,i],cmap=plt.cm.gray)
        plt.imshow(D1[:,:,i], cmap=my_cmap,interpolation='none')
        frame1 = plt.gca()
        frame1.axes.get_xaxis().set_visible(False)
        frame1.axes.get_yaxis().set_visible(False)
        
    plt.show()
    
   # plt.plot(TS_ROI[Order[j],:])
    plt.plot(DTvar[:,j])
    plt.plot(Xkdff[0,:]/np.std(Xkdff[0,:]),color=(1,0,0))  
    plt.plot(Xkdff[1,:]/np.std(Xkdff[1,:]),color=(1,0,0))  
    plt.plot(Xkdff[2,:]/np.std(Xkdff[2,:]),color=(1,0,0))  
  
    #plt.plot(Xk[3,:]/np.std(Xk[1,:])+0.5,color=(0,0.5,1))
    CCry=np.correlate(DTvar[:,j],Xkdff[0,:]+Xkdff[1,:]+Xkdff[2,:],'full')
    TimeCCMax[j]=((np.argmax(CCry[DTvar.shape[0]-400:DTvar.shape[0]+400]))-400)/100.0
    print(((np.argmax(CCry[DTvar.shape[0]-400:DTvar.shape[0]+400]))-400)/100.0)
    plt.show()
    plt.plot(CCry[DTvar.shape[0]-400:DTvar.shape[0]+400])   
    plt.show()

    
    Label_ICs.append(raw_input())
    if Label_ICs[j]=='':
        Good_ICs[j]=0
    else:
        Good_ICs[j]=1


0
-0.02
a
1
-0.04
a
2
0.02
a
3
0.02
a
4
0.0
a
5
-0.58
6
0.04
a
7
-0.01
a
8
0.05
a
9
-0.06
10
0.07
a
11
-2.12
12
-2.6
13
0.0
14
-0.13
15
-0.04
16
-0.02
17
0.05
a
18
0.01
19
-0.04
20
0.01
21
-0.02
22
-0.02
23
-0.02
24
-0.01
25
-0.01
26
0.04
27
-0.01
28
-3.04
29
0.0
30
0.0
31
0.0
32
0.05
33
0.06
34
0.06
35
-0.05
36
0.07
37
-0.04
38
0.01
39
-0.02
40
0.15
41
-0.01
42
0.04
43
-0.01
44
-0.02
45
0.04
a
46
0.68
a
47
-0.02
a
48
0.05
49
0.05
50
0.1
51
-0.01
52
0.0
53
-0.04
54
-1.01
a
55
0.0
56
-0.02
57
0.05
58
-0.01
59
-0.06
60
0.46
61
-1.1
a
62
0.01
63
-0.03
64
0.02
65
0.11
a
66
0.05
a
67
0.01
a
68
0.0
69
0.0
70
-0.04
71
0.02
72
0.04
73
-0.87
74
0.0
75
-0.06
76
-2.01
77
0.04
a
78
-0.01
79
-3.98
80
0.67
a
81
0.03
82
-0.02
83
0.0
84
-0.05
85
0.02
86
0.01
a
87
-0.04
88
0.03
89
-0.07
90
-1.08
91
1.08
92
3.91
93
0.02
94
0.05
95
3.67
96
-0.04
97
0.03
98
-0.01
99
-0.05
100
0.05


In [36]:
#zip(range(S[3]),Label_ICs)

In [69]:
if S[2]>5:
    Final_map=np.zeros([S[0],S[1],5,3])
    Fmaps=np.zeros([S[0],S[1],5,3])
else:
    Final_map=np.zeros([S[0],S[1],3]) 
    Fmaps=np.zeros([S[0],S[1],3])    
C=np.zeros([S[3],3])
C1=np.zeros([6,3])
C1[0][:]=(1,0,0)
C1[1][:]=(0,1,0)
C1[2][:]=(0,0,1)
C1[3][:]=(0.8,0.8,0)
C1[4][:]=(0,1,1)
C1[5][:]=(1,0,1)
S1=DT.shape

C=np.zeros((S[3],3))
i=1
l=0



for j in range(S[3]):  
    if Label_ICs[j]=='a' and TimeCCMax[j]>0 and TimeCCMax[j]<0.3:
    #if 1>0.1:
        #C[j,:]=C1[i%6][:]
        C[j,0]=10*TimeCCMax[j]
        C[j,1]=1-10*TimeCCMax[j]

        #C[j,2]=1
        for k in range(3):           
            M=np.max(np.squeeze(np.reshape(D2[:,:,:,j],S[0]*S[1]*5)))
            Fmaps[:,:,:,k]=0.5*D2[:,:,:,j]*C[j,k]/M
        Final_map=Final_map+Fmaps
        #Betas2[1,j]=0
        #print(Indexo[j])
        i=i+1
        l=l+1
        #print(j+1)
        #print(C[j,:])
        #if l==2:
         #   break

for j in range(S[3]):  

    if Label_ICs[j]=='a' and TimeCCMax[j]<0 and TimeCCMax[j]>-0.3:
    #if 1>0.1:
        #C[j,:]=C1[i%6][:]
        #print(j+1)
        C[j,2]=-6*TimeCCMax[j]
        C[j,1]=1+6*TimeCCMax[j]
        #C[j,2]=1
        for k in range(3):           
            M=np.max(np.squeeze(np.reshape(D2[:,:,:,j],S[0]*S[1]*5)))
            Fmaps[:,:,:,k]=0.5*D2[:,:,:,j]*C[j,k]/M
        Final_map=Final_map+Fmaps
        #Betas[0,j]=0
        #print(Indexo[j])
        i=i+1
        l=l+1
        #print(j+1)
        #print(C[j,:])
        #if l==2:
            #break
    

C=np.zeros((S[3],3))
i=1
l=0            
            
pylab.rcParams['figure.figsize'] = (15, 6)
C2=np.zeros(3)

Df=np.zeros([S[0],S[1],5,3]) 
  
for i in range(3):
    Df[:,:,:,i]=Final_map[:,:,:,i]+Dmean/70
    #Df=Df/(np.max(np.max(np.max(Df),3)))
if S[2]>5:
    N=Nstack
else:
    N=S[2]
for i in range(N):
    #if Good_ICs[j]:
        plt.subplot(1,N,i+1)
        plt.imshow(Df[:,:,i],cmap=plt.cm.gray)
        plt.imshow(Df[:,:,i,:],cmap=my_cmap,interpolation='none')
        frame1 = plt.gca()
        frame1.axes.get_xaxis().set_visible(False)
        frame1.axes.get_yaxis().set_visible(False)
plt.tight_layout(pad=0,w_pad=0,h_pad=0)



In [37]:
set(Label_ICs)


Out[37]:
{'', 'alpha', 'gamma'}

In [38]:
#Label_ICs[94]='M'

In [ ]:


In [41]:
Xk=Xk.T

In [51]:
Xk.shape


Out[51]:
(6, 10183)

In [50]:
Xksmoothed=np.zeros(Xk[range(3),:].shape)

Xksmoothed[0,:]=np.convolve(Xk[0,999:Xk.shape[1]-1000],np.ones(2000)/2000)

Xksmoothed[1,:]=np.convolve(Xk[1,999:Xk.shape[1]-1000],np.ones(2000)/2000)

Xksmoothed[2,:]=np.convolve(Xk[2,999:Xk.shape[1]-1000],np.ones(2000)/2000)

Xkdff=Xk[range(3),:]-Xksmoothed

In [53]:
Rsq=np.zeros((1,S[3]))
Betas=np.zeros((3,S[3]))

In [54]:
from sklearn import linear_model

In [55]:
algorithm = linear_model.LinearRegression()

In [56]:
for j in range(S[3]):
    model = algorithm.fit(Xkdff.T, DT[:,j])
    Betas[:,j] = model.coef_
    Rsq[:,j] = model.score(Xkdff.T,DT[:,j])

In [57]:
max(max(Rsq))


Out[57]:
0.55541010730021101

In [58]:
List1=[(Label_ICs[i],i) for i in range(S[3])]
Newlist=sorted(List1, key=lambda List1: List1[0])

Neworder=[Newlist[i][1] for i in range(S[3])]

NewDT=DTvar[:,Neworder[:]].T

for j in range(len(Neworder)):
    A=NewDT[:,j]
    V=np.sqrt(np.var(A))
    NewDT[:,j]=A/V

C1=np.zeros([16,3])
C1[0][:]=(1,0,0)
C1[1][:]=(0,1,0)
C1[2][:]=(0,0,1)
C1[3][:]=(0.8,0.8,0)
C1[4][:]=(0,1,1)
C1[5][:]=(1,0,1)
C1[6][:]=(1,0.5,0)
C1[7][:]=(0,1,0.5)
C1[8][:]=(0.5,0,1)
C1[9][:]=(0.8,0.8,0.5)
C1[10][:]=(0.5,1,1)
C1[11][:]=(1,0.5,1)
C1[12]=(0.5,0.5,0.5)
C1[13]=(0.2,0.5,0.5)
C1[14]=(0.5,0.2,0.5)
C1[15]=(0.5,0.5,0.2)
h=3

Newmaps=Dmaps[:,:,:,Neworder[:]]

L=len(set([Label_ICs[Neworder[i]] for i in range(len(Neworder))]))

Regionmaps=np.zeros([S[0],S[1],L,3])
Datasort=np.zeros([S[0],S[1],S[2],L,3])

Regionname=[]

DMapsordered=Dmapso[:,:,:,Neworder[:]]

j=0
i=0
k=Label_ICs[Neworder[0]]
m=0
Regionname.append(Label_ICs[Neworder[i]])
for i in range(len(Neworder)):
    
    #C2=C1[i%6][:]
    for l in range(3):
        M=np.max(np.squeeze(np.reshape(Newmaps[:,:,:,i],S[0]*S[1]*S[2])))
        Regionmaps[:,:,j,l]=Regionmaps[:,:,j,l]+0.6*np.max(DMapsordered[:,:,:,i],2)*C1[i%12+1][l]/M
        Datasort[:,:,:,j,l]=Datasort[:,:,:,j,l]+Dmaps[:,:,:,Neworder[i]]*C1[i%15+1][l] 
    i=i+1
    m=m+1
    if i<len(Neworder):
        k1=Label_ICs[Neworder[i]]
        
        
    if k1 != k:
        j=j+1
        k=k1
        m=0
        Regionname.append(Label_ICs[Neworder[i]])

pylab.rcParams['figure.figsize'] = (14, 5)
import scipy
from scipy import ndimage
j=0
m=0
L=0
k=Label_ICs[Neworder[0]]
for i in range(len(Neworder)):
    m=m+1
    
    
    if i<len(Neworder):
        k1=Label_ICs[Neworder[i]]
        
    if k1 != k:
        
        k=k1
        m=0
        
        plt.show()
        plt.figure(2*j+1)
        Rotated_Plot = ndimage.rotate(Regionmaps[:,:,j], -90)
        IM=plt.imshow(Rotated_Plot) 
        frame1 = plt.gca()
        frame1.axes.get_xaxis().set_visible(False)
        frame1.axes.get_yaxis().set_visible(False)
        j=j+1
        plt.figure(2*j)
        plt.plot(Xk[0,:]/np.std(Xk[0,:])+0.5,color=(1,0,0))   
        plt.plot(Xk[1,:]/np.std(Xk[1,:])+0.5,color=(0,1,0))
        plt.plot(Xk[2,:]/np.std(Xk[1,:])+0.5,color=(0.5,0.5,0))    
        #plt.plot(Xk[3,:]/np.std(Xk[1,:])+0.5,color=(0,0.5,1))
    plt.plot(NewDT[i,:]+h*m,color=C1[i%12+1][:])
    print(Neworder[i])
    print(Rsq[:,Neworder[i]])
    print(Betas[:,Neworder[i]])
plt.figure(2*j+1)
Rotated_Plot = ndimage.rotate(Regionmaps[:,:,j], -90)
IM=plt.imshow(Rotated_Plot)
frame1 = plt.gca()
frame1.axes.get_xaxis().set_visible(False)
frame1.axes.get_yaxis().set_visible(False)
print(Neworder)


0
[ 0.54531931]
[  6.95828047e-06  -6.16112639e-06   8.83361800e-06]
1
[ 0.5201476]
[  3.01826532e-06  -1.77070968e-06   3.55176246e-06]
2
[ 0.45507086]
[ -7.76541047e-06   2.80489274e-06  -5.50631727e-06]
3
[ 0.43376014]
[  5.71641031e-06  -1.29930074e-05   2.74582537e-05]
4
[ 0.40702922]
[  2.65359475e-07  -1.29401168e-06   3.06267135e-06]
5
[ 0.40633365]
[  9.01829313e-07  -1.67965468e-06   4.94087973e-06]
6
[ 0.38484897]
[  1.99412679e-06  -2.34825491e-06   6.01039067e-06]
7
[ 0.40338953]
[  3.14137152e-07  -9.22026737e-07   1.90921228e-06]
8
[ 0.5215179]
[  1.45592733e-06  -9.38010496e-07   1.70570162e-06]
9
[ 0.42283721]
[  7.10783523e-07  -6.26855113e-07   1.44939928e-06]
10
[ 0.37717416]
[  5.48239328e-07  -1.50845345e-06   3.89915759e-06]
11
[ 0.31623718]
[ -4.69656735e-06   2.12947080e-06  -1.70272927e-06]
13
[ 0.36646519]
[  6.10295046e-06  -1.34724650e-05   3.67483486e-05]
14
[ 0.35191608]
[  2.72339909e-07  -2.75744173e-06   4.72042756e-06]
15
[ 0.55541011]
[  1.61481328e-06  -6.54556166e-07   6.44618404e-07]
16
[ 0.49092185]
[  2.14638630e-06  -1.09662742e-06   1.87455032e-06]
17
[ 0.42423344]
[  1.19205982e-06  -1.87094612e-06   4.38816970e-06]
18
[ 0.31186598]
[  2.10962361e-07  -3.93430291e-07   1.34297486e-06]
19
[ 0.33765819]
[  1.58613203e-06  -1.13519183e-05   2.85196147e-05]
20
[ 0.45046182]
[  1.58783571e-06  -1.09228916e-06   1.53489934e-06]
21
[ 0.44244307]
[  6.32066671e-06  -9.42407620e-06   1.85619978e-05]
22
[ 0.3473132]
[  3.75412023e-06  -1.07680706e-05   3.08256273e-05]
23
[ 0.3522547]
[  2.49843680e-07  -1.75548245e-06   3.83906186e-06]
24
[ 0.32053049]
[ -5.79887057e-05   1.67735621e-04  -4.89854823e-04]
26
[ 0.39686336]
[  1.05300001e-06  -2.25465653e-06   4.78233300e-06]
27
[ 0.43487744]
[  6.63814219e-07  -5.57020268e-07   1.28429719e-06]
28
[ 0.37908474]
[  1.04160193e-06  -9.87513865e-07   2.54927005e-06]
29
[ 0.25513302]
[  2.08291673e-07  -3.08479072e-07   7.87258085e-07]
30
[ 0.45519024]
[ -1.10200983e-06   1.08623896e-06  -2.05342890e-06]
31
[ 0.33953096]
[  2.25544610e-07  -1.73737748e-06   4.40604198e-06]
32
[ 0.37239247]
[  1.33609502e-06  -1.92679380e-06   4.99665695e-06]
33
[ 0.42815358]
[  1.04242137e-06  -9.13824406e-07   2.07987725e-06]
34
[ 0.33900589]
[  3.49411293e-07  -1.09132259e-06   3.01253530e-06]
36
[ 0.03918728]
[  1.11123331e-07  -2.12252364e-07   4.39756823e-07]
37
[ 0.44542479]
[  2.99718547e-07  -3.84941197e-07   7.15512751e-07]
38
[ 0.39629265]
[  6.25097265e-07  -5.09334286e-07   1.00606988e-06]
39
[ 0.36108459]
[  2.16407869e-07  -3.25678008e-07   5.93958361e-07]
41
[ 0.4594244]
[  5.44462266e-07  -3.32352615e-07   3.75191481e-07]
42
[ 0.31683527]
[  3.19904436e-07  -4.22875138e-07   9.07653658e-07]
43
[ 0.32771965]
[  2.52716561e-07  -2.00739856e-07   5.23294407e-07]
45
[ 0.27379642]
[  5.54371390e-07  -3.13097284e-07   9.04343459e-07]
46
[ 0.26725108]
[  2.62306126e-07  -3.16722111e-07   8.24188201e-07]
48
[ 0.36678462]
[  3.53954410e-07  -3.42736771e-07   6.63611114e-07]
49
[ 0.39597206]
[  6.71144167e-07  -3.54345914e-07   6.30777113e-07]
50
[ 0.45513184]
[  9.72534351e-07  -9.99089482e-07   1.95130901e-06]
51
[ 0.14718788]
[  4.98442833e-07  -1.89000689e-06   3.13085282e-06]
52
[ 0.27628728]
[ -5.30902445e-07  -1.86793514e-06   4.67230608e-06]
53
[ 0.36330776]
[  5.04572418e-07  -7.98786690e-07   1.69000636e-06]
54
[ 0.35062943]
[ -6.66032840e-07   9.28625122e-07  -2.30055085e-06]
55
[ 0.29433972]
[ -1.09672963e-06   1.46994219e-07  -7.76144375e-07]
56
[ 0.12707324]
[-0.0001062   0.00012694 -0.00022836]
57
[ 0.24093249]
[  2.74134745e-07  -1.04651167e-06   2.63100665e-06]
58
[ 0.34522087]
[  3.36400617e-07  -6.65529871e-07   1.44809225e-06]
59
[ 0.32450372]
[ -5.81066921e-07   1.20237991e-06  -3.05835155e-06]
60
[ 0.3346174]
[  6.81661281e-07  -4.60627472e-07   4.52453474e-07]
61
[ 0.00080721]
[ -4.49045826e-09   8.82802438e-08  -3.60255784e-08]
62
[ 0.26494939]
[  2.42635681e-07  -1.70705054e-07   4.01366807e-07]
63
[ 0.37030083]
[  7.14718478e-07  -9.80878415e-07   2.38222882e-06]
64
[ 0.11958904]
[  2.81524812e-06  -6.56301588e-07   3.83174350e-08]
65
[ 0.25285268]
[  2.73879813e-07  -2.03077776e-07   4.77995374e-07]
66
[ 0.26010437]
[  4.01829982e-07  -2.97395572e-07   6.94300436e-07]
67
[ 0.32315469]
[  3.26370325e-07  -2.51614143e-07   4.05819617e-07]
68
[ 0.04683896]
[ -5.06455755e-06   4.72391570e-06  -5.49007385e-06]
69
[ 0.1140445]
[ -4.13523996e-07   1.63828524e-06  -2.97284179e-06]
70
[ 0.14612517]
[  1.59795730e-07  -1.92760291e-07   8.61993353e-07]
71
[ 0.23783735]
[  1.38744745e-07  -1.98204508e-07   4.18514009e-07]
72
[ 0.217136]
[  4.81565342e-08  -2.90103355e-07   5.11295366e-07]
73
[ 0.14627701]
[  3.75322455e-07  -1.07766751e-08   9.49164240e-09]
74
[ 0.26281348]
[  1.21112237e-06  -2.85590761e-06   7.59310606e-06]
75
[ 0.30667419]
[ -8.18072407e-06   7.55328748e-06  -9.78976387e-06]
76
[ 0.10540086]
[  1.32228890e-07   4.49564356e-08   1.92386131e-08]
77
[ 0.11326103]
[  9.08471054e-09   1.75421391e-07  -4.32921120e-07]
78
[ 0.25697901]
[  2.72007181e-06  -1.95831184e-06   3.57028820e-06]
79
[ 0.04447558]
[ -2.53201615e-08  -1.56891962e-07   3.58622159e-07]
80
[ 0.20485094]
[  1.59324309e-06  -3.50143112e-07   6.28510378e-07]
81
[ 0.02948089]
[  2.11761541e-07   1.37655508e-07  -1.33792823e-08]
82
[ 0.20091747]
[  8.67220035e-07  -1.41265442e-06   2.76158094e-06]
83
[ 0.04720827]
[ -6.46754832e-08   5.18640706e-08  -8.47603167e-08]
12
[ 0.01086138]
[  5.02764685e-07   3.15293637e-07  -1.33874542e-06]
25
[ 0.03430017]
[ -2.86649748e-07   1.54643660e-06  -2.45682203e-06]
35
[ 0.11223422]
[ -1.25524174e-06   1.35088924e-07   2.49924552e-07]
40
[ 0.07992806]
[ -5.90157369e-07   8.48956044e-07  -1.17375291e-06]
44
[ 0.03566925]
[ -6.42669772e-08   6.27238578e-07  -1.46594740e-06]
47
[ 0.12248352]
[ -5.44490194e-07   1.89411693e-07  -2.87476603e-07]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 31, 32, 33, 34, 36, 37, 38, 39, 41, 42, 43, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 12, 25, 35, 40, 44, 47]

In [ ]:
# from http://stackoverflow.com/questions/3579568/choosing-a-file-in-python-with-simple-dialog
Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
filename = askopenfilename() # show an "Open" dialog box and return the path to the selected file
print(filename)

In [ ]:
Ua=sio.loadmat(filename)
Xk=Ua['Xk']

In [ ]:
plt.plot(Xkdff[range(3),:].T)

In [66]:
Label_ICs


Out[66]:
['a',
 'a',
 'a',
 'a',
 'a',
 '',
 'a',
 'a',
 'a',
 '',
 'a',
 '',
 '',
 '',
 '',
 '',
 '',
 'a',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 'a',
 'a',
 'a',
 '',
 '',
 '',
 '',
 '',
 '',
 'a',
 '',
 '',
 '',
 '',
 '',
 '',
 'a',
 '',
 '',
 '',
 'a',
 'a',
 'a',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 'a',
 '',
 '',
 'a',
 '',
 '',
 '',
 '',
 '',
 'a',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '',
 '']

In [ ]: