Esempio n. 1
0
        /// <summary>
        /// Button: Load
        /// </summary>
        private void _btnLoad_Click_1(object sender, EventArgs e)
        {
            ClusterEvaluationPointer res = this.PickResults();

            if (res == null)
            {
                return;
            }

            ClusterEvaluationResults set = FrmWait.Show(this, "Loading results", null, z => this.LoadResults(res.FileName, z));

            if (res.Configuration == null)
            {
                // The results didn't have known config, they do now!
                this._core.EvaluationResultFiles.Remove(res);
                this._core.EvaluationResultFiles.Add(new ClusterEvaluationPointer(res.FileName, set.Configuration));

                FrmMsgBox.ShowInfo(this, "Imported results", "The details on this result set have been imported into the current session. You will have to save the session to view these details in future.", FrmMsgBox.EDontShowAgainId.ImportResultsDetailNotice);
            }

            if (set != null)
            {
                this.SelectResults(res.FileName, set);
            }
        }
Esempio n. 2
0
        private void updateResultsDataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EUpdateResults options = EnumHelper.SumEnum(DataSet.ForFlagsEnum <EUpdateResults>(this._core, "Batch Options").ShowCheckBox(this, null));

            if (options == EUpdateResults.None)
            {
                return;
            }

            IEnumerable <ClusterEvaluationPointer> tests = DataSet.ForTests(this._core).ShowCheckBox(this, null);

            if (tests == null)
            {
                return;
            }

            EClustererStatistics stats;

            if (options.Has(EUpdateResults.Statistics))
            {
                stats = EnumHelper.SumEnum(DataSet.ForFlagsEnum <EClustererStatistics>(this._core, "Statistics").ShowCheckBox(this, null));
            }
            else
            {
                stats = EClustererStatistics.None;
            }

            string log = FrmWait.Show <string>(this, "Batch Process", null, proggy => this.BatchProcess(options, tests, stats, proggy));

            FrmInputMultiLine.ShowFixed(this, this.Text, "Batch Process", "Results of the batch process", log);
        }
Esempio n. 3
0
        private void _btnOk_Click(object sender, EventArgs e)
        {
            this._uniqueTable.Reset();

            FrmWait.Show(this, "Exporting data", "Your data is being exported", this.ExportSelected);

            if (this._uniqueTable.Renamed.Count != 0)
            {
                string allRenames = string.Join("\r\n", this._uniqueTable.Renamed.Select(z => z.DisplayName + " --> " + this._uniqueTable.Name(z)).ToArray());
                FrmInputMultiLine.ShowFixed(this, this.Text, "Name clashes", null, "There are some objects with the same DisplayName. To avoid conflicts the objects were temporarily renamed. The new names are guaranteed to match for all tables exported in this instance, but may not match exports made at a later time.\r\n\r\n" + allRenames);
            }

            this.DialogResult = DialogResult.OK;
        }
Esempio n. 4
0
        /// <summary>
        /// Handles button: Save results
        /// </summary>
        private void _btnSave_Click(object sender, EventArgs e)
        {
            if (this._selectedResults == null)
            {
                return;
            }

            string fn = UiControls.BrowseForFile(this, null, UiControls.EFileExtension.EvaluationResults, FileDialogMode.SaveAs, UiControls.EInitialFolder.Evaluations);

            if (fn == null)
            {
                return;
            }

            FrmWait.Show(this, "Please wait", null, z => SaveResults(this._core, fn, null, this._selectedResults, z));

            FrmMsgBox.ShowInfo(this, "Export Notice", "Results have been exported. Exported data will only be compatible with the current data set.", FrmMsgBox.EDontShowAgainId.ExportDataNotice);
        }
