In [1]:
clear all
In [2]:
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
from scipy import io
import scipy.io as sio
%matplotlib inline
import pylab
import csv
from Tkinter import Tk
from tkFileDialog import askopenfilename
from tkFileDialog import askdirectory
import nibabel as nb
from scipy import io
import nibabel as nb
from scipy.interpolate import interp1d
from scipy import ndimage
In [3]:
from sklearn import linear_model
In [4]:
# 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 [5]:
Ua=sio.loadmat(filename)
DT=Ua['TS2']
DT.shape
Out[5]:
In [180]:
# 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 [181]:
Ua=sio.loadmat(filename)
DTzmap=Ua['TS2']
DT.shape
Out[181]:
In [6]:
# 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
filename2 = askopenfilename() # show an "Open" dialog box and return the path to the selected file
print(filename2)
In [7]:
img1 = nb.load(filename2)
data = img1.get_data()
Out[7]:
In [158]:
S=data.shape
S
Out[158]:
In [37]:
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 [42]:
Ua=sio.loadmat(filename)
In [45]:
Time=Ua['TimeFluoOnVid']
In [49]:
Time.shape
Out[49]:
In [51]:
Time_fluoICA=Time[5:12441]
Time_fluoICA.shape
Out[51]:
Z-score
In [190]:
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])
In [191]:
for i in range(S[3]):
Demean[:,:,:,i]=data[:,:,:,i]-np.mean(np.mean(np.mean(data[:,:,:,i],0),0),0)
In [192]:
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
Tvar[i]=np.var(DT[i,:])
Dmaps[Dmaps<0]=0
In [97]:
# 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 [98]:
Ua=sio.loadmat(filename)
In [99]:
Xk=Ua['Xk']
In [25]:
# 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
filenameM = askopenfilename() # show an "Open" dialog box and return the path to the selected file
print(filenameM)
img1 = nb.load(filenameM)
Masks = img1.get_data()
Sm=Masks.shape
Masks=np.array(Masks)
In [26]:
filenameM='/home/sophie/Downloads/RegionList'
with open(filenameM) as f:
content = f.readlines()
Names=[Line.split('\t') for Line in content]
RegionName=[Names[i][0] for i in range(75)]
Num=[int(Names[i][2]) for i in range(75)]
In [193]:
Dmaps.shape
Out[193]:
In [194]:
M=np.zeros((S[3],86))
Mapmean=np.zeros(S[3])
MMasks=np.zeros(86)
In [216]:
for i in range(S[3]):
Mapmean[i]=np.mean(np.mean(np.mean(Dmaps[:,:,:,i])))
for j in range(86):
MMasks[j]=np.mean(np.mean(np.mean(Masks[:,:,:,j])))
if MMasks[j]:
#M[i,j]=np.mean(np.mean(np.mean(Masks[:,:,:,j]*Dmaps[:,:,:,i])))/(MMasks[j]*Mapmean[i])
M[i,j]=np.mean(np.mean(np.mean(Masks[:,:,:,j]*Dmaps[:,:,:,i])))/(Mapmean[i])
In [217]:
CompMainName=S[3]*['']
CompNameAdd=np.zeros((S[3],86))
for i in range(S[3]):
Max=np.max(M[i,:])
I=np.argmax(M[i,:])+1
for j in range(86):
J=[l for l in range(74) if Num[l]==(j+1)]
if M[i,j]>0.2*Max:
CompNameAdd[i,J]=1
J=[l for l in range(75) if Num[l]==I]
CompMainName[i]=Names[np.array(J)][0]
In [197]:
Time_fluoICA.shape
Out[197]:
In [83]:
Time_fluoICA=Time_fluoICA.T
In [84]:
Time_fluoICA.shape
Out[84]:
In [95]:
Xk=Xk.T
In [96]:
Xk.shape
Out[96]:
In [220]:
pylab.rcParams['figure.figsize'] = (13, 2.5)
h=5
tot=0
GoodICAnat=np.zeros(S[3])
for l in range(74):
Final_maps=np.zeros((S[0],S[1],3))
Fmap=np.zeros((S[0],S[1],3))
C=np.zeros(3)
n=0
for i in range(len(CompMainName)):
Dmmv=np.mean(data[:,:,:,i],2)
Dmmv[Dmmv<0.2*np.max(np.max(np.max(Dmmv)))]=0
C=np.squeeze(np.random.rand(3,1))
labeled, nrobject=ndimage.label(Dmmv>0)
if CompMainName[i]==Names[l][0] and (sum(CompNameAdd[i,:])<5) and nrobject<400:
n=n+1
for k in range(3):
Fmap[:,:,k]=0.7*Dmmv*C[k]/np.max(C)
Final_maps=Final_maps+Fmap
plt.plot(Time_fluoICA,(DT[:,i]/np.sqrt(np.var(DT[:,i]))-h*n+2),color=C/2)
tot=tot+1
GoodICAnat[i]=1
#print(i)
for j in range(86):
if CompNameAdd[i,j]==1:
print(Names[np.array(j)][0])
print(i)
plt.plot(Time_fluoICA,Xk[:,0]/np.std(Xk[:,0])+2,color=(1,0,0))
plt.plot(Time_fluoICA,Xk[:,1]/np.std(Xk[:,1])+6,color=(0.5,0.5,0))
plt.plot(Time_fluoICA,Xk[:,2]/np.std(Xk[:,2])+6,color=(1,0,1))
#plt.plot(Time_fluoICA.T,2*Xk[:,2]/np.max(Xk[:,2])+1.5,color=(1,0,1))
if n!=0:
print(Names[l][1])
plt.show()
FM=Final_maps/np.max(np.max(Final_maps))
FM[FM<0.1]=0
plt.imshow(FM,interpolation='none')
plt.show()
frame1 = plt.gca()
frame1.axes.get_xaxis().set_visible(False)
frame1.axes.get_yaxis().set_visible(False)
In [103]:
# 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
Out[103]:
In [104]:
LargerRegionsDic={'':'','AME_R':'OL','LO_R':'OL','NO':'CX','BU_R':'CX','PB':'CX','LH_R':'LH','LAL_R':'LX','SAD':'PENP'
,'CAN_R':'PENP','AMMC_R':'PENP','ICL_R':'INP','VES_R':'VMNP','IB_R':'INP','ATL_R':'INP','CRE_R':'INP'
,'MB_PED_R':'MB','MB_VL_R':'MB','MB_ML_R':'MB','FLA_R':'PENP','LOP_R':'OL','EB':'CX','AL_R':'AL',
'ME_R':'OL','FB':'CX','SLP_R':'SNP','SIP_R':'SNP','SMP_R':'SNP','AVLP_R':'VLNP','PVLP_R':'VLNP',
'IVLP_R':'VLNP','PLP_R':'VLNP','AOTU_R':'VLNP','GOR_R':'VMNP','MB_CA_R':'MB','SPS_R':'VMNP',
'IPS_R':'VMNP','SCL_R':'INP','EPA_R':'VMNP','GNG':'GNG','PRW':'PENP','GA_R':'LX','AME_L':'OL'
,'LO_L':'OL','BU_L':'CX','LH_L':'LH','LAL_L':'LX','CAN_L':'PENP','AMMC_L':'PENP','ICL_L':'INP',
'VES_L':'VMNP','IB_L':'INP','ATL_L':'INP','CRE_L':'INP','MB_PED_L':'MB','MB_VL_L':'MB',
'MB_ML_L':'MB','FLA_L':'PENP','LOP_L':'OL','AL_L':'AL','ME_L':'OL','SLP_L':'SNP','SIP_L':'SNP',
'SMP_L':'SNP','AVLP_L':'VLNP','PVLP_L':'VLNP','IVLP_L':'VLNP','PLP_L':'VLNP','AOTU_L':'VLNP',
'GOR_L':'VMNP','MB_CA_L':'MB','SPS_L':'VMNP','IPS_L':'VMNP','SCL_L':'INP','EPA_L':'VMNP','GA_L':'LX'}
In [105]:
SmallRegionsSorted=['ME_L','ME_R','LO_R','LO_L','LOP_R','LOP_L','AME_R','AME_L',
'PLP_R','PLP_L','PVLP_R','PVLP_L','AVLP_R','AVLP_L','AOTU_R','AOTU_L','IVLP_R','IVLP_L',
'AL_R','AL_L',
'MB_CA_R','MB_CA_L','MB_PED_R','MB_PED_L','MB_VL_R','MB_VL_L','MB_ML_R','MB_ML_L',
'SMP_R','SMP_L','SIP_R','SLP_L','SLP_R','SIP_L',
'LH_R','LH_L',
'CRE_R','CRE_L','ICL_R','ICL_L','SCL_R','SCL_L','IB_R','IB_L','ATL_R','ATL_L',
'EB','PB','NO','FB',
'BU_R','BU_L','LAL_R','LAL_L','GA_R','GA_L',
'GOR_R','GOR_L','EPA_R','EPA_L','VES_R','VES_L','SPS_R','SPS_L','IPS_R','IPS_L',
'AMMC_R','AMMC_L','SAD','FLA_R','FLA_L','PRW','CAN_R','CAN_L',
'GNG','']
In [106]:
Tozip=range(len(SmallRegionsSorted))
SmallRegionsDic=dict(zip(SmallRegionsSorted,Tozip))
In [107]:
LargerRegionInd={ 'OL':1,'VLNP':2,'VMNP':3,'AL':4,'MB':5,'LH':6,'SNP':7,'CX':8,'LX':9,'INP':10,'PENP':11,'GNG':12,'':13}
In [199]:
LargerRegion=[LargerRegionsDic[CompMainName[i]] for i in range(S[3])]
In [200]:
LargerRegionI=np.array([LargerRegionInd[LargerRegion[i]] for i in range(S[3])])
In [201]:
SmallRegion=np.array([SmallRegionsDic[CompMainName[i]] for i in range(S[3])])
In [202]:
NewOrder=np.argsort(SmallRegion)
In [150]:
from rpy2 import robjects
In [206]:
robjects.r['load']('/home/sophie/JefferisData.Rdata')
JefferisData=robjects.r['x']
e=np.array(JefferisData)
enorm=e[10:85,:].astype(float)
for i in range(75):
enorm[i,:]=np.divide(enorm[i,:],np.max(enorm[i,:]))
#enorm[enorm<0.1]=0
In [166]:
set(e[4,:])
Out[166]:
In [221]:
S2=M.shape
M2=np.zeros((S2[0],75))
for j in range(86):
J=np.array([l for l in range(75) if Num[l]==j+1])
if J.shape[0] != 0:
J=J[0]
M2[:,J]=M[:,j]
Mnorm=M2
for i in range(75):
Mnorm[j,i]=M2[j,i]/np.max(M2[:,i])
#Mnorm[Mnorm<0.1]=0
In [222]:
Scores=np.zeros((enorm.shape[1],M2.shape[0]))
for i in range(enorm.shape[1]):
for j in range(M2.shape[0]):
#Scores[i,j]=np
#Scores[i,j]=np.inner(enorm[:,i],Mnorm[j,:])
Scores[i,j]=sum((enorm[:,i]*Mnorm[j,:]))
#Scores[i,j]=-sum(abs(enorm[:,i]-Mnorm[j,:]))
In [223]:
ScoresTH=np.zeros((enorm.shape[1],M2.shape[0]))-18
for i in range(enorm.shape[1]):
for j in range(M2.shape[0]):
if e[4,i]=='TH-Gal4':
ScoresTH[i,j]=np.inner(enorm[:,i],Mnorm[j,:])
#ScoresTH[i,j]=-sum(abs(enorm[:,i]-Mnorm[j,:]))
In [156]:
import csv
i=0
NeuronName=[]
with open('/home/sophie/fc_name_mapping.csv') as f:
file_read = csv.reader(f)
for row in file_read:
NeuronName.append(row[3])
i=i+1
In [112]:
%%javascript
IPython.OutputArea.auto_scroll_threshold =4000;
In [113]:
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=np.squeeze(data[:,:,range(Nstack),2])
for i in range(Nstack):
Vmean=np.mean(Dtemp[:,:,Indices[i]],2)
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[:,:,:])
In [114]:
plt.imshow(Dmean[:,:,1],cmap=plt.cm.gray)
Out[114]:
In [262]:
my_cmap=plt.cm.jet
my_cmap.set_bad(alpha=0)
Good_ICs=np.zeros(S[3])
Label_ICs=[]
pylab.rcParams['figure.figsize'] = (15, 2.5)
In [116]:
algorithm = linear_model.LinearRegression()
In [117]:
Sxk=Xk.shape
In [132]:
Sxk
Out[132]:
In [135]:
Xk=Xk.T
In [136]:
X=np.zeros((Sxk[0],3))
In [137]:
X[:,0]=(Xk[:,0]-np.mean(Xk[:,0]))/np.std(Xk[:,0])
X[:,1]=(Xk[:,1]-np.mean(Xk[:,1]))/np.std(Xk[:,1])
X[:,2]=(Xk[:,2]-np.mean(Xk[:,2]))/np.std(Xk[:,2])
In [138]:
X.shape
Out[138]:
In [140]:
plt.plot(X)
Out[140]:
In [263]:
for j in range(S[3]):
a=''
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,Order[j]]
D1[:,:,i]=V
if (CompMainName[j] != ''):
print(j)
print(CompMainName[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()
model = algorithm.fit(X, DT[:,j])
betas = model.coef_
rsq = model.score(X,DT[:,j])
print('left:',betas[0],'right:',betas[1],'walk:',betas[2])
print(rsq)
I=np.argsort(-Scores[:,j])
#print(I)
#print(e[0][I])
print(NeuronName[np.int(np.float(e[3][I[0]]))])
print(NeuronName[np.int(np.float(e[3][I[1]]))])
ITH=np.argsort(-ScoresTH[:,j])
#print(I)
#print(e[0][ITH])
print(NeuronName[np.int(np.float(e[3][ITH[0]]))])
print(NeuronName[np.int(np.float(e[3][ITH[1]]))])
plt.plot(Time_fluoICA,2*DT[:,j]+4)
plt.plot(Time_fluoICA,DTzmap[:,j]/np.std(DTzmap[:,j])+6)
plt.plot(Time_fluoICA,2*(Xk[:,0]-Xk[:,1])/np.max(Xk[:,0]-Xk[:,1]),color=(1,0,0))
plt.plot(Time_fluoICA,Xk[:,2]/np.max(Xk[:,2])+1.5,color=(1,1,0))
plt.show()
a=raw_input()
Label_ICs.append(a)
In [270]:
L=[j for j in range(len(Label_ICs)) if Label_ICs[j]=='a']
In [271]:
Good_ICs[L]=1
In [273]:
fn=open('/home/sophie/Desktop/100142GoodICs109.txt','w')
for i in range(S[3]):
if Good_ICs[i]:
print>>fn, i
print>>fn, CompMainName[i]
print>>fn, Good_ICs[i]
In [274]:
G=Good_ICs.tolist();
In [275]:
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])
In [276]:
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
In [316]:
GoodICo=Good_ICs[NewOrder]
D2o=D2[:,:,:,NewOrder]
datao=data[:,:,:,NewOrder]
Dmapso=Dmaps[:,:,:,NewOrder]
LargerRegionIo=LargerRegionI[NewOrder]
Ind=np.array(range(S[3]))
Indexo=Ind[NewOrder]
DTo=DT[:,NewOrder]
In [278]:
C=np.zeros((S[3],3))
i=0
for j in range(S[3]):
if LargerRegionIo[j]<12 and GoodICo[j]:
C[j,:]=C1[i%6][:]
for k in range(3):
M=np.max(np.squeeze(np.reshape(D2o[:,:,:,j],S[0]*S[1]*5)))
Fmaps[:,:,:,k]=0.6*D2o[:,:,:,j]*C[j,k]/M
Final_map=Final_map+Fmaps
#print(Indexo[j])
i=i+1
In [279]:
k=0
J=np.zeros(len(GoodICo[GoodICo==1]))
for j in range(len(GoodICo)):
if GoodICo[j]:
print(k)
print([CompMainName[Indexo[j]]])
J[k]=j
k=k+1
In [293]:
Sets=[0,[1,2,23],[6,7,21,22],[4,5],[8,9,10,11,12,13,14],20,[3,15,16,17,18,19,27,28,25],29,[30,31],32,[33,34,35,24]]
In [305]:
S=datao.shape
In [308]:
S
Out[308]:
In [326]:
for i in range(len(Sets)):
Final_map3=np.zeros([S[0],S[1],S[2],3])
Fmaps3=np.zeros([S[0],S[1],S[2],3])
if type(Sets[i])==list:
for j in np.array(Sets[i]):
C=np.zeros((S[3],3))
C[j,:]=C1[j%6][:]
print(j)
for k in range(3):
M=np.max(np.squeeze(np.reshape(Dmapso[:,:,:,J[j]],S[0]*S[1]*S[2],1)))
Fmaps3[:,:,:,k]=0.9*Dmapso[:,:,:,J[j]]*C[j,k]/M
#M=np.max(np.squeeze(np.reshape(D2o[:,:,:,J[j]]),S[0]*S[1],5))
#Fmaps3[:,:,:,k]=0.9*D2o[:,:,:,J[j]]*C[j,k]/M
Final_map3=Final_map3+Fmaps3
else:
j=Sets[i]
C[j,:]=C1[j%6][:]
for k in range(3):
M=np.max(np.squeeze(np.reshape(Dmapso[:,:,:,J[j]],S[0]*S[1]*S[2])))
Fmaps3[:,:,:,k]=0.9*Dmapso[:,:,:,J[j]]*C[j,k]/M
#M=np.max(np.squeeze(np.reshape(D2o[:,:,:,J[j]]),S[0]*S[1],5))
#Fmaps3[:,:,:,k]=0.9*D2o[:,:,:,J[j]]*C[j,k]/M
Final_map3=Final_map3+Fmaps3
#nim=nib.Nifti1Image(D4,np.eye(4))
nim=nb.Nifti1Image(Final_map3,np.eye(4))
nb.save(nim,filename+str(i)+'.nii.gz')
In [350]:
pylab.rcParams['figure.figsize'] = (12, 6)
c=1
for i in range(len(Sets)):
Final_map2=np.zeros([S[0],S[1],3])
Fmaps2=np.zeros([S[0],S[1],3])
Final_map3=np.zeros([S[0],S[1],5,3])
Fmaps3=np.zeros([S[0],S[1],5,3])
if type(Sets[i])==list:
for j in np.array(Sets[i]):
C=np.zeros((S[3],3))
C[j,:]=C1[c%6][:]
#print(j)
for k in range(3):
M=np.max(np.squeeze(np.reshape(D2o[:,:,:,J[j]],S[0]*S[1]*5)))
Fmaps2[:,:,k]=0.9*np.mean(D2o[:,:,:,J[j]],2)*C[j,k]/M
#M=np.max(np.squeeze(np.reshape(D2o[:,:,:,J[j]]),S[0]*S[1],5))
#Fmaps3[:,:,:,k]=0.9*D2o[:,:,:,J[j]]*C[j,k]/M
Final_map2=Final_map2+Fmaps2
#Final_map3=Final_map3+Fmaps3
c=c+1
else:
j=Sets[i]
C[j,:]=C1[c%6][:]
for k in range(3):
M=np.max(np.squeeze(np.reshape(D2o[:,:,:,J[j]],S[0]*S[1]*5)))
Fmaps2[:,:,k]=0.8*np.mean(D2o[:,:,:,J[j]],2)*C[j,k]/M
Final_map2=Final_map2+Fmaps2
c=c+1
Df=np.zeros([S[0],S[1],3])
for l in range(3):
Df[:,:,l]=Final_map2[:,:,l]+np.mean(Dmean,2)/600
MM=np.max(np.max(Df))
Rotated=ndimage.rotate(Df[:,:,:]/MM,-90)
a=plt.imshow(Rotated,cmap=my_cmap,interpolation='none')
frame1 = plt.gca()
frame1.axes.get_xaxis().set_visible(False)
frame1.axes.get_yaxis().set_visible(False)
plt.show()
In [342]:
Walk=X[:,1]+X[:,2]+X[:,0]
Walk[Walk>0]=1
Walk[Walk<0]=np.nan
In [353]:
pylab.rcParams['figure.figsize'] = (7, 30)
h=7
l=0
c=1
plt.plot(Time_fluoICA,(Walk)+10,linewidth=6,color='forestgreen')
for i in range(len(Sets)):
if type(Sets[i])==list:
for j in np.array(Sets[i]):
C=np.zeros((S[3],3))
C[j,:]=C1[c%6][:]
plt.plot(Time_fluoICA,(DTo[:,J[j]]/np.sqrt(np.var(DTo[:,J[j]]))-h*l-h*i),color=C[j,:])
l=l+1
c=c+1
else:
j=Sets[i]
C[j,:]=C1[c%6][:]
plt.plot(Time_fluoICA,(DTo[:,J[j]]/np.sqrt(np.var(DTo[:,J[j]]))-h*l-h*i),color=C[j,:])
l=l+1
c=c+1
plt.plot(Time_fluoICA,(Walk)-h*i-h*l,linewidth=6,color='forestgreen')
plt.plot(Time_fluoICA,(Walk)-h*i-h*l,linewidth=6,color='forestgreen')
plt.xlim([np.min(Time_fluoICA),np.max(Time_fluoICA)])
plt.ylim([-h*i-h*l+7-10,18])
frame1 = plt.gca()
frame1.axes.get_yaxis().set_visible(False)
frame1.axes.set_xlabel('Time (s)')
frame1.xaxis.set_tick_params(width=2,length=5)
matplotlib.rcParams.update({'font.size': 25})
plt.savefig('/media/DataPaper/100142/100142imagegraph.svg')
plt.show()
In [331]:
X.shape
Out[331]:
In [355]:
pylab.rcParams['figure.figsize'] = (12, 6)
c=1
for i in range(len(Sets)):
Final_map2=np.zeros([S[0],S[1],3])
Fmaps2=np.zeros([S[0],S[1],3])
Final_map3=np.zeros([S[0],S[1],5,3])
Fmaps3=np.zeros([S[0],S[1],5,3])
if type(Sets[i])==list:
for j in np.array(Sets[i]):
C=np.zeros((S[3],3))
C[j,:]=C1[c%6][:]
#print(j)
for k in range(3):
M=np.max(np.squeeze(np.reshape(D2o[:,:,:,J[j]],S[0]*S[1]*5)))
Fmaps2[:,:,k]=0.9*np.mean(D2o[:,:,:,J[j]],2)*C[j,k]/M
#M=np.max(np.squeeze(np.reshape(D2o[:,:,:,J[j]]),S[0]*S[1],5))
#Fmaps3[:,:,:,k]=0.9*D2o[:,:,:,J[j]]*C[j,k]/M
Final_map2=Final_map2+Fmaps2
#Final_map3=Final_map3+Fmaps3
c=c+1
Df=np.zeros([S[0],S[1],3])
for l in range(3):
Df[:,:,l]=Fmaps2[:,:,l]+np.mean(Dmean,2)/600
MM=np.max(np.max(Df))
Rotated=ndimage.rotate(Df[:,:,:]/MM,-90)
a=plt.imshow(Rotated,cmap=my_cmap,interpolation='none')
frame1 = plt.gca()
frame1.axes.get_xaxis().set_visible(False)
frame1.axes.get_yaxis().set_visible(False)
plt.show()
else:
j=Sets[i]
C[j,:]=C1[c%6][:]
for k in range(3):
M=np.max(np.squeeze(np.reshape(D2o[:,:,:,J[j]],S[0]*S[1]*5)))
Fmaps2[:,:,k]=0.8*np.mean(D2o[:,:,:,J[j]],2)*C[j,k]/M
Final_map2=Final_map2+Fmaps2
c=c+1
Df=np.zeros([S[0],S[1],3])
for l in range(3):
Df[:,:,l]=Final_map2[:,:,l]+np.mean(Dmean,2)/600
MM=np.max(np.max(Df))
Rotated=ndimage.rotate(Df[:,:,:]/MM,-90)
a=plt.imshow(Rotated,cmap=my_cmap,interpolation='none')
frame1 = plt.gca()
frame1.axes.get_xaxis().set_visible(False)
frame1.axes.get_yaxis().set_visible(False)
plt.show()
In [ ]: