-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlotCurrentXCorrs.py
126 lines (119 loc) · 6.59 KB
/
PlotCurrentXCorrs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
from __future__ import division
import numpy
import os
import matplotlib
import matplotlib.pyplot as plt
from currents_visualization import plotCurrentscape
# Cell_Name = 'Gormadoc'
Cell_Name = 'Isembard'
Case = Cell_Name + '_E_COM_I_COM'
dt = 0.1
cmap = matplotlib.cm.get_cmap('jet')
cmap2 = matplotlib.cm.get_cmap('rainbow')
labels0 = ('gKA','gKdrf','gKdrs','gKCa','gM','gL','gNa','gCaT','gCaL','gH')
labels = ('$I_{K_A}$','$I_{Kdrf}$','$I_{Kdrs}$','$I_{KCa}$','$I_M$','$I_L$','$I_{Na}$','$I_{CaT}$','$I_{CaL}$','$I_H$')
r0 = numpy.load('NPYFiles_' + Cell_Name + '/' + Case + '_RandSeed_' + str(0) + '_VivoCurrentsS.npy') # Just to initialize r0
r0[6:]=-r0[6:] # Flip inward currents for cross-correlations
# Soma
RecName = '_All_'
RecName2 = '_VivoCurrentsS.npy'
RecName3 = '_VitroCurrentsS.npy'
RecName4 = '_VivoCurrentsD1.npy'
RecName5 = '_VitroCurrentsD1.npy'
RecName6 = '_VivoCurrentsD2.npy'
RecName7 = '_VitroCurrentsD2.npy'
RecName8 = '_VivoCurrentsD3.npy'
RecName9 = '_VitroCurrentsD3.npy'
RecName10 = '_VivoCurrentsD4.npy'
RecName11 = '_VitroCurrentsD4.npy'
cind = 0
for r in range(len(r0)):
# Perform all possible cross-correlations (forward and backward)
for u in range(len(r0)):
for y in range(0,5):
plt.plot(numpy.array([-20,20]),numpy.array([0,0]),color='k',linestyle='dashed',linewidth=1)
plt.plot(numpy.array([0,0]),numpy.array([-1,1]),color='k',linestyle='dashed',linewidth=1)
r0 = numpy.load('NPYFiles_' + Cell_Name + '/' + Case + '_RandSeed_' + str(y) + RecName3)
r0[6:]=-r0[6:]
a = (r0[r] - numpy.mean(r0[r])) / (numpy.std(r0[r]) * len(r0[r]))
v = (r0[u] - numpy.mean(r0[u])) / numpy.std(r0[u])
xcorr = numpy.correlate(a,v,mode='full')
lags = (numpy.arange(-len(r0[r])+1, len(r0[u]))*dt)
plt.plot(lags,xcorr,color=(0,0,0.4,0.9),linestyle='solid')
# r0 = numpy.load('NPYFiles_' + Cell_Name + '/' + Case + '_RandSeed_' + str(y) + RecName5)
# r0[6:]=-r0[6:]
# a = (r0[r] - numpy.mean(r0[r])) / (numpy.std(r0[r]) * len(r0[r]))
# v = (r0[u] - numpy.mean(r0[u])) / numpy.std(r0[u])
# xcorr = numpy.correlate(a,v,mode='full')
# lags = (numpy.arange(-len(r0[r])+1, len(r0[u]))*dt)
# plt.plot(lags,xcorr,color=(0,0,0.3,0.9),linestyle='solid')
# r0 = numpy.load('NPYFiles_' + Cell_Name + '/' + Case + '_RandSeed_' + str(y) + RecName7)
# r0[6:]=-r0[6:]
# a = (r0[r] - numpy.mean(r0[r])) / (numpy.std(r0[r]) * len(r0[r]))
# v = (r0[u] - numpy.mean(r0[u])) / numpy.std(r0[u])
# xcorr = numpy.correlate(a,v,mode='full')
# lags = (numpy.arange(-len(r0[r])+1, len(r0[u]))*dt)
# plt.plot(lags,xcorr,color=(0,0,0.5,0.9),linestyle='solid')
# r0 = numpy.load('NPYFiles_' + Cell_Name + '/' + Case + '_RandSeed_' + str(y) + RecName9)
# r0[6:]=-r0[6:]
# a = (r0[r] - numpy.mean(r0[r])) / (numpy.std(r0[r]) * len(r0[r]))
# v = (r0[u] - numpy.mean(r0[u])) / numpy.std(r0[u])
# xcorr = numpy.correlate(a,v,mode='full')
# lags = (numpy.arange(-len(r0[r])+1, len(r0[u]))*dt)
# plt.plot(lags,xcorr,color=(0,0,0.7,0.9),linestyle='solid')
r0 = numpy.load('NPYFiles_' + Cell_Name + '/' + Case + '_RandSeed_' + str(y) + RecName11)
r0[6:]=-r0[6:]
a = (r0[r] - numpy.mean(r0[r])) / (numpy.std(r0[r]) * len(r0[r]))
v = (r0[u] - numpy.mean(r0[u])) / numpy.std(r0[u])
xcorr = numpy.correlate(a,v,mode='full')
lags = (numpy.arange(-len(r0[r])+1, len(r0[u]))*dt)
plt.plot(lags,xcorr,color=(0,0,0.9,0.9),linestyle='solid')
for y in range(0,5):
r0 = numpy.load('NPYFiles_' + Cell_Name + '/' + Case + '_RandSeed_' + str(y) + RecName2)
r0[6:]=-r0[6:]
a = (r0[r] - numpy.mean(r0[r])) / (numpy.std(r0[r]) * len(r0[r]))
v = (r0[u] - numpy.mean(r0[u])) / numpy.std(r0[u])
xcorr = numpy.correlate(a,v,mode='full')
lags = (numpy.arange(-len(r0[r])+1, len(r0[u]))*dt)
plt.plot(lags,xcorr,color=(0.4,0,0,0.9),linestyle='solid')
# r0 = numpy.load('NPYFiles_' + Cell_Name + '/' + Case + '_RandSeed_' + str(y) + RecName4)
# r0[6:]=-r0[6:]
# a = (r0[r] - numpy.mean(r0[r])) / (numpy.std(r0[r]) * len(r0[r]))
# v = (r0[u] - numpy.mean(r0[u])) / numpy.std(r0[u])
# xcorr = numpy.correlate(a,v,mode='full')
# lags = (numpy.arange(-len(r0[r])+1, len(r0[u]))*dt)
# plt.plot(lags,xcorr,color=(0.3,0,0,0.9),linestyle='solid')
# r0 = numpy.load('NPYFiles_' + Cell_Name + '/' + Case + '_RandSeed_' + str(y) + RecName6)
# r0[6:]=-r0[6:]
# a = (r0[r] - numpy.mean(r0[r])) / (numpy.std(r0[r]) * len(r0[r]))
# v = (r0[u] - numpy.mean(r0[u])) / numpy.std(r0[u])
# xcorr = numpy.correlate(a,v,mode='full')
# lags = (numpy.arange(-len(r0[r])+1, len(r0[u]))*dt)
# plt.plot(lags,xcorr,color=(0.5,0,0,0.9),linestyle='solid')
# r0 = numpy.load('NPYFiles_' + Cell_Name + '/' + Case + '_RandSeed_' + str(y) + RecName8)
# r0[6:]=-r0[6:]
# a = (r0[r] - numpy.mean(r0[r])) / (numpy.std(r0[r]) * len(r0[r]))
# v = (r0[u] - numpy.mean(r0[u])) / numpy.std(r0[u])
# xcorr = numpy.correlate(a,v,mode='full')
# lags = (numpy.arange(-len(r0[r])+1, len(r0[u]))*dt)
# plt.plot(lags,xcorr,color=(0.7,0,0,0.9),linestyle='solid')
r0 = numpy.load('NPYFiles_' + Cell_Name + '/' + Case + '_RandSeed_' + str(y) + RecName10)
r0[6:]=-r0[6:]
a = (r0[r] - numpy.mean(r0[r])) / (numpy.std(r0[r]) * len(r0[r]))
v = (r0[u] - numpy.mean(r0[u])) / numpy.std(r0[u])
xcorr = numpy.correlate(a,v,mode='full')
lags = (numpy.arange(-len(r0[r])+1, len(r0[u]))*dt)
plt.plot(lags,xcorr,color=(0.9,0,0,0.9),linestyle='solid')
cind = cind + (1/(10+10+15))
plt.xticks([])
plt.yticks([])
plt.xlim(-20,20)
plt.ylim(-1,1)
# plt.title(labels[r] + ' X ' + labels[u])
plt.rcParams.update({'font.size': 20})
plt.savefig('Plots_' + Cell_Name + '/' + Cell_Name + RecName + labels0[r] + '_Curr1_' + labels0[u] + '_Curr2.pdf', bbox_inches='tight',dpi=200)
plt.savefig('Plots_' + Cell_Name + '/' + Cell_Name + RecName + labels0[r] + '_Curr1_' + labels0[u] + '_Curr2.png', bbox_inches='tight',dpi=200)
plt.gcf().clear()
plt.cla()
plt.clf()
plt.close()