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/sophie/New Volume/100621ss2series/100621ss2oncregcdFF20spsfkfconcatMB116Smith0_4_60TS.mat

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

In [8]:
DT=Ua['TSmean']

In [9]:
DT.shape


Out[9]:
(10497, 116)

In [10]:
S1=DT.shape

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

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

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

In [14]:
DTvar.shape


Out[14]:
(10497, 116)

open maps


In [15]:
import nibabel as nb

In [16]:
# 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/sophie/New Volume/100621ss2series/100621ss2oncregcdFF20spsfkfconcatMB116Smith0_4_60IC.nii

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

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

In [19]:
S=data.shape

In [20]:
S


Out[20]:
(78, 43, 9, 116)

Zscore maps


In [21]:
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 [22]:
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 [23]:
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 [24]:
datao=data
Dmapso=Dmaps

In [25]:
plt.plot(Var)


Out[25]:
[<matplotlib.lines.Line2D at 0x7fe40d1c1810>]

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


In [26]:
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 [27]:
Dtemp=data[:,:,:,0]

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



In [29]:
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 [30]:
DTvar.shape


Out[30]:
(10497, 116)

In [31]:
S


Out[31]:
(78, 43, 9, 116)

In [32]:
# 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/sophie/New Volume/100621ss2series/MAX_100621ss2oncregcdFF20spsfkfconcatMB116Smith0_4_60IC.nii

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/sophie/New Volume/100621ss2series/MAX_100621ss2oncregcdFF20spsfkfconcatMB116Smith0_4_60IC.nii
Out[35]:
<matplotlib.image.AxesImage at 0x7fe408d1f310>

