public Tags(ABFFIO.TagStruct[] tagStructs, ABFFIO.AbfFileHeader header) { float sampleRate = 1e6f / header.fADCSequenceInterval / header.nADCNumChannels; float samplePeriod = 1.0f / sampleRate; float tagTimeMult = (header.fSynchTimeUnit == 0) ? samplePeriod / header.nADCNumChannels : header.fSynchTimeUnit / 1e6f; IndividualTags = tagStructs.Select(x => new Tag(x, tagTimeMult)).ToArray(); }
/// <summary> /// Load an ABF using the official library (ABFFIO.DLL) /// </summary> /// <param name="filePath">Path to the ABF</param> /// <param name="preloadSweepData">If True, sweep data will be loaded into memory up-front for faster (filesystem-free) access later</param> public ABF(string filePath, bool preloadSweepData = true) { FilePath = System.IO.Path.GetFullPath(filePath); using Wrapper abffio = new(filePath); Header = abffio.GetHeader(); Tags = new Tags(abffio.ReadTags(), Header); SweepData = new float[SweepCount * ChannelCount][]; if (preloadSweepData) { LoadAllSweeps(abffio); } }
private static extern bool ABF_ReadChannel(Int32 nFile, ref AbfFileHeader pFH, Int32 nChannel, Int32 dwEpisode, ref float pfBuffer, ref UInt32 puNumSamples, ref Int32 pnError);
private static extern bool ABF_ReadTags(Int32 nFile, ref AbfFileHeader pFH, UInt32 dwFirstTag, ref TagStruct pTagArray, UInt32 uNumTags, ref Int32 pnError);
private static extern bool ABF_ReadOpen(String szFileName, ref Int32 phFile, UInt32 fFlags, ref AbfFileHeader pFH, ref UInt32 puMaxSamples, ref UInt32 pdwMaxEpi, ref Int32 pnError);
private static extern float ABF_GetWaveform(Int32 fileHandle, ref AbfFileHeader pFH, Int32 nChannel, Int32 sweep, ref float pfBuffer, ref Int32 pnError);
private static extern bool ABFH_GetEpochLimits(ref AbfFileHeader pFH, Int32 nADCChannel, Int32 uDACChannel, Int32 dwEpisode, Int32 nEpoch, ref UInt32 puEpochStart, ref UInt32 puEpochEnd, ref Int32 pnError);
private static extern float ABFH_GetEpochLevel(ref AbfFileHeader pFH, Int32 nChannel, Int32 dwEpisode, Int32 nEpoch);
private static extern int ABFH_GetEpochDuration(ref AbfFileHeader pFH, Int32 nChannel, Int32 dwEpisode, Int32 nEpoch);