22 Plots the membrane voltage, possibility to plot spike times on top of it    24 from builtins 
import range
    27 parser = argparse.ArgumentParser(description=
'Plot membrane potential graphs')
    30 parser.add_argument(
"--ymin", type=float, help=
"minimal y-value")
    31 parser.add_argument(
"--ymax", type=float, help=
"maximal y-value")
    32 parser.add_argument(
"--xmin", type=float, help=
"minimal x-value")
    33 parser.add_argument(
"--xmax", type=float, help=
"maximal x-value")
    34 parser.add_argument(
"-s", type=str, help=
"Name of the simulator", default=
"")
    35 parser.add_argument(
"-tc", type=int, help=
"Column of time-values", default=0)
    36 parser.add_argument(
"-sp", type=str, help=
"file containing spikes")
    38     "-spc", type=int, help=
"Number of the Column containing spikes", default=0)
    42 parser.add_argument(
"-y", type=int, required=
True, help=
"Column of y-values")
    43 parser.add_argument(
"file", metavar=
"file", type=str,
    44                     help=
"file with membrane voltage to plot")
    46 args = parser.parse_args()
    50 import matplotlib.pyplot 
as plt
    51 import matplotlib.colorbar
    55 from dim_labels 
import *
    63     idcs = np.isfinite(data)
    64     return np.max(data[np.isfinite(data)])
    68     idcs = np.isfinite(data)
    69     return np.min(data[np.isfinite(data)])
    72 def plot_membrane(ax, xs, ys, color, ymin=None, ymax=None, xmin=None, xmax=None, label=""):
    74     Plots membrane potential and spikes    76     ax -- plt.figure object to plot into    79     color -- color for the membrane potential graph    80     ymin -- Minimal y value for limits of the plot    81     ymax -- Maximal y value for limits of the plot    82     xmin -- Mnimial x value for limits of the plot    83     xmin -- Maximal x value for limits of the plot    86     ax.plot(xs, ys, color=color, lw=0.3, zorder=1, label=label)
    88     ax.set_xlabel(
"Time in ms")
    89     ax.set_ylabel(
"Voltage in mV")
    92     if (ymin 
is None) 
and (ymax 
is None):
    95         ax.set_ylim(bottom=ymin)
    99         ax.set_ylim(bottom=ymin, top=ymax)
   102     if (xmin 
is None) 
and (xmax 
is None):
   105         ax.set_xlim(left=xmin, right=
get_max(xs))
   107         ax.set_xlim(left=
get_min(xs), right=xmax)
   109         ax.set_xlim(left=xmin, right=xmax)
   113 ax = fig.add_subplot(111)
   116 results = np.genfromtxt(args.file, delimiter=
',', names=
None)
   117 data = np.zeros((results.shape[0], len(results[0])))
   118 for i 
in range(0, len(results)):
   119     data[i] = np.array(list(results[i]))
   121 xs = np.array(data[:, args.tc])
   122 ys = np.array(data[:, args.y])
   124 label = 
"Membrane Voltage"   125 if args.s 
is not None:
   126     label = label + 
" of " + SIMULATOR_LABELS[args.s]
   129               ymax=args.ymax, xmin=args.xmin, xmax=args.xmax, label=label)
   133 if args.sp 
is not None:
   134     results2 = np.genfromtxt(args.sp, delimiter=
',', names=
None)
   136     if not isinstance(results2[0], list):
   140                 ax.axvline(x=i, linestyle=
':', color=
'r',   141                            lw=0.3, label="Spike Times")
   144                 ax.axvline(x=i, linestyle=
':', color=
'r',   148         spikes = np.zeros((results2.shape[0], len(results2[0])))
   149         for i 
in range(0, len(results2)):
   150             spikes[i] = np.array(list(results2[i]))
   154         for i 
in spikes[:, args.spc]:
   156                 ax.axvline(x=i, linestyle=
':', color=
'r',   157                            lw=0.3, label="Spike Times")
   160                 ax.axvline(x=i, linestyle=
':', color=
'r',   164 ax.legend(loc='lower center', bbox_to_anchor=(0.5, 1.05),
   166 fig.savefig(args.file.split(
'.csv')[0] +
   167             ".pdf", format=
'pdf', bbox_inches=
'tight')
 
def plot_membrane(ax, xs, ys, color, ymin=None, ymax=None, xmin=None, xmax=None, label="")