def label_peri_signals(self,time_signals,label_names=[],units=None,data_units=None,copy=True, pre_signal = 100.0, post_signal = 1000.0, **kwargs):
        """
            creates a labeled spike data structure

            time_label_array is list of lists (or matrix), containing a timestamp in the 
            first column (or first element of each element) and indizes that are to be 
            applied to the data in the remaining columns / elements.


            This function will leave out and duplicate spikes to manage overlapping time signals.

            If you want to get spikes relative to a time signal with felxible limits, use `label_by_time`,
            which will not add or remove spikes, but only shift spikes according to the 
            adjecent time signals.

        """
        if self.data_format == 'empty':
            return SpikeContainer(None,units=self.units,copy_from=self)
        time_signals[0] = convert_time(time_signals[0],from_units=data_units,to_units=units)
        spike_times = self.spike_times.convert(0,units).matrix.copy() # this is read only
        new_matrix = []
        for t in range(len(time_signals[0])):
            condition = (spike_times[:,0] >= time_signals[0][t] - pre_signal)*(spike_times[:,0] < time_signals[0][t] + post_signal)
            new_spikes = (spike_times[condition,0] - time_signals[0][t])[:,np.newaxis]
            old_labels = spike_times[condition,1:]
            new_labels = [[time_signals[_i][t] for _i in range(1,time_signals.shape[0])]] * np.sum(condition)
            if np.sum(condition) > 0:
                new_matrix.append(np.concatenate([new_spikes,old_labels,new_labels],axis=1))
        if len(new_matrix) == 0:
            return SpikeContainer(None,copy_from=self)
        new_matrix = np.concatenate(new_matrix,0)
        if copy:
            new_spike_times = LabeledMatrix(new_matrix,self.spike_times.labels + label_names)
            new_spike_times.labels[0].units = units
            new_spike_times.labels[0].min = pre_signal
            new_spike_times.labels[0].max = post_signal
            s = SpikeContainer(new_spike_times, copy_from=self)
            return s
        else:
            new_spike_times = LabeledMatrix(new_matrix,self.spike_times.labels + label_names)
            new_spike_times.labels[0].units = units
            new_spike_times.labels[0].min = pre_signal
            new_spike_times.labels[0].max = post_signal
            self.set_spike_times(new_spike_times)
            return self
def label_peri_signals ( self , time_signals , label_names = [ ] , units = None , data_units = None , copy = True , pre_signal = 100.0 , post_signal = 1000.0 , ** kwargs ) : if self . data_format == 'empty' : return SpikeContainer ( None , units = self . units , copy_from = self ) time_signals [ 0 ] = convert_time ( time_signals [ 0 ] , from_units = data_units , to_units = units ) spike_times = self . spike_times . convert ( 0 , units ) . matrix . copy ( ) new_matrix = [ ] for t in range ( len ( time_signals [ 0 ] ) ) : condition = ( spike_times [ : , 0 ] >= time_signals [ 0 ] [ t ] - pre_signal ) * ( spike_times [ : , 0 ] < time_signals [ 0 ] [ t ] + post_signal ) new_spikes = ( spike_times [ condition , 0 ] - time_signals [ 0 ] [ t ] ) [ : , np . newaxis ] old_labels = spike_times [ condition , 1 : ] new_labels = [ [ time_signals [ _i ] [ t ] for _i in range ( 1 , time_signals . shape [ 0 ] ) ] ] * np . sum ( condition ) if np . sum ( condition ) > 0 : new_matrix . append ( np . concatenate ( [ new_spikes , old_labels , new_labels ] , axis = 1 ) ) if len ( new_matrix ) == 0 : return SpikeContainer ( None , copy_from = self ) new_matrix = np . concatenate ( new_matrix , 0 ) if copy : new_spike_times = LabeledMatrix ( new_matrix , self . spike_times . labels + label_names ) new_spike_times . labels [ 0 ] . units = units new_spike_times . labels [ 0 ] . min = pre_signal new_spike_times . labels [ 0 ] . max = post_signal s = SpikeContainer ( new_spike_times , copy_from = self ) return s else : new_spike_times = LabeledMatrix ( new_matrix , self . spike_times . labels + label_names ) new_spike_times . labels [ 0 ] . units = units new_spike_times . labels [ 0 ] . min = pre_signal new_spike_times . labels [ 0 ] . max = post_signal self . set_spike_times ( new_spike_times ) return self
creates a labeled spike data structure

            time_label_array is list of lists (or matrix), containing a timestamp in the 
            first column (or first element of each element) and indizes that are to be 
            applied to the data in the remaining columns / elements.


            This function will leave out and duplicate spikes to manage overlapping time signals.

            If you want to get spikes relative to a time signal with felxible limits, use `label_by_time`,
            which will not add or remove spikes, but only shift spikes according to the 
            adjecent time signals.