slayerPytorch icon indicating copy to clipboard operation
slayerPytorch copied to clipboard

binningMode = 'SUM' does not work as it's supposed to

Open ronichester opened this issue 2 years ago • 1 comments

in spikeFileIO.py, the following lines have the same effect as binningMode = 'OR' :

elif binningMode.upper() == 'SUM':
				emptyTensor[pEvent[validInd], 
							yEvent[validInd],
							xEvent[validInd],
							tEvent[validInd]] += 1/samplingTime

That is because += 1 in this case does not work, I believe it's a bug in your code. The idea is to sum the number of spikes on the same pixel in the same time window, but the way it's written it does not sum; i did many tests myself. In order to work as expected, the code should be something like this:

elif binningMode.upper() == 'SUM':
    for p,y,x,t in zip(pEvent[validInd], yEvent[validInd], xEvent[validInd], tEvent[validInd]):
                    emptyTensor[p,y,x,t] += 1/samplingTime

This implementation is terribly NOT efficient (up to the point it is unfeasible) but it works as expected. I can't think of a clever way to use the np.array characteristics to make it work efficiently; any ideas?

The point is, in my opinion, the way the code is written now, binning mode OR = binning mode SUM, and I am sure it was not supposed to be this way.

Cheers,

ronichester avatar Jan 19 '23 21:01 ronichester

Hi @ronichester, yes it looks like a bug. Your snippet is correct. Will you be willing to issue a fix?

bamsumit avatar Jan 20 '23 17:01 bamsumit