Skip to content

Parse EpochSection in ABF2 files to get digital output waveform info - #562

Merged
apdavison merged 1 commit into
NeuralEnsemble:masterfrom
erikli:master
Nov 15, 2018
Merged

apdavison merged 1 commit into
NeuralEnsemble:masterfrom
erikli:master

Conversation

@erikli

@erikli erikli commented Aug 30, 2018

Copy link
Copy Markdown
Contributor

Noticed that there was an EpochInfoDescription block sitting around that wasn't being used, so I followed the format of the other sections to parse an 'EpochInfo' block into the ABF2 header. On initial inspection, it seems to work properly and I can see the digital output epochs.

A caveat is that each DAC channel can define it's own epoch durations and the EpochInfo returned doesn't provide a duration field. So for example, if Epoch A is defined as 1 second in CMD#0 and as 5 seconds in CMD#1, it isn't necessarily obvious which length the digital output pulse should be if you were to turn the EpochInfo section into a waveform. (Similar to how read_raw_protocol converts the dictEpochInfoPerDAC into a waveform). Still, I think that parsing the EpochInfo block is useful.

@coveralls

coveralls commented Aug 30, 2018 •

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.02%) to 49.576% when pulling 73d4aef on erikli:master into 75f8f9f on NeuralEnsemble:master.

@JuliaSprenger

Copy link
Copy Markdown
Member

Thanks for your contribution @erikli!
Could you incorporate the latest changes from master by rebasing? This should fix the failing travis tests here.

@pep8speaks

Copy link
Copy Markdown

Hello @erikli! Thanks for updating the PR.

@erikli

erikli commented Sep 7, 2018

Copy link
Copy Markdown
Contributor Author

@JuliaSprenger thanks for the advice! Looks like all checks now pass.

Also just adding a note here to resolve the caveat I pointed out in my initial post for the pull request and provide some useful knowledge for anyone who might be trying to parse Axon ABF2 files. The information that you need to recapitulate the original stimulus waveform (both digital and analog) is contained in multiple places.

  • AxonIO._axon_info['protocol'] -- things like number of samples in episode
  • AxonIO.axon_info['section']['ADCSection'] | AxonIO.axon_info['section']['DACSection'] -- things about the number of channels and channel properties
  • AxonIO._axon_info['protocol']['nActiveDACChannel'] -- bitmask specifying which DACs are actually active
  • AxonIO._axon_info['protocol']['nDigitalEnable'] -- bitmask specifying which set of Epoch timings should be used to specify the duration of digital outputs
  • AxonIO._axon_info['dictEpochInfoPerDAC'] -- dict of dict. First index is DAC channel and second index is Epoch number (i.e. information about Epoch A in Channel 2 would be in AxonIO._axon_info['dictEpochInfoPerDAC'][2][0])
  • AxonIO._axon_info['EpochInfo'] -- list of dicts containing information about each Epoch's digital out pattern. Digital out is a bitmask with least significant bit corresponding to Digital Out 0
  • AxonIO._axon_info['listDACInfo'] -- information about DAC name, scale factor, holding level, etc
  • AxonIO._t_starts -- start time of each sweep in a unified time basis
  • AxonIO._sampling_rate

The current AxonIO.read_protocol() method utilizes a subset of these. In particular I know it doesn't consider nDigitalEnable, EpochInfo, or nActiveDACChannel and it doesn't account for different types of Epochs offered by Clampex/pClamp other than discrete steps (such as ramp, pulse train, etc and encoded by nEpochType in the EpochInfoPerDAC section). I'm currently parsing a superset of the properties used by read_protocol() in my analysis scripts, but that code still doesn't parse the full information and isn't in a state where it could be committed and I can't currently prioritize putting together all the code that would parse the full set of data. The AxonIO._axon_info['EpochInfo'] section doesn't currently exist.

What this commit provides is parsing of the ABF2 file header to populate AxonIO._axon_info['EpochInfo']. With that populated, it is possible for a knowledgeable individual to parse out the relevant parts of the protocol for them.

@apdavison

Copy link
Copy Markdown
Member

@erikli The information in your previous comment is very useful. Could you put this information within the docstring for the axonio module or the AxonIO class, so that users can easily see the limitations?

@erikli

erikli commented Sep 11, 2018

Copy link
Copy Markdown
Contributor Author

I'd be happy to but it will probably take me until sometime at the end of this week or next weekend. I will do my best to follow the guidelines in https://neo.readthedocs.io/en/0.6/developers_guide.html#working-on-the-documentation but it will definitely warrant a bit of review as I have never written documentation that would be parsed by something like sphinx autodoc.

@samuelgarcia

Copy link
Copy Markdown
Contributor

I am not a user of clampfit so you are more expert that me here.

As an author of AxonIO and AxonRawIO, the only thing I can say is : read_protocol is not garanty.
I port it to the new implentation but it certainly cover all cases correctly.

Adding more thing to _axon_info info is really good.

Feel free to also make modification on read_protocol and/or add warning/raise for uncorvered case.

@samuelgarcia samuelgarcia added this to the 0.7.0 milestone Oct 2, 2018
@samuelgarcia samuelgarcia added the IO label Oct 2, 2018
@samuelgarcia

Copy link
Copy Markdown
Contributor

Can we merge ?

@erikli

erikli commented Oct 8, 2018 via email

Copy link
Copy Markdown
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants