lucastheis / c2s

A toolbox for inferring spikes from calcium traces.
http://c2s.readthedocs.org
MIT License
22 stars 13 forks source link

Output of c2s.preprocess is inconsistent #11

Closed mpmbq2 closed 8 years ago

mpmbq2 commented 8 years ago

When using c2s.preprocess if the fps parameter is set such that the sampling rate does not need to be adjusted (i.e. the same sampling rate as the original image), the resulting preprocessed_output[0]['calcium'] is an array of shape (frames,). However, if fps is set such that the sampling rate of the data does need to be adjusted, the preprocessed_output[0]['calcium'] is an array of shape (1, frames). This is problematic when matching the sampling rates of multiple images. I am attaching a screenshot from jupyter notebook as an example. In 19: is a packaging step; In 35: sets fps to require re-sampling, and In 36: is using the original sampling rate of the image.

I will continue to look for a fix, but I wanted to also bring it to your attention.

screenshot from 2016-08-29 11 25 58

System Info: Ubuntu 14.04, Python 2.7.12

mpmbq2 commented 8 years ago

I believe this issue can be fixed by removing the .reshape(1, -1) method from line 239 of c2s.py. Is there a problem with doing this that I am missing?

Edit: It seems my previous solution breaks the predict function. To work around the issue I added data[k]['calcium'] = data[k]['calcium'].reshape(1,-1) at line 244 to get it into a format readable by c2s.predict.

lucastheis commented 8 years ago

preprocess assumed that if spike trains or spike times are given as input, it is already in the correct format (1xN). It probably shouldn't, so I changed it (04a4c2f5878). Thanks for reporting the issue, @mpmbq2!