示例#1
0
        public void Test_Quickstart_Native()
        {
            string abfPath = SampleData.GetAbfPath("File_axon_5.abf");
            var    abf     = new AbfSharp.ABF(abfPath);

            float[] sweep = abf.GetSweep(0);
            for (int i = 0; i < 5; i++)
            {
                Console.Write($"{sweep[i]:0.000}, ");
            }
        }
示例#2
0
        public void Test_FirstSweep_FirstChannel_FirstFiveValues(string filename, double[] expectedFirstValues)
        {
            string abfPath = SampleData.GetAbfPath(filename);
            var    abf     = new AbfSharp.ABF(abfPath);

            float[] sweepValues = abf.GetSweep(0);

            for (int i = 0; i < expectedFirstValues.Length; i++)
            {
                Assert.AreEqual(expectedFirstValues[i], sweepValues[i], 1e-3);
            }
        }
示例#3
0
        public void Test_MatchesOfficial_SweepValues()
        {
            foreach (AbfSharp.ABFFIO.ABF official in OfficialABFs)
            {
                var raw = new AbfSharp.ABF(official.FilePath, preloadData: true);

                // Don't compare ABF1 GapFree ABFs because ABFFIO freaks out
                if (raw.Header.OperationMode == AbfSharp.OperationMode.GapFree && raw.Header.Version < 2)
                {
                    continue;
                }

                // Don't compare EventDriven sweeps because ABFFIO returns fixed-length sweeps
                // whereas I simply return each event's data as a sweep.
                if (raw.Header.OperationMode == AbfSharp.OperationMode.EventDriven)
                {
                    continue;
                }

                Console.WriteLine(raw);
                int channelIndex = raw.Header.ChannelCount - 1;
                int sweepIndex   = raw.Header.SweepCount - 1;

                if (raw.Header.OperationMode == AbfSharp.OperationMode.GapFree)
                {
                    sweepIndex = 0;
                }

                float[] officialValues = official.GetSweep(sweepIndex, channelIndex);
                Assert.IsNotNull(officialValues);
                Assert.IsNotEmpty(officialValues);

                float[] rawValues = raw.GetSweep(sweepIndex, channelIndex);
                Assert.IsNotNull(rawValues);
                Assert.IsNotEmpty(rawValues);

                if (raw.Header.OperationMode != AbfSharp.OperationMode.GapFree)
                {
                    Assert.AreEqual(officialValues.Length, rawValues.Length);
                }

                for (int i = 0; i < 10; i++)
                {
                    Assert.AreEqual(officialValues[i], rawValues[i], 1e-3);
                }
            }
        }