`bins` can be either a number of bins (has to be int) or a list of edges.
                `bins` can be a tuple (for x and y respectively).

                imshow(s.spatial_firing_rate(weight_function=lambda x: (x[:,1]>0.5)*(x[:,1]<0.6)))

def spatial_firing_rate(self,label_x='x',label_y='y',bins=None,resolution=1.0,geometry=None,weight_function=None,normalize_time=True,normalize_n=False,start_units_with_0=True):
        """
                `bins` can be either a number of bins (has to be int) or a list of edges.
                `bins` can be a tuple (for x and y respectively).

                imshow(s.spatial_firing_rate(weight_function=lambda x: (x[:,1]>0.5)*(x[:,1]<0.6)))

        """
        if bool(self):
            if type(bins) is tuple:
                if type(bins[0]) is int:
                    bins_x = self.spike_times.get_label(label_y).linspace_bins(bins=bins[0])
                else:
                    bins_x = bins[0]
                if type(bins[1]) is int:
                    bins_y = self.spike_times.get_label(label_x).linspace_bins(bins=bins[1])
                else:
                    bins_y = bins[1]
            else:
                if type(bins) is int:
                    bins_x = self.spike_times.get_label(label_y).linspace_bins(bins=bins)
                    bins_y = self.spike_times.get_label(label_x).linspace_bins(bins=bins)
                else:
                    bins_x = bins
                    bins_y = bins
            if weight_function is None:
                H,xed,yed = np.histogram2d(self.spike_times[label_x],self.spike_times[label_y],bins=(bins_x,bins_y))
            else:
                if start_units_with_0:
                    ## TODO : reintroduce a neuron number thing
                    spike_numbers = np.transpose([self.spikes[:,0]-self.n_range[0],self.spikes[:,1]])
                    weights = weight_function(spike_numbers)
                else:
                    weights = weight_function(self.spike_times[label_x],self.spike_times[label_y])
                H,xed,yed = np.histogram2d(self.spike_times[label_x],self.spike_times[label_y],bins=(bins_x,bins_y),weights=weights)
            if normalize_time:
                H = H/(self.spike_times.labels[0].convert('s').len())
            if normalize_n:
                H = H/cells_per_bin
            return H,xed,yed
        else:
            return (np.array([[0]]),np.array([0]),np.array([0]))