Esempio n. 5
0
        private static object Show(Form owner, string title, string subtitle, Callable callable)
        {
            using (FrmWait frm = new FrmWait(title, subtitle, callable))
            {
                UiControls.ShowWithDim(owner, frm);

                if (callable.Error != null)
                {
                    if (callable.Error is TaskCanceledException)
                    {
                        throw new TaskCanceledException("The task was cancelled.", callable.Error);
                    }
                    else
                    {
                        throw new InvalidOperationException("The background process encountered an error: " + callable.Error.Message, callable.Error);
                    }
                }

                ShowLogMessage(owner, frm._prog.Logs);

                return(callable.Result);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Handles button: New test
        /// </summary>
        private void _btnNewTest_Click(object sender, EventArgs e)
        {
            if (DataSet.ForTests(this._core).ShowListEditor(this) == null)
            {
                return;
            }

            bool loop2 = false;

            while (this._core.EvaluationResultFiles.Any(z => !z.HasResults && !z.Hidden))
            {
                var toRun = this._core.EvaluationResultFiles.Where(z => !z.HasResults && !z.Hidden).ToArray();

                if (toRun.Length == 0)
                {
                    return;
                }

                MsgBoxButton[] buttons;
                string         msg;

                if (loop2)
                {
                    buttons = new MsgBoxButton[]
                    {
                        new MsgBoxButton("Continue", Resources.MnuAccept, DialogResult.Yes),
                        new MsgBoxButton("Later", Resources.MnuAdd, DialogResult.No),
                        new MsgBoxButton("Discard", Resources.MnuDelete, DialogResult.Abort),
                    };

                    msg = "An error occured but " + toRun.Length.ToString() + " tests are still queued. You can continue running them now, save them for later, or discard them.";
                }
                else
                {
                    buttons = new MsgBoxButton[]
                    {
                        new MsgBoxButton("Now", Resources.MnuAccept, DialogResult.Yes),
                        new MsgBoxButton("Later", Resources.MnuAdd, DialogResult.No)
                    };

                    msg = toRun.Length.ToString() + " tests are ready to run. You can save these for later or run them now.";
                }

                switch (FrmMsgBox.Show(this, "Save Tests", null, msg, Resources.MsgWarning, buttons))
                {
                case DialogResult.Yes:
                    break;

                case DialogResult.No:
                default:
                    return;

                case DialogResult.Abort:
                    this._core.EvaluationResultFiles.RemoveAll(test => !test.HasResults);
                    return;
                }

                if (this.Paranoid)
                {
                    if (string.IsNullOrWhiteSpace(this._core.FileNames.Session))
                    {
                        FrmMsgBox.ShowError(this, "The evaluations cannot be conducted because the session has not yet been saved. Please return to the main screen and save the session before continuing.");
                        return;
                    }
                    else if (!FrmMsgBox.ShowOkCancel(this, "Save Session", "To avoid data loss the current session must be saved. The current session is \"" + this._core.FileNames.Session + "\".", FrmMsgBox.EDontShowAgainId.SaveBetweenEvaluations, DialogResult.OK))
                    {
                        return;
                    }
                }

                this.BeginWait(this._tlpHeaderParams);

                try
                {
                    FrmWait.Show(this, "Please wait", null, z => RunTests(this._core, toRun, z, this.Paranoid));
                }
                catch (Exception ex)
                {
                    FrmMsgBox.ShowError(this, ex);
                }
                finally
                {
                    this.EndWait(this._tlpHeaderParams);
                }

                loop2 = true;
            }
        }
Esempio n. 7
0
        private void UpdateScores()
        {
            StringBuilder title = new StringBuilder();

            IntensityMatrix sourceMatrix = this._selectedCorrection.Provide;
            IntensityMatrix source       = sourceMatrix.Subset(this._peakFilter, this._obsFilter, ESubsetFlags.None);

            double[] plsrResponseMatrix = null;

            this._lblPcaSource.Text = this._transposeToShowPeaks ? "Peaks" : "Observations";
            this.transposeToShowObservationsToolStripMenuItem.Checked = !this._transposeToShowPeaks;
            this.transposeToShowPeaksToolStripMenuItem.Checked        = this._transposeToShowPeaks;

            this._lblObs.Text         = this._obsFilter.ToString();
            this._lblPeaks.Text       = this._peakFilter.ToString();
            this._lblCorrections.Text = this._selectedCorrection.ToString();

            this._lblMethod.Text   = this._method.ToString().ToUpper();
            this.ctlTitleBar1.Text = this._method.ToUiString();

            this._lblPlsrSource.Visible = this._mnuPlsrSource.Visible = this._method == EMethod.Plsr;

            int corIndex = IVisualisableExtensions.WhereEnabled(this._core.Corrections).IndexOf(this._selectedCorrection);

            Column plsrColumn;

            this.GetSource(this._regressAgainst, out plsrColumn);

            this._lblPlsrSource.Text = plsrColumn.DisplayName;

            double[,] valueMatrix = this._transposeToShowPeaks ? new double[source.NumRows, source.NumCols] : new double[source.NumCols, source.NumRows];

            for (int row = 0; row < source.NumRows; row++)
            {
                Vector vector = source.Vectors[row];

                int obsIndex = 0;

                for (int col = 0; col < source.NumCols; col++)
                {
                    if (this._transposeToShowPeaks)
                    {
                        valueMatrix[row, col] = source.Values[row, col];
                    }
                    else
                    {
                        valueMatrix[col, row] = source.Values[row, col];
                    }

                    ++obsIndex;
                }
            }

            this._pcaPeaks        = source.Rows.Select(z => z.Peak).ToArray();
            this._pcaObservations = source.Columns.Select(z => z.Observation).ToArray();

            if (this._method == EMethod.Plsr)
            {
                plsrResponseMatrix = new double[valueMatrix.GetLength(0)];

                IEnumerable rows;

                if (this._transposeToShowPeaks)
                {
                    rows = this._pcaPeaks;
                }
                else
                {
                    rows = this._pcaObservations;
                }

                IEnumerator en  = rows.GetEnumerator();
                Factoriser  fac = new Factoriser();

                for (int n = 0; n < plsrResponseMatrix.Length; n++)
                {
                    en.MoveNext();
                    object row = plsrColumn.GetRow((Visualisable)en.Current);
                    plsrResponseMatrix[n] = fac.Factor(row);
                }
            }

            try
            {
                switch (this._method)
                {
                case EMethod.Pca:
                    FrmWait.Show(this, "PCA", "Updating scores", () =>
                                 Arr.Instance.Pca(valueMatrix, out this._scores, out this._loadings));
                    break;

                case EMethod.Plsr:
                    FrmWait.Show(this, "PLSR", "Updating scores", () =>
                                 Arr.Instance.Plsr(valueMatrix, plsrResponseMatrix, out this._scores, out this._loadings));
                    break;

                default:
                    throw new SwitchException(this._method);
                }

                this._errorMessage = null;
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("there is no package called 'pls'"))
                {
                    this._errorMessage = "The 'pls' library for R is not installed on your system. Please install that library to use the PLS feature.";
                    FrmMsgBox.ShowError(this, this._errorMessage);
                }
                else
                {
                    this._errorMessage = ex.Message;
                }

                this._scores   = null;
                this._loadings = null;
            }

            this.UpdatePlot();
        }
Esempio n. 8
0
 public Info(FrmWait frmWait)
 {
     this._form = frmWait;
 }