Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative way to get offset before first "epoch" in axon protocol conversion #1305

Open
MichaelClerx opened this issue Jul 12, 2023 · 1 comment
Milestone

Comments

@MichaelClerx
Copy link

At the moment Neo uses a slightly "magic" equation to work out the (undocumented) time spent at holding potential before the first "epoch" of a protocol starts:

# Save last sample index
i_last = int(nSam * 15625 / 10 ** 6)
# TODO guess for first holding

Digging into the File Support Pack 1 for Windows for the old ABF 1.x format, there's a method inside AxonDev/Comp/AxAbfFio32/ABFHWAVE.CPP (which I guess deals with "waveforms", a.k.a. D/A protocol outputs) called _GetHoldingLength():

//===============================================================================================
// FUNCTION: GetHoldingLength
// PURPOSE:  Get the duration of the first/last holding period.
//
static int _GetHoldingLength(int nSweepLength, int nNumChannels)
{
   ASSERT((nSweepLength % nNumChannels)==0);

   // Calculate holding count.
   int nHoldingCount = nSweepLength / ABFH_HOLDINGFRACTION;

   // Round down to nearest sequence length.
   nHoldingCount -= nHoldingCount % nNumChannels;

   // If less than one sequence, round up to one sequence.
   if (nHoldingCount < nNumChannels)
      nHoldingCount = nNumChannels;

   return nHoldingCount;
}

where ABFH_HOLDINGFRACTION is a macro defined as 64 and where I'm guessing nNumChannels is the number of AD (not DA) channels.

I've tried for a few files and it seems to give the same result as the current code. Don't want to fix what isn't broken, but perhaps good to try out?

The next function down, ABFH_GetHoldingDuration, suggests a difference for "old" versions of the format (but given that these were "old" in 2000, maybe that's ok)

Note that the file starts with

// Copyright (c) 1993-2000 Axon Instruments.
// All rights reserved.
// Permission is granted to freely to use, modify and copy the code in this file.

@JuliaSprenger
Copy link
Member

Hi @MichaelClerx. Thanks for digging into the Axon format and looking for potential bugs in Neo.
If the current code is already loading the file correctly I don't think it's necessary to change it. If you find it important, feel free to open a PR and include a corresponding test in the our code base here.

@JuliaSprenger JuliaSprenger added this to the future milestone Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants