python-neo icon indicating copy to clipboard operation
python-neo copied to clipboard

Neuroscope: fix scale of signals.

Open PeterNSteinmetz opened this issue 9 months ago • 2 comments

Need to multiply not divide by 1000 for mV scale.

PeterNSteinmetz avatar May 01 '24 16:05 PeterNSteinmetz

Do you have some documentation or some example traces? This seems reasonable, but it would be nice to know where the scale is coming from.

zm711 avatar May 01 '24 18:05 zm711

The only thing this corrects is the scaling factor applied to convert to mV from the raw samples. There is nothing in the .dat files. The corresponding .xml files contain the voltage range, number of bits for each sample, and amplification. There is nothing per se in those files which says it is mV. @samuelgarcia 's original code set the unit after scaling to mV, so I assume he got that from somewhere.

I can tell you however that with the correction the other way, as before this change, the recordings are being shown as in the 100 nV range, which makes no sense for neurophysiological signals.

This is a common mistake and I have done it myself many times - dividing instead of multiplying by the amplification.

This change also includes a comment which clearly explains the derivation of the scale.

PeterNSteinmetz avatar May 01 '24 19:05 PeterNSteinmetz

Since @samuelgarcia wrote this I put him to review it. My only suggestion would be to move the comment into the actual class rather than in the test so that future us see it there :)

zm711 avatar May 01 '24 21:05 zm711

OK. I added a comment in the source and clarified that this is the proper scale to convert a raw sample value to mV.

PeterNSteinmetz avatar May 01 '24 22:05 PeterNSteinmetz

Oups. Yes it was a mistake. Thanks for the catch.

samuelgarcia avatar May 02 '24 07:05 samuelgarcia

OK. Can we get this reviewed and merged? I don't like keeping these branches open unnecessarily on my fork. Thanks.

PeterNSteinmetz avatar May 02 '24 16:05 PeterNSteinmetz