In [ ]:
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,:])+0.5,color=(1,0,0))   
    plt.plot(Xkdff[1,:]/np.std(Xkdff[1,:])+0.5,color=(0,1,0))
    plt.plot(Xkdff[2,:]/np.std(Xkdff[2,:])+0.5,color=(0.5,0.5,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')
    
    plt.show()
    plt.plot(CCry-3)   
    plt.show()
    print(np.argmax(CCry))
    Label_ICs.append(raw_input())
    if Label_ICs[j]=='':
        Good_ICs[j]=0
    else:
        Good_ICs[j]=1


0
11073

In [46]:
#Label_ICs[91]='gamma'

In [38]:
# 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/sophie/New Volume/100621ss2series/100621ss2seriesXk.mat

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

In [40]:
Xksmoothed=np.zeros(Xk.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-Xksmoothed

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

In [42]:
from sklearn import linear_model

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

In [44]:
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 [45]:
max(max(Rsq))


Out[45]:
0.57662473603742215

In [46]:
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.01728461]
[ 0.00012955 -0.0001038   0.00153739]
1
[ 0.03108548]
[ -4.06104040e-04   9.39896563e-05  -3.30163357e-03]
2
[ 0.02578217]
[ 0.00013532  0.00014846  0.0006384 ]
4
[ 0.01187777]
[ -1.77224522e-05  -6.93210492e-05   4.72891288e-04]
5
[ 0.00685549]
[  2.50742430e-05   6.16408488e-05  -3.92576637e-04]
6
[ 0.09409194]
[  2.20224430e-05   2.82736348e-05   6.99463078e-05]
7
[ 0.02701614]
[  2.23138667e-05   4.54374399e-05   1.79196712e-04]
9
[ 0.05192609]
[ 0.0008331   0.00104758  0.00235151]
10
[ 0.03593022]
[ 0.0010695   0.00097956  0.00839904]
12
[ 0.00726146]
[ -6.48644383e-05  -1.49132257e-04   5.08587144e-04]
13
[ 0.00583527]
[  2.42301032e-05   1.72799235e-05  -3.11152008e-04]
14
[ 0.32894211]
[  1.17295651e-04   9.55522644e-06   2.62589055e-04]
15
[ 0.005617]
[ -2.15000676e-05   5.41799094e-05   1.06602818e-06]
16
[ 0.49526081]
[  6.75425666e-05  -8.23980732e-06   4.01192532e-04]
18
[ 0.01348817]
[ -4.69401528e-05  -2.21328880e-06  -3.74870139e-05]
19
[ 0.48610081]
[ 0.00129934 -0.001297    0.00302275]
20
[ 0.0055361]
[  1.31578629e-05   1.20997577e-05  -1.49546254e-04]
22
[ 0.05512858]
[ 0.00016257  0.00029006  0.0006527 ]
23
[ 0.05412098]
[  2.98692370e-05   3.12171040e-05   1.56929162e-04]
24
[ 0.57662474]
[  7.78105414e-05  -1.08432784e-05   2.94672367e-04]
25
[ 0.12171848]
[  8.55346464e-05   8.30568521e-05   2.50984817e-04]
26
[ 0.01884433]
[ 0.00069978  0.00134469  0.00300735]
27
[ 0.0110386]
[ -3.29243243e-05  -5.35703733e-05  -2.70014497e-05]
29
[ 0.07264996]
[  1.00081829e-04   1.30810474e-04  -3.94490065e-05]
30
[ 0.01115846]
[ -4.11553100e-05  -8.34233001e-05   2.29180479e-05]
31
[ 0.0674741]
[  2.42401559e-05   1.86952548e-05   1.95654069e-04]
32
[ 0.05427378]
[  8.70315798e-05  -8.78623802e-05   6.96487686e-04]
33
[ 0.04955133]
[ -4.52595607e-05  -1.06837060e-04  -4.31241172e-04]
34
[ 0.24094383]
[  3.15256884e-05   8.32135961e-06   1.24988918e-04]
35
[ 0.01833267]
[  4.33058856e-05  -7.73565808e-05   7.48528637e-04]
36
[ 0.15214979]
[  2.62128012e-05   2.11438591e-05   5.50185363e-05]
37
[ 0.16898599]
[-0.00154738 -0.00110956 -0.00441046]
39
[ 0.17661513]
[ -1.25423427e-04  -5.68904445e-05  -4.58267665e-04]
40
[ 0.21931328]
[  1.26562968e-04  -2.64313170e-05   7.01873327e-04]
41
[ 0.05324243]
[  3.80231002e-05   5.97342246e-05   6.59889554e-05]
42
[ 0.11727895]
[  4.47477133e-05   2.91593733e-05   1.71129286e-04]
43
[ 0.29305193]
[  1.70916814e-05  -3.00856427e-06   5.45745095e-05]
45
[ 0.1264332]
[  2.06079843e-04   7.69480041e-05   8.48831071e-04]
47
[ 0.01808549]
[  7.38648210e-05   9.98777889e-06  -1.61683104e-04]
48
[ 0.02247107]
[  1.48125785e-05   4.61170604e-05   2.00207809e-05]
49
[ 0.21558915]
[ -1.68778832e-04  -1.69878256e-05  -4.69743167e-04]
50
[ 0.19933012]
[  8.61695064e-05   5.80457739e-05   1.92346507e-04]
51
[ 0.1640354]
[-0.00024879  0.00015555 -0.0006108 ]
52
[ 0.02151322]
[ -5.11895586e-05   3.89139524e-06  -4.37232425e-04]
53
[ 0.42931139]
[-0.00041486  0.00023168 -0.00167073]
54
[ 0.19501905]
[  1.21715731e-04  -5.27898081e-05   2.64280646e-04]
55
[ 0.02459351]
[  2.29182919e-05   8.07053450e-05  -3.65585087e-04]
56
[ 0.40289594]
[ -7.90097262e-05   2.41579349e-06  -2.67861404e-04]
57
[ 0.00439391]
[ -9.10100691e-05   1.55981115e-05   7.10280886e-04]
58
[ 0.04533458]
[ -1.33476828e-04  -6.93886389e-05  -9.41424159e-04]
59
[ 0.05711403]
[  1.75017672e-04  -2.69633952e-05   3.53596576e-05]
60
[ 0.37417315]
[-0.00012119  0.00010415 -0.00073501]
61
[ 0.36204237]
[  2.55383106e-04  -9.44673989e-05   7.52983099e-04]
62
[ 0.01862319]
[  2.10104621e-04   5.34973261e-06  -3.03795533e-04]
63
[ 0.18460557]
[ -4.56122335e-05   5.75122204e-05  -2.54484607e-04]
64
[ 0.1905853]
[ 0.00037055  0.00028427  0.0019568 ]
65
[ 0.05404968]
[  3.63342751e-05   5.02124445e-05   2.93994336e-05]
67
[ 0.01548555]
[ -1.86158776e-05  -1.25462100e-04   2.96848172e-04]
68
[ 0.02586909]
[ -2.31318605e-05  -8.19409568e-06  -1.24712588e-04]
69
[ 0.45221938]
[  4.23943530e-05  -1.69637800e-05   1.99159489e-04]
70
[ 0.3994859]
[ 0.0001367  -0.00012992  0.00055485]
71
[ 0.33937062]
[  6.47121515e-05  -2.46040868e-05   2.12753033e-04]
72
[ 0.14995983]
[  2.16085521e-05  -1.39429331e-05   1.60175033e-04]
73
[ 0.10799533]
[ -3.78330587e-05  -1.76484633e-05  -1.65503862e-04]
74
[ 0.17459584]
[ -2.90637396e-05  -2.37043479e-06  -1.74981561e-04]
75
[ 0.0140983]
[ -2.48860681e-05  -2.13785668e-06  -1.65071565e-05]
76
[ 0.13297745]
[ 0.00059753  0.00026317  0.00185177]
77
[ 0.05335634]
[ -3.65562655e-05  -6.54397039e-05  -1.11597133e-04]
78
[ 0.04322799]
[ -6.54029809e-05  -1.21650033e-05  -2.09746458e-05]
79
[ 0.00833964]
[  7.76954681e-06  -5.29633679e-05   1.46722044e-04]
80
[ 0.30780771]
[ 0.00044745 -0.00035206  0.0020032 ]
81
[ 0.23974153]
[-0.00031223  0.00018946 -0.00121538]
82
[ 0.06591831]
[ -1.30358649e-05   4.81581846e-06  -1.11755477e-04]
83
[ 0.16863825]
[  5.57840807e-05  -2.16559413e-05   4.70989932e-04]
84
[ 0.02846497]
[-0.04889231  0.0639426  -0.08127728]
85
[ 0.01473005]
[  1.27171986e-05   7.73994947e-05  -2.85487307e-04]
86
[ 0.0013146]
[ -6.79233805e-06  -2.89286821e-06   5.51709255e-05]
88
[ 0.02897467]
[  7.29767876e-05   6.37056181e-05   3.66982660e-04]
89
[ 0.01138618]
[  4.23848864e-06   2.49392508e-05  -7.93518891e-06]
90
[ 0.01588507]
[  7.71874711e-07  -3.19977944e-05  -7.66071671e-05]
91
[ 0.01026939]
[ -6.74199338e-05   4.76632607e-04   5.70046877e-03]
92
[ 0.10228089]
[  1.09418887e-05   1.62980766e-05   7.59019823e-05]
93
[ 0.15055026]
[ -4.00263889e-05   8.46446031e-05  -7.48876495e-04]
94
[ 0.00095164]
[  4.81745085e-05   9.27337165e-05  -2.17356012e-04]
95
[ 0.18140125]
[  5.31522351e-05   2.61696803e-05   1.31271321e-04]
96
[ 0.14696926]
[  3.01519656e-05   1.51507228e-05   1.63261864e-04]
97
[ 0.01269112]
[  6.73077318e-07   5.83202953e-06  -3.13143273e-05]
98
[ 0.05904733]
[ -8.20000287e-06   2.55475871e-06  -4.86191869e-05]
99
[ 0.01072944]
[  2.10172308e-05  -2.90650450e-05  -2.24395663e-04]
100
[ 0.05819721]
[  5.70098282e-05   1.21593256e-05   4.02254890e-04]
101
[ 0.0020784]
[ -1.20014437e-05  -4.31825817e-06   2.42432228e-05]
102
[ 0.06278701]
[ 0.00046151 -0.00023571  0.00602219]
103
[ 0.04559248]
[  1.39707675e-05   1.70395419e-05   1.09362602e-05]
104
[ 0.13828559]
[  6.42975615e-05   2.76874500e-05   5.47635319e-05]
105
[ 0.02735299]
[  1.52761542e-05  -1.25830444e-05  -1.73868921e-04]
106
[ 0.01101776]
[  9.93854944e-06  -1.44128981e-05  -5.87643175e-05]
107
[ 0.01656046]
[ -9.53128901e-05  -5.22200302e-05   2.74816431e-04]
109
[ 0.0102185]
[  1.51285354e-05   1.71963646e-05  -1.01727088e-04]
110
[ 0.00412438]
[  7.73094281e-06  -8.36330187e-06   3.36497630e-05]
111
[ 0.05817742]
[ -1.23897193e-05   1.97330589e-05  -2.56010897e-04]
112
[ 0.13762276]
[ -3.60538792e-05   4.43873642e-05  -3.77577496e-04]
113
[ 0.022986]
[  3.20652463e-06   1.36278758e-06   1.30021683e-04]
114
[ 0.00615727]
[ -4.97270003e-05   8.93204184e-05   3.33396108e-04]
115
[ 0.05675157]
[  2.77924395e-05  -2.49701720e-05   3.56553770e-04]
46
[ 0.00983081]
[  2.78848742e-05   5.54323865e-05  -7.68599190e-05]
87
[ 0.00948979]
[  3.94658496e-06  -8.37955696e-06   2.66872454e-05]
108
[ 0.12275377]
[ -3.38689362e-05   7.29565714e-05  -2.36667417e-04]
3
[ 0.07140619]
[-0.00064051 -0.00023728 -0.00077211]
11
[ 0.11347967]
[ -3.24879102e-04   5.09492026e-05  -8.08345903e-04]
17
[ 0.03189365]
[  2.54782479e-04   9.09038470e-05  -1.70586826e-04]
8
[ 0.17571284]
[  2.62466144e-04   5.00213333e-06   1.77234992e-03]
21
[ 0.2220488]
[-0.0001026  0.0003913 -0.0059829]
28
[ 0.30069035]
[ -1.33694075e-04   7.94178475e-05  -1.06739629e-03]
38
[ 0.09469862]
[  4.00192103e-05   9.13635019e-05   3.15565862e-04]
44
[ 0.01388484]
[-0.00023552  0.00047482 -0.00020402]
66
[ 0.07274449]
[ 0.00011817 -0.00013122  0.00062819]
[0, 1, 2, 4, 5, 6, 7, 9, 10, 12, 13, 14, 15, 16, 18, 19, 20, 22, 23, 24, 25, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36, 37, 39, 40, 41, 42, 43, 45, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 109, 110, 111, 112, 113, 114, 115, 46, 87, 108, 3, 11, 17, 8, 21, 28, 38, 44, 66]

In [35]:
# 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/sophie/New Volume/100621ss2series/100621ss2seriesXk.mat

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

In [ ]: