Beispiel #1
0
        private void cbReadProfileTfs_Click(object sender, EventArgs e)
        {
            if (m_reader == null)
            {
                MessageBox.Show("File is not open");
                return;
            }
            if (!m_reader.HasProfileTfsSpectra)
            {
                MessageBox.Show("This files doesn't have profile Total Frame Sepctra");
                return;
            }


            int reps = 1;

            int.TryParse(txtReps.Text, out reps);

            // Get m/z ranges
            m_doTic    = rbChroTic.Checked;
            m_mzRanges = new List <IDoubleRange>();
            if (m_doTic)
            {
                double maxMz = m_reader.FileInfo.MaxFlightTimeBin;
                m_reader.FileUnitConverter.Convert(MidacUnits.FlightTimeBinIndex, MidacUnits.MassToCharge, ref maxMz);

                m_mzRanges.Add(new DoubleRange(5.0, maxMz, MidacUnits.MassToCharge));
            }
            else
            {
                IDoubleRange dr = GetMzRange(txtEic1.Text);
                if (!DoubleRange.IsNullOrEmpty(dr))
                {
                    m_mzRanges.Add(dr);
                }

                dr = GetMzRange(txtEic2.Text);
                if (!DoubleRange.IsNullOrEmpty(dr))
                {
                    m_mzRanges.Add(dr);
                }

                dr = GetMzRange(txtEic3.Text);
                if (!DoubleRange.IsNullOrEmpty(dr))
                {
                    m_mzRanges.Add(dr);
                }

                dr = GetMzRange(txtEic4.Text);
                if (!DoubleRange.IsNullOrEmpty(dr))
                {
                    m_mzRanges.Add(dr);
                }

                dr = GetMzRange(txtEic5.Text);
                if (!DoubleRange.IsNullOrEmpty(dr))
                {
                    m_mzRanges.Add(dr);
                }
            }

            m_ftBinRanges = new List <IIntRange>();
            IMidacUnitConverter converter = m_reader.FileUnitConverter;

            foreach (IDoubleRange mzRange in m_mzRanges)
            {
                IDoubleRange mzClone = mzRange.Clone();
                converter.Convert(MidacUnits.FlightTimeBinIndex, ref mzClone);
                m_ftBinRanges.Add(new IntRange((int)mzClone.Min, (int)mzClone.Max));
            }

            try
            {
                cbBrowse.Enabled         = false;
                cbOpen.Enabled           = false;
                cbReadProfileTfs.Enabled = false;
                cbReadFrameMs.Enabled    = false;
                gbProfileTfsFmt.Enabled  = false;

                int[] frameNumbers = null;
                if (rbAllIonsHigh.Enabled)
                {
                    IMidacMsFiltersChrom chromFilters = MidacFileAccess.DefaultMsChromFilters;
                    if (rbAllIonsHigh.Checked)
                    {
                        chromFilters.ApplicableFilters  = ApplicableFilters.FragmentationClass;
                        chromFilters.FragmentationClass = FragmentationClass.HighEnergy;
                    }
                    else if (rbAllIonsLow.Checked)
                    {
                        chromFilters.ApplicableFilters  = ApplicableFilters.FragmentationClass;
                        chromFilters.FragmentationClass = FragmentationClass.LowEnergy;
                    }
                    frameNumbers = m_reader.FilteredFrameNumbers(chromFilters);
                }
                else
                {
                    frameNumbers = new int[m_reader.FileInfo.NumFrames];
                    for (int i = 0; i < frameNumbers.Length; i++)
                    {
                        frameNumbers[i] = i + 1;
                    }
                }

                Stopwatch sw = new Stopwatch();
                sw.Reset();

                lbStatus.Text = "Processing";
                this.Refresh();

                m_msCount     = 0;
                m_tic         = 0.0;
                m_sumPoints   = 0;
                m_sumNzPoints = 0;

                for (int i = reps; i > 0; i--)
                {
                    if (rbProfTfsFrameInfo.Checked)
                    {
                        ReadFrameInfo(ref sw, frameNumbers);
                    }

#if ENABLE_MHDAC_TESTS
                    if (rbProfTfsMhdac.Checked)
                    {
                        ReadProfTfsMhdac(ref sw, frameNumbers);
                    }
#endif

                    if (rbProfTfsMidacSpecDataExternal.Checked)
                    {
                        ReadProfTfsMidacSpecDataExternal(MidacSpecFormat.Profile, ref sw, frameNumbers);
                    }

                    if (rbProfZtTfsMidacSpecDataExternal.Checked)
                    {
                        ReadProfTfsMidacSpecDataExternal(MidacSpecFormat.ZeroTrimmed, ref sw, frameNumbers);
                    }

                    if (rbProfZbTfsMidacSpecDataExternal.Checked)
                    {
                        ReadProfTfsMidacSpecDataExternal(MidacSpecFormat.ZeroBounded, ref sw, frameNumbers);
                    }

                    if (rbProfMdTfsMidacSpecDataExternal.Checked)
                    {
                        ReadProfTfsMidacSpecDataExternal(MidacSpecFormat.Metadata, ref sw, frameNumbers);
                    }

                    if (rbReadTic.Checked)
                    {
                        ReadTic(ref sw, frameNumbers);
                    }
#if INTERNAL_TEST
                    // placeholder for internal tests
#endif
                }

                double ticks        = sw.ElapsedTicks;
                double ticksPerSec  = Stopwatch.Frequency;
                double milliseconds = 1000.0 * ticks / ticksPerSec / reps;
                m_tic         /= reps;
                m_sumPoints   /= reps;
                m_sumNzPoints /= reps;
                m_msCount     /= reps;

                if (rbProfTfsFrameInfo.Checked)
                {
                    lbStatus.Text = string.Format("Done in {0:F3} ms ({1:F3} us/frame; {2} non-empty frames)",
                                                  milliseconds,
                                                  1000 * milliseconds / m_msCount,
                                                  m_msCount);
                }
                else if (rbReadTic.Checked)
                {
                    lbStatus.Text = string.Format("Done in {0:F3} ms; (TIC = {1})",
                                                  milliseconds,
                                                  m_tic);
                }
                else
                {
                    if (chkTfsDoSumming.Checked && !rbProfMdTfsMidacSpecDataExternal.Checked)
                    {
                        lbStatus.Text =
                            string.Format("Done in {0:##,0.###} ms ({1:##,0.###} us/frame; {2:##,0} non-empty spectra; TIC = {3:##,#}; Points = {4:##,0}; NZ = {5:##,0})",
                                          milliseconds,
                                          1000 * milliseconds / m_msCount,
                                          m_msCount,
                                          m_tic,
                                          m_sumPoints,
                                          m_sumNzPoints);
                    }
                    else
                    {
                        // no TIC value
                        lbStatus.Text =
                            string.Format("Done in {0:##,0.###} ms ({1:##,0.###} us/frame; {2:##,0} non-empty spectra; Points = {3:##,0}; NZ = {4:##,0})",
                                          milliseconds,
                                          1000 * milliseconds / m_msCount,
                                          m_msCount,
                                          m_sumPoints,
                                          m_sumNzPoints);
                    }
                }
            }
            finally
            {
                cbBrowse.Enabled         = true;
                cbOpen.Enabled           = true;
                cbReadProfileTfs.Enabled = true;
                cbReadFrameMs.Enabled    = true;
                gbProfileTfsFmt.Enabled  = true;
            }
        }