abfload icon indicating copy to clipboard operation
abfload copied to clipboard

Solved problem with tag set by HumSilencer

Open Mijar007 opened this issue 1 year ago • 2 comments

abfload runs into an error in line 860 if the HumSilencer of the Axon Digidata 1550B digitalizer was enabled during the recording using Clampex 11.2 (At least for episodic recordings). The reason is that at the end of Part 3, the tags are assigned to the corresponding episodes based on their start time. However, while the HumSilencer tag was created at time 0, the first episode starts a bit later (~0.02 during a 10 kHz recording). Therefore, the code runs into the condition, but the variable tmp remains empty, which is why it cannot be used for indexing in the next line, leading to an error. So I added another condition which checks if the tag was created at time 0. If yes, it will be assigned to episode 0. Here is my code snippet which replaces lines 857-862:

if ~isempty(h.tags) && isfield(h,'sweepStartInPts')
    for i=1:numel(h.tags)
        if h.tags(i).timeSinceRecStart > 0 %Comments added during recording
            tmp=find(h.tags(i).timeSinceRecStart>=h.sweepStartInPts/1e6*h.si);
            h.tags(i).episodeIndex=tmp(end);
        elseif h.tags(i).timeSinceRecStart == 0 %HumSilencer comment at timeSinceRecStart = 0
            h.tags(i).episodeIndex = 0; %Will be added to episode 0
        end
    end
end

Mijar007 avatar Jun 14 '23 12:06 Mijar007

looks good! can you submit a PR?

fcollman avatar Jun 14 '23 13:06 fcollman

Thank you. I submitted a pull request.

Mijar007 avatar Jun 14 '23 14:06 Mijar007