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}"); } }
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}"); }
public void Test_Quickstart_Official() { string abfPath = SampleData.GetAbfPath("File_axon_5.abf"); var abf = new AbfSharp.ABFFIO.ABF(abfPath); float[] sweep = abf.GetSweep(0); for (int i = 0; i < 5; i++) { Console.Write($"{sweep[i]:0.000}, "); } }
static void Main(string[] args) { string thisFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(typeof(Program)).Location); Console.WriteLine(thisFolder); string abfFolder = Path.GetFullPath(thisFolder + "/../../../../../data/abfs"); string[] abfPaths = Directory.GetFiles(abfFolder, "*.*").Where(x => x.EndsWith(".abf")).ToArray(); foreach (string abfPath in abfPaths) { var abf = new AbfSharp.ABFFIO.ABF(abfPath); double[] firstValues = new double[abf.Header.nADCNumChannels]; for (int i = 0; i < abf.Header.nADCNumChannels; i++) { double[] sweep = abf.GetSweep(sweepIndex: 0, channelIndex: i); firstValues[i] = sweep[0]; } string values = string.Join(", ", firstValues.Select(x => $"{x:0.00000}")); string abfid = Path.GetFileNameWithoutExtension(abfPath); string line = $"FIRSTVALUES['{abfid}'] = [{values}]"; Console.WriteLine(line); } }
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); } } }