neuroprob/likelihoods.py
def rate_rescale(self, neuron, spike_ind, rates, duplicate, minimum=1e-8):
        """
        Rate rescaling with option to dequantize, which will be random per sample.
        
        :param torch.tensor rates: input rates of shape (trials, neurons, timesteps)
        :returns: list of rescaled ISIs, list index over neurons, elements of shape (trials, ISIs)
        :rtype: list
        """
        rtime = torch.cumsum(rates, dim=-1)*self.tbin
        samples = rtime.shape[0]
        rISI = []
        for tr in range(self.trials):
            isis = []
            for en, n in enumerate(neuron):
                if len(spike_ind[tr][n]) > 1:
                    if self.dequant:
                        deqn = torch.rand(
                            samples, 
                            *spike_ind[tr][n].shape, 
                            device=rates.device
                        )*rates[tr::self.trials, en, spike_ind[tr][n]]*self.tbin # assume spike at 0
                        
                        tau = rtime[tr::self.trials, en, spike_ind[tr][n]] - deqn
                        if duplicate[n]: # re-oder in case of duplicate spike_ind
                            tau = torch.sort(tau, dim=-1)[0]
                    else:
                        tau = rtime[tr::self.trials, en, spike_ind[tr][n]]
                        
                    a = tau[:, 1:]-tau[:, :-1]
                    a[a < minimum] = minimum # don't allow near zero ISI
                    isis.append(a) # samples, order
                else:
                    isis.append([])
            rISI.append(isis)

        return rISI

        Rate rescaling with option to dequantize, which will be random per sample.
        
        :param torch.tensor rates: input rates of shape (trials, neurons, timesteps)
        :returns: list of rescaled ISIs, list index over neurons, elements of shape (trials, ISIs)
        :rtype: list
        
Rate rescaling with option to dequantize, which will be random per sample.
Rate rescaling with option to dequantize which will be random per sample .
def rate_rescale(self, neuron, spike_ind, rates, duplicate, minimum=1e-8):
        rtime = torch.cumsum(rates, dim=-1)*self.tbin
        samples = rtime.shape[0]
        rISI = []
        for tr in range(self.trials):
            isis = []
            for en, n in enumerate(neuron):
                if len(spike_ind[tr][n]) > 1:
                    if self.dequant:
                        deqn = torch.rand(
                            samples, 
                            *spike_ind[tr][n].shape, 
                            device=rates.device
                        )*rates[tr::self.trials, en, spike_ind[tr][n]]*self.tbin 
                        tau = rtime[tr::self.trials, en, spike_ind[tr][n]] - deqn
                        if duplicate[n]: 
                            tau = torch.sort(tau, dim=-1)[0]
                    else:
                        tau = rtime[tr::self.trials, en, spike_ind[tr][n]]
                    a = tau[:, 1:]-tau[:, :-1]
                    a[a < minimum] = minimum 
                    isis.append(a) 
                else:
                    isis.append([])
            rISI.append(isis)
        return rISI
def rate_rescale ( self , neuron , spike_ind , rates , duplicate , minimum = 1e-8 ) : rtime = torch . cumsum ( rates , dim = - 1 ) * self . tbin samples = rtime . shape [ 0 ] rISI = [ ] for tr in range ( self . trials ) : isis = [ ] for en , n in enumerate ( neuron ) : if len ( spike_ind [ tr ] [ n ] ) > 1 : if self . dequant : deqn = torch . rand ( samples , * spike_ind [ tr ] [ n ] . shape , device = rates . device ) * rates [ tr : : self . trials , en , spike_ind [ tr ] [ n ] ] * self . tbin tau = rtime [ tr : : self . trials , en , spike_ind [ tr ] [ n ] ] - deqn if duplicate [ n ] : tau = torch . sort ( tau , dim = - 1 ) [ 0 ] else : tau = rtime [ tr : : self . trials , en , spike_ind [ tr ] [ n ] ] a = tau [ : , 1 : ] - tau [ : , : - 1 ] a [ a < minimum ] = minimum isis . append ( a ) else : isis . append ( [ ] ) rISI . append ( isis ) return rISI
Rate rescaling with option to dequantize, which will be random per sample.
Rate rescaling with option to dequantize which will be random per sample .
"""
        Rate rescaling with option to dequantize, which will be random per sample.
        
        :param torch.tensor rates: input rates of shape (trials, neurons, timesteps)
        :returns: list of rescaled ISIs, list index over neurons, elements of shape (trials, ISIs)
        :rtype: list
        """ # assume spike at 0 # re-oder in case of duplicate spike_ind # don't allow near zero ISI # samples, order
list of rescaled ISIs, list index over neurons, elements of shape (trials, ISIs)
list of rescaled ISIs list index over neurons elements of shape ( trials ISIs )
list
self
neuron
spike_ind
rates
input rates of shape (trials, neurons, timesteps)
input rates of shape ( trials neurons timesteps )
duplicate
minimum