NeuralEnsemble / python-neo

Neo is a package for representing electrophysiology data in Python, together with support for reading a wide range of neurophysiology file formats
http://neo.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
322 stars 247 forks source link

Scaling error with ABF file #228

Open xiki-tempula opened 8 years ago

xiki-tempula commented 8 years ago

The analog signals read from ABF files are roughly 500 times larger than the correct value. The ABF file which I'm using is the ABF V1.60 and I'm using Python 3. I load the ABF file using the following code.

original_file = AxonIO(filename=self.filename) read_data = original_file.read_block(lazy=False, cascade=True) self.trace = read_data.segments[0].analogsignals[0]

The raw file can be found here. https://drive.google.com/file/d/0BwyH-AX6qhpUczljSFlYNWxlOFk/view?usp=sharing

Thanks.

samuelgarcia commented 8 years ago

Hi thank you for reporting this.

Could you give your value with this:

bl= neo.AxonIO(filename = '2015_06_04_0020.abf').read()[0]

for seg in bl.segments:
    print(seg)
    for ana in seg.analogsignals:
        print '  ', ana.name, ana.size, ana.max(), ana.min(), ana.mean(), ana.times[0], ana.times[-1] 

I have: IcontpA 7230000 9999.69433594 pA -2627.25830078 pA 1956.23046875 pA 0.0 s 72.29999 s

I guess the bug is in neo/io.axonio.py in the function _def reformat_integerV1(data, nbchannel, header)

Could you have a look if something seems to be strange there. I am not expert with abf files.

xiki-tempula commented 8 years ago

Hi, Thank you for your reply. I have also got. <neo.core.segment.Segment object at 0x10da7d8d0> b'IcontpA' 7230000 9999.6943359375 pA -2627.25830078125 pA 1934.9583740234375 pA 0.0 s 72.29999 s

However, if you open this file with clampfit, you will notice that the maximum current is 19.9994 pA, the minimum current is -5.25452 pA and the mean current is 3.86992 pA. The time is correct. My personal guess is that the amplification done by AMP is not included in the algorithm and since I'm using an AMP of *500, all the current is roughly 500 times larger than the actual data. Thank you very much.

samuelgarcia commented 8 years ago

Do you think that this gain could be one of theses variables:

I do not known what AMP is (I am not an user). Is this module programmable or is it manual ?

xiki-tempula commented 8 years ago

I have did a check on these four values and I think they are correct. I have resaved the data from ABF v1.6 to ABFv1.8 and that solves the problem.

samuelgarcia commented 8 years ago

There must be a hidden gain in version 1.6. If someone have time to read the specification history I leave this open for a while. thanks for helping.