Пример #1
0
        private void LoadABF(string path)
        {
            // setup the voltage plot
            path         = Path.GetFullPath(path);
            lblPath.Text = path;
            var abf = new AbfSharp.ABF(path);

            V = abf.ReadAllSweeps();
            formsPlot1.Plot.AddSignal(V, SAMPLE_RATE, Color.Blue);
            Vline1 = formsPlot1.Plot.AddVerticalLine(0, Color.Black, style: ScottPlot.LineStyle.Dash);
            formsPlot1.Plot.AxisAuto(horizontalMargin: 0);
            formsPlot1.Plot.YLabel("mV");

            // setup the dVdt plot
            DVDT = new double[V.Length];
            for (int i = 1; i < V.Length; i++)
            {
                DVDT[i] = (V[i] - V[i - 1]) * (SAMPLE_RATE / 1000);
            }
            DVDT[0] = DVDT[1];
            formsPlot2.Plot.AddSignal(DVDT, SAMPLE_RATE, Color.Red);
            Vline2 = formsPlot2.Plot.AddVerticalLine(0, Color.Black, style: ScottPlot.LineStyle.Dash);
            formsPlot2.Plot.AxisAuto(horizontalMargin: 0);
            formsPlot2.Plot.YLabel("mV/ms");

            // setup the phase plot
            Sp        = formsPlot3.Plot.AddScatterLines(V, DVDT, Color.Gray);
            Highlight = formsPlot3.Plot.AddPoint(0, 0, Color.Black, 10, ScottPlot.MarkerShape.filledCircle);
            formsPlot3.Render(lowQuality: true);
            formsPlot3.Plot.XLabel("mV");
            formsPlot3.Plot.YLabel("mV/ms");
        }
Пример #2
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}, ");
            }
        }
Пример #3
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);
            }
        }
Пример #4
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);
                }
            }
        }
Пример #5
0
        public void Test_MatchesOfficial_DataScalingVariables()
        {
            foreach (AbfSharp.ABFFIO.ABF official in OfficialABFs)
            {
                Console.WriteLine($"v={official.Header.fFileVersionNumber:0.0} {System.IO.Path.GetFileName(official.FilePath)}");
                var raw = new AbfSharp.ABF(official.FilePath);

                for (int i = 0; i < 8; i++)
                {
                    Assert.AreEqual(official.Header.fInstrumentOffset[i], raw.Header.fInstrumentOffset[i]);
                    Assert.AreEqual(official.Header.fSignalOffset[i], raw.Header.fSignalOffset[i]);
                    Assert.AreEqual(official.Header.fInstrumentScaleFactor[i], raw.Header.fInstrumentScaleFactor[i]);
                    Assert.AreEqual(official.Header.fSignalGain[i], raw.Header.fSignalGain[i]);
                    Assert.AreEqual(official.Header.fADCProgrammableGain[i], raw.Header.fADCProgrammableGain[i]);
                    Assert.AreEqual(official.Header.lADCResolution, raw.Header.lADCResolution);
                    Assert.AreEqual(official.Header.fADCRange, raw.Header.fADCRange);
                    Assert.AreEqual(official.Header.nTelegraphEnable[i], raw.Header.nTelegraphEnable[i]);
                    Assert.AreEqual(official.Header.fTelegraphAdditGain[i], raw.Header.fTelegraphAdditGain[i]);
                }
            }
        }