예제 #1
0
 def draw_correlation(self, graph_key, flags=None, smooth=False,reverse=False,name=None,xlabel=None,ylabel=None,color_bar=True,color_bar_label=None,vmin=None,vmax=None):
   # Gathering neurons
   if flags is None:
     neuron_list = xrange(len(self.neuron_list))
   else:
     neuron_list = self.get_neuron_id_from_flags(flags)
   if reverse:
     neuron_list.reverse()
   # Gathering datas
   data = map(lambda x : self.neuron_data[x][graph_key], neuron_list)
   if smooth:
     data = map(lambda x : math_tools.gaussian_kernel(x,200), data)
   data = numpy.array(data)
   correlation_matrix = numpy.corrcoef(data)
   # Drawing the graph
   fig = plt.figure()
   ax = fig.add_subplot(111)
   img = ax.imshow(correlation_matrix, interpolation="nearest",vmax=vmax,vmin=vmin)
   if color_bar:
     color_bar = plt.colorbar(img)
     if color_bar_label is not None:
       color_bar.set_label(color_bar_label)
   if name is not None:
     plt.title(name)
   if xlabel is not None:
     plt.xlabel(xlabel)
   if ylabel is not None:
     plt.ylabel(ylabel)
   plt.show()
예제 #2
0
 def draw_neuron_graph(self, graph_key, neuron_id = None, flags = None, r_figure=True,smooth=False):
   data_list = []
   names = []
   if type(graph_key)==list:
     figure = True
   else:
     figure = False
     graph_key = [graph_key]
   if not r_figure:
     figure=False
   if neuron_id is not None:
     data_list = map(lambda x: self.neuron_data[neuron_id][x], graph_key)
     names.extend(map(lambda x: "%s for %s" % (x, self.neuron_list[neuron_id].get_name()), graph_key))
   else:
     if flags is not None:
       if type(flags) != list:
         flags = [flags]
       data = []
       neurons = []
       for flag in flags:
         data.extend(map(lambda x: self.neuron_data[x], self.neuron_flag_dict[flag]))
         neurons.extend(map(lambda x: self.neuron_list[x], self.neuron_flag_dict[flag]))
     else:
       data = self.neuron_data
       neurons = self.neuron_list
     for key in graph_key:
       data_list.extend(map(lambda x: x[key], data))
       names.extend(map(lambda x: "%s for %s" % (key, x.get_name()), neurons))
   if smooth:
     data_list = map(lambda x : math_tools.gaussian_kernel(x, 200), data_list) 
   smart_plot(data_list, figure=figure, names=names)
예제 #3
0
 def draw_neuron_graph(self,
                       graph_key,
                       neuron_id=None,
                       flags=None,
                       r_figure=True,
                       smooth=False):
     data_list = []
     names = []
     if type(graph_key) == list:
         figure = True
     else:
         figure = False
         graph_key = [graph_key]
     if not r_figure:
         figure = False
     if neuron_id is not None:
         data_list = map(lambda x: self.neuron_data[neuron_id][x],
                         graph_key)
         names.extend(
             map(
                 lambda x: "%s for %s" %
                 (x, self.neuron_list[neuron_id].get_name()), graph_key))
     else:
         if flags is not None:
             if type(flags) != list:
                 flags = [flags]
             data = []
             neurons = []
             for flag in flags:
                 data.extend(
                     map(lambda x: self.neuron_data[x],
                         self.neuron_flag_dict[flag]))
                 neurons.extend(
                     map(lambda x: self.neuron_list[x],
                         self.neuron_flag_dict[flag]))
         else:
             data = self.neuron_data
             neurons = self.neuron_list
         for key in graph_key:
             data_list.extend(map(lambda x: x[key], data))
             names.extend(
                 map(lambda x: "%s for %s" % (key, x.get_name()), neurons))
     if smooth:
         data_list = map(lambda x: math_tools.gaussian_kernel(x, 200),
                         data_list)
     smart_plot(data_list, figure=figure, names=names)
예제 #4
0
 def draw_correlation(self,
                      graph_key,
                      flags=None,
                      smooth=False,
                      reverse=False,
                      name=None,
                      xlabel=None,
                      ylabel=None,
                      color_bar=True,
                      color_bar_label=None,
                      vmin=None,
                      vmax=None):
     # Gathering neurons
     if flags is None:
         neuron_list = xrange(len(self.neuron_list))
     else:
         neuron_list = self.get_neuron_id_from_flags(flags)
     if reverse:
         neuron_list.reverse()
     # Gathering datas
     data = map(lambda x: self.neuron_data[x][graph_key], neuron_list)
     if smooth:
         data = map(lambda x: math_tools.gaussian_kernel(x, 200), data)
     data = numpy.array(data)
     correlation_matrix = numpy.corrcoef(data)
     # Drawing the graph
     fig = plt.figure()
     ax = fig.add_subplot(111)
     img = ax.imshow(correlation_matrix,
                     interpolation="nearest",
                     vmax=vmax,
                     vmin=vmin)
     if color_bar:
         color_bar = plt.colorbar(img)
         if color_bar_label is not None:
             color_bar.set_label(color_bar_label)
     if name is not None:
         plt.title(name)
     if xlabel is not None:
         plt.xlabel(xlabel)
     if ylabel is not None:
         plt.ylabel(ylabel)
     plt.show()