Skip to content

Commit af3e2a1

Browse files
m-kowalskaMarta
andauthored
Figs correction (#157)
* Replace polish names * Uncomment data path * Modify make_plot_perf to take noise_lvl as an argument (#150) * Update CSD resolution * Replace deprecated griddata function * Update README to figures * Fix figures * Update README * Fix data shapes in figures --------- Co-authored-by: Marta <[email protected]>
1 parent 4288610 commit af3e2a1

File tree

10 files changed

+64
-138
lines changed

10 files changed

+64
-138
lines changed

figures/kCSD_properties/L_curve_simulation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def main_loop(src_width, total_ele, inpos, lpos, nm, noise=0, srcs=1):
118118
for i, noise in enumerate(n_spec):
119119
plt.close('all')
120120
noise = np.round(noise, 5)
121-
print('numer rekonstrukcji: ', i, 'noise level: ', noise)
121+
print('number of reconstruction: ', i, 'noise level: ', noise)
122122
#Electrodes
123123
ele_pos, pots = electrode_config(total_ele, true_csd, t_csd_x, t_csd_y, inpos, lpos)
124124
ele_y = ele_pos[:, 1]
@@ -179,5 +179,5 @@ def main_loop(src_width, total_ele, inpos, lpos, nm, noise=0, srcs=1):
179179
os.chdir('..')
180180
np.save('sim_results', sim_results)
181181
sim_results = np.load('sim_results.npy')
182-
make_plot_perf(sim_results)
182+
make_plot_perf(sim_results, noise_lvl)
183183

figures/kCSD_properties/README.txt

Lines changed: 24 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,178 +1,93 @@
1-
Instructions for the figures from kCSD-revisited paper.
1+
Instructions for the figures from kCSD-python, reliable current source density estimation with quality control.
22

33
~~~~~~~~~~~~~~~~~~~~~~~
44
Figure 1 - Schematic
55

66
name: figure1.png
77

88
~~~~~~~~~~~~~~~~~~~~~~~
9-
Figure 2 - 1D spectral properties of kCSD method
10-
11-
figure_eigensources_M_1D.py
12-
13-
~~~~~~~~~~~~~~~~~~~~~~~
14-
Figure 3 - Noise-free Electrode / Basis source placement
15-
16-
figure_Tbasis.py
17-
18-
~~~~~~~~~~~~~~~~~~~~~~~
19-
Figure 4 - Noisy electrodes / Basis source placement
20-
21-
figure_Tbasis_noise.py
22-
23-
~~~~~~~~~~~~~~~~~~~~~~~
24-
Figure 5 - L-curve method for regularization
9+
Figure 2 - L-curve method for regularization
2510

2611
You will need to run L_curve_simulation.py first.
2712

2813
figure_LC.py
2914

3015
~~~~~~~~~~~~~~~~~~~~~~~
31-
Figure 6 - L-curve versus Cross-validation
32-
33-
You will need to run L_curve_simulation.py first.
34-
35-
figure_LCandCVperformance.py
36-
37-
~~~~~~~~~~~~~~~~~~~~~~~
38-
Figure 7 - Error propagation map
16+
Figure 3 - Error propagation map
3917

4018
error_propagation.py
4119
colorblind_friendly.py
4220

4321
~~~~~~~~~~~~~~~~~~~~~~~
44-
Figure 8 - Reliability map
22+
Figure 4 - Reliability map 2D
4523

4624
reliability_map_2d.py
4725

4826
error_maps_2D/point_error_large_100_all_ele.npy
4927
error_maps_2D/point_error_small_100_all_ele.npy
5028

5129
~~~~~~~~~~~~~~~~~~~~~~~
52-
Figure 9 - Reliability map; Use case in a 2D dipolar large source
30+
Figure 5 - Reliability map; Use case in a 2D dipolar large source
5331

5432
kCSD_with_reliability_map_2D.py
5533

5634
error_maps_2D/point_error_large_100_all_ele.npy
5735
error_maps_2D/point_error_small_100_all_ele.npy
5836

5937
~~~~~~~~~~~~~~~~~~~~~~~
60-
Figure 10 - Average Error (Diff) when broken electrode and loss in reconstruction quality
38+
Figure 6 - Average Error (Diff) when broken electrode and loss in reconstruction quality
6139

6240
You will need to run tutorial3.py first or download files from here
6341
https://www.dropbox.com/sh/6kykj4d3dx3fp5s/AAACtN49VCbAHA9otOfNXbnOa?dl=0
6442

6543
tutorial_broken_electrodes_diff_err.py
6644

6745
~~~~~~~~~~~~~~~~~~~~~~~
68-
Figure 11 - Simulated cortical recordings in Traubs's model
69-
70-
You will need to download files from:
71-
https://repod.pon.edu.pl/dataset/thalamocortical-network/resource/6add09e1-bfe4-4082-b990-24b469756886
72-
73-
npx/traub_data_kcsd_column_figure.py
74-
75-
~~~~~~~~~~~~~~~~~~~~~~~
76-
Figure 12 - LFP and CSD as a function of time - Traub's model
77-
78-
You will need to download files from:
79-
https://repod.pon.edu.pl/dataset/thalamocortical-network/resource/6add09e1-bfe4-4082-b990-24b469756886
80-
81-
npx/figure_traub_timespace.py
82-
83-
~~~~~~~~~~~~~~~~~~~~~~~
84-
Figure 13 - Six first eigensources for a single bank of a Neuropixels probe
85-
86-
You will need to download files from:
87-
https://repod.pon.edu.pl/dataset/thalamocortical-network/resource/6add09e1-bfe4-4082-b990-24b469756886
88-
89-
npx/figure_traub_eigensources.py
90-
91-
~~~~~~~~~~~~~~~~~~~~~~~
92-
Figure 14 - LFP and CSD space profiles - experimental data from a single bank of a Neuropixels probe
9346

94-
You will need to download files from:
95-
96-
npx/kCSD2D_reconstruction_from_npx.py
97-
98-
~~~~~~~~~~~~~~~~~~~~~~~
99-
Figure 15 - LFP and CSD as a function of time - experimental data
100-
101-
You will need to download files from:
102-
103-
npx/kCSD2D_reconstruction_from_npx.py
104-
105-
~~~~~~~~~~~~~~~~~~~~~~~~
106-
Figure 16 - L-Curve and CV landscape
47+
Figure 7 - L-Curve and CV landscape
10748

10849
You will need to run L_curve_simulation.py first.
10950

11051
figure_LCandCV.py
11152

11253
~~~~~~~~~~~~~~~~~~~~~~~
113-
Figure 17 - Schematic - location of Neuropixels bank 0
114-
115-
name: figure17.png
116-
117-
=====================
118-
Supplementary Figures
119-
=====================
120-
121-
~~~~~~~~~~~~~~~~~~~~~~~~~~
122-
Figure 2-Figure supplement 1 - spectral properties of kCSD method for simple 2D case
123-
124-
figure_eigensources_M_2D.py
125-
126-
~~~~~~~~~~~~~~~~~~~~~~~~~~
127-
Figure 7-Figure supplement 1 - Error propagation maps for 1D
128-
129-
pots_propagation.py
13054

131-
~~~~~~~~~~~~~~~~~~~~~~~~~~
132-
Figure 13-Figure supplement 1 - Eigensurces 7-12 ('start=6', 'stop=12'),
133-
Figure 13-Figure supplement 2 - Eigensurces 13-18 ('start=12', 'stop=18'),
134-
Figure 13-Figure supplement 3 - Eigensurces 19-24 ('start=18', 'stop=24'),
135-
Figure 13-Figure supplement 4 - Eigensurces 25-30 ('start=24', 'stop=30'),
136-
Figure 13-Figure supplement 5 - Eigensurces 31-36 ('start=30', 'stop=36'),
137-
Figure 13-Figure supplement 6 - Eigensurces 37-42 ('start=36', 'stop=42'),
138-
Figure 13-Figure supplement 7 - Eigensurces 43-48 ('start=42', 'stop=48')
139-
140-
All supplementary figures to Figure 13 were created using different
141-
'start' and 'stop'parameters at:
142-
npx/figure_traub_eigensources.py
143-
144-
================
145-
Appendix Figures
146-
================
147-
148-
~~~~~~~~~~~~~~~~~~~~~~~
149-
Appendix 1 Figure 1 - Basic features tutorial
55+
Figure 8 - Basic features tutorial
15056

15157
You will need to run tutorial3.py first or download files from here
15258
https://www.dropbox.com/sh/6kykj4d3dx3fp5s/AAACtN49VCbAHA9otOfNXbnOa?dl=0
15359

15460
tutorial_basic.py
15561

15662
~~~~~~~~~~~~~~~~~~~~~~~
157-
Appendix 1 Figure 2 - Noisy electrodes tutorial
63+
64+
Figure 9 - Noisy electrodes tutorial
15865

15966
tutorial_noisy_electrodes.py
16067

161-
~~~~~~~~~~~~~~~~~~~~~~~~
162-
Appendix 1 Figure 3 - Broken electrodes tutorial
68+
~~~~~~~~~~~~~~~~~~~~~~~
69+
Figure 10 - Broken electrodes tutorial
16370

16471
Download first from
16572
https://www.dropbox.com/sh/6kykj4d3dx3fp5s/AAACtN49VCbAHA9otOfNXbnOa?dl=0
16673
(generated from tweaking tutorial3.py)
16774

16875
tutorial_broken_electrodes.py
16976

170-
~~~~~~~~~~~~~~~~~~~~~~~~~~
171-
Appendix 1 Figure 4 - 3D source reconstruction
77+
~~~~~~~~~~~~~~~~~~~~~~~
78+
Figure 11 - Error propagation maps for 1D
79+
80+
pots_propagation.py
81+
82+
~~~~~~~~~~~~~~~~~~~~~~~
83+
Figure 12 - 3D source reconstruction
17284

17385
tutorial_basic_3d.py
17486

175-
~~~~~~~~~~~~~~~~~~~~~~~~~~
176-
Appendix 1 Figure 5 - sKCSD example
87+
~~~~~~~~~~~~~~~~~~~~~~~
88+
Figure 13 - sKCSD example
89+
90+
You will need to install LFPy package first:
91+
pip install lfpy
17792

17893
skcsd_and_l_curve_complex_morphology.py

figures/kCSD_properties/error_propagation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ def _BipolarColormap(name, negative, positive):
8080
h = 50. # distance between the electrode plane and the CSD plane
8181
conductivity = 1.0 # S/m
8282

83-
csd_at = np.mgrid[0.:1.:100j,
84-
0.:1.:100j]
83+
csd_at = np.mgrid[0.:1.:101j,
84+
0.:1.:101j]
8585
csd_x, csd_y = csd_at
8686

8787
D = 2 - 1.618

figures/kCSD_properties/figure_LC.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@ def make_plots(title, m_norm, m_resi, true_csd, curveseq, ele_y,
100100
fig.savefig(save_as+'.png')
101101

102102
if __name__=='__main__':
103-
# os.chdir("./LCurve/LC2")
103+
os.chdir("./LCurve/LC2")
104104
noises = 3
105105
noise_lvl = np.linspace(0, 0.5, noises)
106-
#df = np.load('data_fig4_and_fig13_lc_noise25.0.npz')
106+
df = np.load('data_fig4_and_fig13_LC_noise25.0.npz')
107107
Rs = np.linspace(0.025, 8*0.025, 8)
108-
title = ['nazwa_pliku']
108+
title = ['file_name']
109109
save_as = 'noise'
110110
make_plots(title, df['m_norm'], df['m_resi'], df['true_csd'],
111111
df['curve_surf'], df['ele_y'], df['pots_n'],

figures/kCSD_properties/figure_LCandCV.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def plot_surface(curve_surf, errsy, save_as):
7474
df = np.load(os.path.join('LC2', 'data_fig4_and_fig13_LC_noise25.0.npz'))
7575

7676
Rs = np.linspace(0.025, 8*0.025, 8)
77-
title = ['nazwa_pliku']
77+
title = ['file_name']
7878
save_as = 'noise'
7979
plot_surface(df['curve_surf'], df['errsy'], save_as+'surf')
8080
plt.close('all')

figures/kCSD_properties/figure_LCandCVperformance.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def set_axis(ax, x, y, letter=None):
2020
transform=ax.transAxes)
2121
return ax
2222

23-
def make_plot_perf(sim_results):
23+
def make_plot_perf(sim_results, noise_lvl):
2424
rms_lc = sim_results[0, 2]
2525
lam_lc = sim_results[0, 0]
2626
rms_cv = sim_results[1, 2]
@@ -81,4 +81,4 @@ def make_plot_perf(sim_results):
8181
noises = 9
8282
noise_lvl = np.linspace(0, 0.5, noises)
8383
sim_results = np.load('sim_results.npy')
84-
make_plot_perf(sim_results)
84+
make_plot_perf(sim_results, noise_lvl)

figures/kCSD_properties/kCSD_with_reliability_map_2D.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def make_reconstruction(KK, csd_profile, csd_seed, total_ele,
102102

103103
def make_subplot(ax, val_type, xs, ys, values, cax, title=None, ele_pos=None,
104104
xlabel=False, ylabel=False, letter='', t_max=None,
105-
mask=False, level=False):
105+
mask=False, mask_x=False, mask_y=False, level=False):
106106
if val_type == 'csd':
107107
cmap = cm.bwr
108108
elif val_type == 'pot':
@@ -124,7 +124,10 @@ def make_subplot(ax, val_type, xs, ys, values, cax, title=None, ele_pos=None,
124124
levels=levels, cmap=cmap, alpha=1,
125125
extent=(0, 0.5, 0, 0.5))
126126
if mask is not False:
127-
CS = ax.contour(xs, ys, mask, cmap='Greys')
127+
if mask_x is not False:
128+
CS = ax.contour(mask_x, mask_y, mask, cmap='Greys')
129+
else:
130+
CS = ax.contour(xs, ys, mask, cmap='Greys')
128131
ax.clabel(CS, # label every second level
129132
inline=1,
130133
fmt='%1.2f',
@@ -182,7 +185,7 @@ def generate_figure(k, true_csd, ele_pos, pots, mask=False):
182185
# gs.update(top=.95, bottom=0.53)
183186
ax = plt.subplot(gs[0, 0])
184187
cax = plt.subplot(gs[1, 0])
185-
make_subplot(ax, 'csd', csd_x, csd_y, true_csd, cax=cax, ele_pos=ele_pos,
188+
make_subplot(ax, 'csd', k.estm_x, k.estm_y, true_csd, cax=cax, ele_pos=ele_pos,
186189
title='True CSD', xlabel=True, ylabel=True, letter='A',
187190
t_max=np.max(abs(true_csd)))
188191
ax = plt.subplot(gs[0, 1])
@@ -195,10 +198,10 @@ def generate_figure(k, true_csd, ele_pos, pots, mask=False):
195198
make_subplot(ax, 'csd', k.estm_x, k.estm_y, k.values('CSD')[:, :, 0],
196199
cax=cax, ele_pos=ele_pos, title='kCSD with Reliability Map',
197200
xlabel=True, letter='C', t_max=np.max(abs(true_csd)),
198-
mask=mask)
201+
mask=mask, mask_x=csd_x, mask_y=csd_y)
199202
ax = plt.subplot(gs[0, 3])
200203
cax = plt.subplot(gs[1, 3])
201-
make_subplot(ax, 'diff', csd_x, csd_y,
204+
make_subplot(ax, 'diff', k.estm_x, k.estm_y,
202205
abs(true_csd-k.values('CSD')[:, :, 0]), cax=cax,
203206
ele_pos=ele_pos, title='|True CSD - kCSD|', xlabel=True,
204207
letter='D',
@@ -241,9 +244,10 @@ def matrix_symmetrization(point_error):
241244
Rs=Rs,
242245
lambdas=lambdas,
243246
method=method)
247+
test_csd = CSD_PROFILE([k.estm_x, k.estm_y], CSD_SEED)
244248
error_l = np.load('error_maps_2D/point_error_large_100_all_ele.npy')
245249
error_s = np.load('error_maps_2D/point_error_small_100_all_ele.npy')
246250
error_all = np.concatenate((error_l, error_s))
247251
symm_array_all = matrix_symmetrization(error_all)
248-
generate_figure(k, true_csd, ele_pos, pots,
252+
generate_figure(k, test_csd, ele_pos, pots,
249253
mask=np.mean(symm_array_all, axis=0))

figures/kCSD_properties/pots_propagation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ def generate_figure(true_csd_xlims, total_ele, ele_lims, R_init=0.23):
123123
for i in range(len(ele_pos)):
124124
ax = fig.add_subplot(gs[plt_cord[i][0],
125125
plt_cord[i][1]:plt_cord[i][1]+2])
126-
ax.plot(np.linspace(0, 1, 100), est_csd[i], lw=2, c='red',
126+
ax.plot(np.linspace(0, 1, 101), est_csd[i], lw=2, c='red',
127127
label='kCSD')
128128
ax.scatter(ele_pos, np.zeros(len(ele_pos)), c='k', label='Electrodes')
129129
ax2 = ax.twinx()
130-
ax2.plot(np.linspace(0, 1, 100), OBJ_M[i].values('POT'), c='green',
130+
ax2.plot(np.linspace(0, 1, 101), OBJ_M[i].values('POT'), c='green',
131131
label='Potentials')
132132
ax2.set_ylim([-1.5, 1.5])
133133
ax.set_ylim([-150, 150])

figures/kCSD_properties/reliability_map_2D.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def make_single_subplot(ax, val_type, xs, ys, values, cax, title=None,
7373
plt.colorbar(im, cax=cax, orientation='horizontal', format='%.2f',
7474
ticks=ticks)
7575
set_axis(ax, letter=letter)
76-
plt.tight_layout()
76+
#plt.tight_layout()
7777
return ax, cax
7878

7979

0 commit comments

Comments
 (0)