//Filename: xx-abfheadr.cxx //Author: Pamela Y. C. Fong //Maintainer: Qi Huang //PI: Henry A. Lester //Organization: California Institute of Technology // // Reformulated and adapted from API copyrighted // by Axon Instruments, Inc. // //Created: February 12, 2004 //Last Modified: Mon Mar 1 13:15:46 PST 2004 // //This code was created by modifying excerpts copied from Axon API file, ABFHEADR.CPP //PYCF #include "xx-abfheadr.h" //============================================================================================== // FUNCTION: GetADCtoUUFactors // PURPOSE: Calculates the scaling factors used to convert ADC values to UserUnits. // PARAMETERS: // nChannel - The physical channel number to get the factors for. // pfADCToUUFactor - Pointers to return locations for scale and offset. // pfADCToUUShift UserUnits = ADCValue * fADCToUUFactor + fADCToUUShift; // void ABFH_GetADCtoUUFactors(const ABFFileHeader *pFH, int nChannel, float *pfADCToUUFactor, float *pfADCToUUShift ) { float fTotalScaleFactor = pFH->fInstrumentScaleFactor[nChannel] * pFH->fADCProgrammableGain[nChannel]; if (pFH->nSignalType != 0) fTotalScaleFactor *= pFH->fSignalGain[nChannel]; // Adjust for the telegraphed gain. if( pFH->nTelegraphEnable[nChannel] ) fTotalScaleFactor *= pFH->fTelegraphAdditGain[nChannel]; if (fTotalScaleFactor==0.0F) fTotalScaleFactor = 1.0F; // InputRange and InputOffset is the range and offset of the signal in // user units when it hits the Analog-to-Digital converter float fInputRange = pFH->fADCRange / fTotalScaleFactor; float fInputOffset= -pFH->fInstrumentOffset[nChannel]; if (pFH->nSignalType != 0) fInputOffset += pFH->fSignalOffset[nChannel]; *pfADCToUUFactor = fInputRange / pFH->lADCResolution; *pfADCToUUShift = -fInputOffset; }