示例#1
0
        private void SetFolder(string path, bool updateTree = true)
        {
            // stop people from clicking on a new path while this one is loading
            treeViewDirUC1.Enabled = false;

            if (updateTree)
            {
                // update the tree (will can an event to re-call fhis function)
                treeViewDirUC1.SelectPath(path);
                return;
            }

            lsFolder = new LineScanFolder(path, analyzeImmediately: false);
            UpdateGuiFromLinescanFirst();
            UpdateGuiFromLinescan();
            if (!lsFolder.isValid)
            {
                SaveNeeded(false);
            }
            if (lsFolder.isValid && System.IO.File.Exists(lsFolder.pathIniFile))
            {
                SaveNeeded(false);
            }

            // unlock the treeview
            treeViewDirUC1.Enabled = true;
        }
示例#2
0
        /// <summary>
        /// Load baseline, structure, and filter settings from LineScanSettings.ini in the linescan folder
        /// </summary>
        public static void Load(LineScanFolder ls)
        {
            if (!ls.isValid)
            {
                return;
            }

            if (!System.IO.File.Exists(ls.pathIniFile))
            {
                return;
            }

            foreach (string rawLine in System.IO.File.ReadAllLines(ls.pathIniFile))
            {
                string line = rawLine.Trim();
                if (line.StartsWith(";"))
                {
                    continue;
                }
                if (!line.Contains("="))
                {
                    continue;
                }
                string[] lineParts = line.Split('=');
                string   var       = lineParts[0];
                string   valStr    = lineParts[1];

                if (var == "baseline1")
                {
                    ls.baseline1 = int.Parse(valStr);
                }
                else if (var == "baseline2")
                {
                    ls.baseline2 = int.Parse(valStr);
                }
                else if (var == "structure1")
                {
                    ls.structure1 = int.Parse(valStr);
                }
                else if (var == "structure2")
                {
                    ls.structure2 = int.Parse(valStr);
                }
                else if (var == "filterPx")
                {
                    ls.filterPx = int.Parse(valStr);
                }
            }
        }
示例#3
0
        /// <summary>
        /// Default filter time and baseline duration for unanalyzed linescans is stored in an INI next to this EXE.
        /// </summary>
        public static void LoadDefaultSettings(LineScanFolder ls)
        {
            if (!ls.isValid)
            {
                return;
            }

            if (!System.IO.File.Exists(ls.pathProgramSettings))
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("; ScanAGator default settings");
                sb.AppendLine("baselineEndFrac = 0.10");
                sb.AppendLine(";filterTimeMs = 50.0");
                System.IO.File.WriteAllText(ls.pathProgramSettings, sb.ToString());
            }

            string raw = System.IO.File.ReadAllText(ls.pathProgramSettings);

            string[] lines = raw.Split('\n');
            foreach (string thisLine in lines)
            {
                string line = thisLine.Trim();
                if (line.StartsWith(";") || !line.Contains("="))
                {
                    continue;
                }
                string var = line.Split('=')[0].Trim();
                string val = line.Split('=')[1].Trim();

                if (var == "baselineEndFrac")
                {
                    ls.defaultBaselineEndFrac = double.Parse(val);
                }

                if (var == "filterTimeMs")
                {
                    ls.defaultFilterTimeMs = double.Parse(val);
                }
            }
        }
示例#4
0
        /// <summary>
        /// Save baseline, structure, and filter settings to LineScanSettings.ini in the linescan folder
        /// </summary>
        public static void Save(LineScanFolder ls)
        {
            if (!ls.isValid)
            {
                return;
            }

            if (!System.IO.Directory.Exists(ls.pathSaveFolder))
            {
                System.IO.Directory.CreateDirectory(ls.pathSaveFolder);
            }

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("; Scan-A-Gator Linescan Settings");
            sb.AppendLine($"version={ls.version}");
            sb.AppendLine($"baseline1={ls.baseline1}");
            sb.AppendLine($"baseline2={ls.baseline2}");
            sb.AppendLine($"structure1={ls.structure1}");
            sb.AppendLine($"structure2={ls.structure2}");
            sb.AppendLine($"filterPx={ls.filterPx}");

            System.IO.File.WriteAllText(ls.pathIniFile, sb.Replace("\n", "\r\n").ToString().Trim());
        }
