def read_spiketrain(self ,
                        # the 2 first key arguments are imposed by neo.io API
                        lazy = False,
                        cascade = True,
                        channel_index = 0,
                        segment_duration = 0.,
                        t_start = 0.):
        """
        Function to read in spike trains. This API still does not support read in of
        specific channels as they are recorded. rather the fuunction gets the entity set
        by 'channel_index' which is set in the __init__ function (all spike channels)
        """
        
        #sampling rate
        sr = self.metadata["sampRate"]
        
        # create a list to store spiketrain times
        times = list() 
        
        if lazy:
            # we add the attribute lazy_shape with the size if lazy
            spiketr = SpikeTrain(times,units = pq.s, 
                       t_stop = t_start+segment_duration,
                       t_start = t_start*pq.s,lazy_shape = 40)
        
        else:
            #get the spike data from a specific channel index
            tempSpks =  self.fd.get_entity(channel_index)    
            #transform t_start into index (reading will start from this index) 
            startat = tempSpks.get_index_by_time(t_start,0)#zero means closest index to value
            #get the last index to read, using segment duration and t_start
            endat = tempSpks.get_index_by_time(float(segment_duration+t_start),-1)#-1 means last index before time
            numIndx = startat-endat
            #get the end point using segment duration
            #create a numpy empty array to store the waveforms
            waveforms=np.array(np.zeros([numIndx,tempSpks.max_sample_count]))
            #loop through the data from the specific channel index
            for i in range(startat,endat,1):
                #get cutout, timestamp, cutout duration, and spike unit
                tempCuts,timeStamp,duration,unit = tempSpks.get_data(i)
                #save the cutout in the waveform matrix
                waveforms[i]=tempCuts[0]
                #append time stamp to list
                times.append(timeStamp)
                
            #create a spike train object
            spiketr = SpikeTrain(times,units = pq.s, 
                         t_stop = t_start+segment_duration,
                         t_start = t_start*pq.s,
                         name ="spikes from electrode"+tempSpks.label[-3:],
                         waveforms = waveforms*pq.volt,
                         sampling_rate = sr * pq.Hz,
                         file_origin = self.filename,
                         annotate = ("channel_index:"+ str(channel_index)))
            
        return spiketr
dataset/ETHPy150Open NeuralEnsemble/python-neo/neo/io/neuroshareapiio.py/NeuroshareapiIO.read_spiketrain/swapped operands of `-`