| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
""" |
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
import os, sys, numpy, pylab, shelve |
|---|
| 17 |
|
|---|
| 18 |
N, N_exp = 1000, 6 |
|---|
| 19 |
t_smooth = 100. |
|---|
| 20 |
from NeuroTools.parameters import ParameterSpace, ParameterRange |
|---|
| 21 |
snr = 2.0 * numpy.linspace(0.1,2.0,N_exp) |
|---|
| 22 |
p = ParameterSpace({'snr' : ParameterRange(list(snr))}) |
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
name = sys.argv[0].split('.')[0] |
|---|
| 26 |
results = shelve.open('results/mat-' + name) |
|---|
| 27 |
try: |
|---|
| 28 |
|
|---|
| 29 |
temporal_ON = results['temporal_ON'] |
|---|
| 30 |
temporal_OFF = results['temporal_OFF'] |
|---|
| 31 |
lower_edges = results['lower_edges'] |
|---|
| 32 |
params = results['params'] |
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
except: |
|---|
| 36 |
from retina import * |
|---|
| 37 |
retina = Retina(N) |
|---|
| 38 |
retina.params['amplitude'] = numpy.ones(retina.params['amplitude'].shape) |
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
results_dim, results_label = p.parameter_space_dimension_labels() |
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
data = retina.run(retina.params,verbose=False) |
|---|
| 46 |
lower_edges = data['out_ON_DATA'].time_axis(t_smooth) |
|---|
| 47 |
N_smooth = len(lower_edges) |
|---|
| 48 |
|
|---|
| 49 |
temporal_ON, temporal_OFF = [],[] |
|---|
| 50 |
import progressbar |
|---|
| 51 |
pbar=progressbar.ProgressBar(widgets=[name, " ", progressbar.Percentage(), ' ', |
|---|
| 52 |
progressbar.Bar(), ' ', progressbar.ETA()], maxval=N_exp) |
|---|
| 53 |
for i_exp,experiment in enumerate(p.iter_inner()): |
|---|
| 54 |
params = retina.params |
|---|
| 55 |
params.update(experiment) |
|---|
| 56 |
|
|---|
| 57 |
data = retina.run(params,verbose=False) |
|---|
| 58 |
|
|---|
| 59 |
index = p.parameter_space_index(experiment) |
|---|
| 60 |
|
|---|
| 61 |
temporal_ON.append(sum(data['out_ON_DATA'].firing_rate(t_smooth))/N) |
|---|
| 62 |
temporal_OFF.append(sum(data['out_OFF_DATA'].firing_rate(t_smooth))/N) |
|---|
| 63 |
pbar.update(i_exp) |
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
results['lower_edges'] = lower_edges |
|---|
| 67 |
results['temporal_ON'] = temporal_ON |
|---|
| 68 |
results['temporal_OFF'] = temporal_OFF |
|---|
| 69 |
results['params'] = retina.params |
|---|
| 70 |
|
|---|
| 71 |
pbar.finish() |
|---|
| 72 |
|
|---|
| 73 |
results.close() |
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
from NeuroTools.plotting import pylab_params |
|---|
| 78 |
|
|---|
| 79 |
""" Figure 1 |
|---|
| 80 |
|
|---|
| 81 |
Prints to a figure the mean firing rate for the output (ON and OFF) as a function |
|---|
| 82 |
of the different parameter values. It's similar to a CRF function. |
|---|
| 83 |
|
|---|
| 84 |
""" |
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
pylab.figure(1) |
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
pylab.subplot(211) |
|---|
| 91 |
for i_exp in range(N_exp): |
|---|
| 92 |
pylab.plot(lower_edges[:-1] + t_smooth/2, temporal_ON[i_exp], |
|---|
| 93 |
label= '%5.2f' % p.snr._values[i_exp]) |
|---|
| 94 |
pylab.xticks( numpy.round(numpy.linspace(0, params.simtime, 5),0) ) |
|---|
| 95 |
pylab.ylabel('ON Firing frequency (Hz)') |
|---|
| 96 |
pylab.axis([0, params.simtime, 0.0, numpy.max(temporal_ON[:])]) |
|---|
| 97 |
pylab.legend(loc='upper right') |
|---|
| 98 |
pylab.subplot(212) |
|---|
| 99 |
for i_exp in range(N_exp): |
|---|
| 100 |
pylab.plot(lower_edges[:-1] + t_smooth/2, temporal_OFF[i_exp]) |
|---|
| 101 |
pylab.xticks( numpy.round(numpy.linspace(0, params.simtime, 5),0) ) |
|---|
| 102 |
pylab.ylabel('OFF Firing frequency (Hz)') |
|---|
| 103 |
pylab.xlabel('time (ms)') |
|---|
| 104 |
pylab.axis([0, params.simtime, 0.0, numpy.max(temporal_OFF[:]) ]) |
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
if 0: |
|---|
| 108 |
pylab.ion() |
|---|
| 109 |
|
|---|
| 110 |
else: |
|---|
| 111 |
pylab.savefig('results/fig-' + name + '.pdf') |
|---|
| 112 |
pylab.savefig('results/fig-' + name + '.png', dpi = 300) |
|---|
| 113 |
|
|---|