示例#5
0
        public static string Text(LineScanFolder ls)
        {
            // name, unit, comment, data...
            int dataPoints = ls.imgG.height;
            string[] csvLines = new string[dataPoints + 3];

            // times (ms)
            csvLines[0] = "Time, ";
            csvLines[1] = "ms, ";
            csvLines[2] = ls.folderName + ", ";
            for (int i = 0; i < dataPoints; i++)
                csvLines[i + 3] = Math.Round(ls.timesMsec[i], 3).ToString() + ", ";

            // raw PMT values (R)
            if (ls.curveR != null)
            {
                csvLines[0] += "R, ";
                csvLines[1] += "AFU, ";
                csvLines[2] += ", ";
                for (int i = 0; i < dataPoints; i++)
                    csvLines[i + 3] += Math.Round(ls.curveR[i], 3).ToString() + ", ";
            }

            // raw PMT values (G)
            if (ls.curveG != null)
            {
                csvLines[0] += "G, ";
                csvLines[1] += "AFU, ";
                csvLines[2] += ", ";
                for (int i = 0; i < dataPoints; i++)
                    csvLines[i + 3] += Math.Round(ls.curveG[i], 3).ToString() + ", ";
            }

            // delta raw PMT values (G)
            if (ls.curveDeltaG != null)
            {
                csvLines[0] += "dG, ";
                csvLines[1] += "AFU, ";
                csvLines[2] += ", ";
                for (int i = 0; i < dataPoints; i++)
                    csvLines[i + 3] += Math.Round(ls.curveDeltaG[i], 3).ToString() + ", ";

                csvLines[0] += "f(dG), ";
                csvLines[1] += "AFU, ";
                csvLines[2] += "filtered, ";
                double[] filteredChopped = ls.GetFilteredYs(ls.curveDeltaG);
                double[] filtered = new double[dataPoints];
                for (int i = 0; i < dataPoints; i++)
                    filtered[i] = 0;
                Array.Copy(filteredChopped, 0, filtered, ls.filterPx * 2, filteredChopped.Length);
                for (int i = 0; i < dataPoints; i++)
                    if (i < ls.filterPx * 2 || i > (dataPoints - ls.filterPx * 2 * 2))
                        csvLines[i + 3] += ", ";
                    else
                        csvLines[i + 3] += Math.Round(filtered[i], 3).ToString() + ", ";
            }

            // Green over Red
            if (ls.curveGoR != null)
            {
                csvLines[0] += "G/R, ";
                csvLines[1] += "%, ";
                csvLines[2] += ", ";
                for (int i = 0; i < dataPoints; i++)
                    csvLines[i + 3] += Math.Round(ls.curveGoR[i], 3).ToString() + ", ";
            }

            // Delta Green over Red
            if (ls.curveDeltaGoR != null)
            {
                csvLines[0] += "dG/R, ";
                csvLines[1] += "%, ";
                csvLines[2] += ", ";
                for (int i = 0; i < dataPoints; i++)
                    csvLines[i + 3] += Math.Round(ls.curveDeltaGoR[i], 3).ToString() + ", ";

                csvLines[0] += "f(dG/R), ";
                csvLines[1] += "AFU, ";
                csvLines[2] += "filtered, ";
                double[] filteredChopped = ls.GetFilteredYs(ls.curveDeltaGoR);
                double[] filtered = new double[dataPoints];
                for (int i = 0; i < dataPoints; i++)
                    filtered[i] = 0;
                Array.Copy(filteredChopped, 0, filtered, ls.filterPx * 2, filteredChopped.Length);
                for (int i = 0; i < dataPoints; i++)
                    if (i < ls.filterPx * 2 || i > (dataPoints - ls.filterPx * 2 * 2))
                        csvLines[i + 3] += ", ";
                    else
                        csvLines[i + 3] += Math.Round(filtered[i], 3).ToString() + ", ";
            }

            // convert to CSV
            string csv = "";
            foreach (string line in csvLines)
                csv += line + "\n";
            return csv;
        }