Exemple #1
0
        static void Convert(string pathIn, string pathOut, string format)
        {
            Console.WriteLine($"Reading data from {System.IO.Path.GetFileName(pathIn)}...");

            using (var abf = new ABF(pathIn))
            {
                Console.WriteLine(abf);

                float[][] sweepValues = new float[abf.SweepCount][];
                for (int i = 0; i < abf.SweepCount; i++)
                {
                    sweepValues[i] = abf.GetSweep(i);
                }

                Console.WriteLine($"Creating {System.IO.Path.GetFileName(pathOut)}...");

                if (format == "CSV")
                {
                    Export.CSV(sweepValues, pathOut, abf.SampleRate, abf.SweepStartTimes);
                }
                else if (format == "TSV")
                {
                    Export.TSV(sweepValues, pathOut, abf.SampleRate, abf.SweepStartTimes);
                }
                else if (format == "ATF")
                {
                    Export.ATF(sweepValues, pathOut, abf.SampleRate, abf.SweepStartTimes);
                }
                else
                {
                    throw new NotImplementedException($"Unsupported output format {format}");
                }
            }
        }
Exemple #2
0
        private void btnConvert_Click(object sender, EventArgs e)
        {
            Enabled = false;

            if (!Directory.Exists(tbOutFolder.Text))
            {
                Directory.CreateDirectory(tbOutFolder.Text);
            }

            progress.Maximum = lbABFs.Items.Count;
            for (int i = 0; i < lbABFs.Items.Count; i++)
            {
                string abfPath = lbABFs.Items[i].ToString();
                string abfID   = Path.GetFileNameWithoutExtension(abfPath);
                lblStatus.Text = $"Converting {abfID}.abf...";
                progress.Value = i + 1;
                Application.DoEvents();

                var       abf         = new ABF(abfPath);
                float[][] sweepValues = new float[abf.SweepCount][];
                for (int j = 0; j < abf.SweepCount; j++)
                {
                    sweepValues[j] = abf.GetSweep(j);
                }

                if (rbCSV.Checked)
                {
                    string pathOut = Path.Combine(tbOutFolder.Text, abfID + ".csv");
                    Export.CSV(sweepValues, pathOut, abf.SampleRate, abf.SweepStartTimes);
                }
                else if (rbTSV.Checked)
                {
                    string pathOut = Path.Combine(tbOutFolder.Text, abfID + ".tsv");
                    Export.TSV(sweepValues, pathOut, abf.SampleRate, abf.SweepStartTimes);
                }
                else if (rbATF.Checked)
                {
                    string pathOut = Path.Combine(tbOutFolder.Text, abfID + ".atf");
                    Export.ATF(sweepValues, pathOut, abf.SampleRate, abf.SweepStartTimes);
                }
            }

            progress.Value = 0;
            lblStatus.Text = $"Finished converting {lbABFs.Items.Count} ABFs.";
            Enabled        = true;
        }