예제 #1
0
 private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     abf = new ABF(listBox1.SelectedValue.ToString());
     nudSweep.Maximum = abf.sweepCount - 1;
     nudSweep.Value   = 0;
     Replot();
 }
예제 #2
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            richTextBox1.Clear();
            ABF abf = new ABF(listBox1.SelectedValue.ToString());

            richTextBox1.Text = abf.GetAbfInfo();
        }
예제 #3
0
        public DataTable AbfTable(string abfFolder)
        {
            if (!System.IO.Directory.Exists(abfFolder))
            {
                return(null);
            }

            DataTable table = new DataTable();

            table.Columns.Add("abfID", typeof(string));
            table.Columns.Add("path", typeof(string));
            table.Columns.Add("protocol", typeof(string));
            table.Columns.Add("sweepCount", typeof(int));
            table.Columns.Add("channelCount", typeof(int));
            table.Columns.Add("lengthSec", typeof(double));
            table.Columns.Add("units", typeof(string));
            table.Columns.Add("tags", typeof(string));

            string[] filePaths = System.IO.Directory.GetFiles(abfFolder, "*.abf");
            foreach (string filePath in filePaths)
            {
                ABF    abf       = new ABF(filePath, false);
                string protocol  = System.IO.Path.GetFileNameWithoutExtension(abf.protocolPath);
                double lengthSec = abf.dataPointCount / abf.dataRate;
                string units     = String.Join(", ", abf.adcUnits);
                string tags      = String.Join(", ", abf.tagComments);
                table.Rows.Add(abf.abfID, abf.abfFilePath, protocol, abf.sweepCount, abf.channelCount, lengthSec, units, tags);
            }

            return(table);
        }
예제 #4
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}");
                }
            }
        }
예제 #5
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;
        }
예제 #6
0
파일: Form1.cs 프로젝트: decacent/vsABF
 public void LoadABF(string abfFileName)
 {
     abf = new ABF(abfFileName);
     richTextBox1.Text += abf.Info();
 }