Ejemplo n.º 1
0
        public void Test_GetStimulusWaveform_Plot()
        {
            string saveFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, "test_figures");

            if (!Directory.Exists(saveFolder))
            {
                Directory.CreateDirectory(saveFolder);
            }

            foreach (string abfPath in SampleData.GetAllAbfPaths())
            {
                var abf = new AbfSharp.ABFFIO.ABF(abfPath);
                Console.WriteLine($"\n{abf}");

                ScottPlot.MultiPlot mp = new(800, 800, 2, 1);
                for (int i = 0; i < abf.SweepCount; i++)
                {
                    float[] adc = abf.GetSweep(i);
                    float[] dac = abf.GetStimulusWaveform(i);
                    mp.subplots[0].AddSignal(ToDoubles(adc), color: System.Drawing.Color.Blue);
                    mp.subplots[1].AddSignal(ToDoubles(dac), color: System.Drawing.Color.Red);
                }

                string saveAs = Path.Combine(saveFolder, Path.GetFileNameWithoutExtension(abf.FilePath) + ".png");
                mp.subplots[0].Layout(left: 75, right: 10);
                mp.subplots[1].Layout(left: 75, right: 10);
                mp.SaveFig(saveAs);
                Console.WriteLine($"SAVED: {saveAs}");
            }
        }
Ejemplo n.º 2
0
        public void Test_Plot_SignalAndStimulus(string abfFilename)
        {
            string abfFilePath = SampleData.GetAbfPath(abfFilename);
            string abfFolder   = Path.GetDirectoryName(abfFilePath);

            var abf = new AbfSharp.ABFFIO.ABF(abfFilePath);

            Console.WriteLine($"\n{abf}");

            ScottPlot.MultiPlot mp = new(800, 600, 2, 1);
            for (int i = 0; i < abf.SweepCount; i++)
            {
                float[] adc = abf.GetSweep(i);
                float[] dac = abf.GetStimulusWaveform(i);
                mp.subplots[0].AddSignal(ToDoubles(adc), abf.SampleRate, color: System.Drawing.Color.Blue);
                mp.subplots[1].AddSignal(ToDoubles(dac), abf.SampleRate, color: System.Drawing.Color.Red);
            }

            mp.subplots[0].Layout(left: 75, right: 10);
            mp.subplots[0].AxisAuto(horizontalMargin: 0);
            mp.subplots[0].Title(abfFilename);
            mp.subplots[0].YLabel($"{abf.AdcNames[0]} ({abf.AdcUnits[0]})");
            mp.subplots[0].XLabel("Sweep Time (seconds)");

            mp.subplots[1].Layout(left: 75, right: 10);
            mp.subplots[1].AxisAuto(horizontalMargin: 0);
            mp.subplots[1].YLabel($"{abf.DacNames[0]} ({abf.DacUnits[0]})");
            mp.subplots[1].XLabel("Sweep Time (seconds)");

            string saveAs = Path.Combine(abfFolder, Path.GetFileNameWithoutExtension(abf.FilePath) + ".png");

            mp.SaveFig(saveAs);
            Console.WriteLine($"SAVED: {saveAs}");
        }
Ejemplo n.º 3
0
        public void Test_AllABfs_Load()
        {
            foreach (string abfPath in SampleData.GetAllAbfPaths())
            {
                var abf = new AbfSharp.ABFFIO.ABF(abfPath, preloadSweepData: false);
                Console.WriteLine($"\n{abf}");
                if (abf.Tags.Count > 0)
                {
                    Console.WriteLine($"TAGS: {abf.Tags}");
                }

                float[] adc = abf.GetSweep(0);
                Console.WriteLine("SWEEP: " + string.Join(", ", adc.Take(10).Select(x => x.ToString())));

                float[] dac = abf.GetStimulusWaveform(0);
                Console.WriteLine("STIM: " + string.Join(", ", dac.Take(10).Select(x => x.ToString())));

                if (abf.OperationMode != AbfSharp.OperationMode.EventDriven)
                {
                    Assert.AreEqual(adc.Length, dac.Length);
                }
            }
        }