Exemplo n.º 1
0
        private void SetSpectraUI(MsDataSpectrum[] spectra)
        {
            _msDataFileScanHelper.MsDataSpectra = spectra;
            _heatMapData = null;
            if (_msDataFileScanHelper.MsDataSpectra == null)
                return;

            // Find max values.
            _maxMz = 0;
            _maxIntensity = 0;
            GetMaxMzIntensity(out _maxMz, out _maxIntensity);
            _maxDriftTime = 0;
            foreach (var spectrum in spectra)
                _maxDriftTime = Math.Max(_maxDriftTime, spectrum.DriftTimeMsec ?? 0);

            if (_zoomXAxis)
            {
                _zoomXAxis = false;
                ZoomXAxis();
            }
            if (_zoomYAxis)
            {
                _zoomYAxis = false;
                ZoomYAxis();
            }
            CreateGraph();
            UpdateUI();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create a drift time heat map graph.
        /// </summary>
        private void CreateDriftTimeHeatmap()
        {
            GraphPane.YAxis.Title.Text = Resources.GraphFullScan_CreateDriftTimeHeatmap_Drift_Time__ms_;
            graphControl.IsEnableVZoom = graphControl.IsEnableVPan = true;

            if (_heatMapData == null)
            {
                var points = new List<Point3D>(5000);
                foreach (var scan in _msDataFileScanHelper.MsDataSpectra)
                {
                    if (!scan.DriftTimeMsec.HasValue)
                        continue;
                    for (int j = 0; j < scan.Mzs.Length; j++)
                        points.Add(new Point3D(scan.Mzs[j], scan.DriftTimeMsec.Value, scan.Intensities[j]));
                }
                _heatMapData = new HeatMapData(points);
            }

            double minDrift;
            double maxDrift;
            _msDataFileScanHelper.GetDriftRange(out minDrift, out maxDrift, _msDataFileScanHelper.Source);  // There may be a different drift time filter for products in Waters

            if (minDrift > 0 && maxDrift < double.MaxValue)
            {
                // Add gray shaded box behind heat points.
                var driftTimeBox = new BoxObj(
                    0.0,
                    maxDrift,
                    1.0,
                    maxDrift - minDrift,
                    Color.Transparent,
                    Color.FromArgb(50, Color.Gray))
                {
                    Location = {CoordinateFrame = CoordType.XChartFractionYScale},
                    ZOrder = ZOrder.F_BehindGrid,
                    IsClippedToChartRect = true,
                };
                GraphPane.GraphObjList.Add(driftTimeBox);

                // Add outline in front of heat points, so you can tell where the limits are in a dense graph.
                var driftTimeOutline = new BoxObj(
                    0.0,
                    maxDrift,
                    1.0,
                    maxDrift - minDrift,
                    Color.FromArgb(50, Color.DarkViolet),
                    Color.Transparent)
                {
                    Location = {CoordinateFrame = CoordType.XChartFractionYScale},
                    ZOrder = ZOrder.C_BehindChartBorder,
                    IsClippedToChartRect = true,
                    Border = new Border(Color.FromArgb(100, Color.DarkViolet), 2)
                };
                GraphPane.GraphObjList.Add(driftTimeOutline);
            }

            if (!Settings.Default.FilterDriftTimesFullScan)
            {
                minDrift = 0;
                maxDrift = double.MaxValue;
            }
            var heatMapGraphPane = (HeatMapGraphPane)GraphPane;
            heatMapGraphPane.SetPoints(_heatMapData, minDrift, maxDrift);
        }
Exemplo n.º 3
0
 public void SetPoints(HeatMapData heatMapData, double yMin, double yMax)
 {
     _heatMapData = heatMapData;
     _yMin        = (float)yMin;
     _yMax        = (float)Math.Min(yMax, float.MaxValue);
 }
Exemplo n.º 4
0
        public static void GraphHeatMap(GraphPane graphPane, HeatMapData heatMapData, int maxDotRadius, int minDotRadius, float yMin, float yMax, bool logScale, int cutoff)
        {
            graphPane.CurveList.Clear();
            graphPane.XAxis.Scale.SetupScaleData(graphPane, graphPane.XAxis);
            graphPane.YAxis.Scale.SetupScaleData(graphPane, graphPane.YAxis);
            double cellWidth  = Math.Abs(graphPane.XAxis.Scale.ReverseTransform(minDotRadius) - graphPane.XAxis.Scale.ReverseTransform(0));
            double cellHeight = Math.Abs(graphPane.YAxis.Scale.ReverseTransform(minDotRadius) - graphPane.YAxis.Scale.ReverseTransform(0));

            if (cellWidth <= 0 || double.IsNaN(cellWidth) || cellHeight <= 0 || double.IsNaN(cellHeight))
            {
                return;
            }

            // Use log scale for heat intensity.
            double scale = (_heatMapColors.Length - 1) /
                           (logScale ? Math.Log(heatMapData.MaxPoint.Point.Z) : heatMapData.MaxPoint.Point.Z);

            // Create curves for each intensity color.
            var curves = new LineItem[_heatMapColors.Length];

            for (int i = 0; i < curves.Length; i++)
            {
                var color = _heatMapColors[i];
                curves[i] = new LineItem(string.Empty)
                {
                    Line = new Line {
                        IsVisible = false
                    },
                    Symbol = new Symbol
                    {
                        Border = new Border {
                            IsVisible = false
                        },
                        Size        = (int)(minDotRadius + i / (double)(curves.Length - 1) * (maxDotRadius - minDotRadius)),
                        Fill        = new Fill(color),
                        Type        = SymbolType.Circle,
                        IsAntiAlias = true
                    },
                    Tag = new List <object>()
                };
                if ((i + 1) % (_heatMapColors.Length / 4) == 0)
                {
                    double intensity = logScale ? Math.Pow(Math.E, i / scale) : i / scale;
                    curves[i].Label.Text = intensity.ToString(@"F0");
                }
                graphPane.CurveList.Insert(0, curves[i]);
            }

            // Get points within bounds of graph/filter, with density appropriate for the current display resolution.
            var points = heatMapData.GetPoints(
                graphPane.XAxis.Scale.Min,
                graphPane.XAxis.Scale.Max,
                Math.Min(graphPane.YAxis.Scale.Min, yMin),
                Math.Max(graphPane.YAxis.Scale.Max, yMax),
                cellWidth,
                cellHeight);

            foreach (var heatPoint in points)
            {
                // A log scale produces a better visual display.
                int intensity = (int)((logScale ? Math.Log(heatPoint.Point.Z) : heatPoint.Point.Z) * scale);
                if (intensity >= cutoff)
                {
                    curves[intensity].AddPoint(heatPoint.Point.X, heatPoint.Point.Y);
                    ((List <object>)curves[intensity].Tag).Add(heatPoint.Tag);
                }
            }
        }
Exemplo n.º 5
0
 public void SetPoints(HeatMapData heatMapData, double yMin, double yMax)
 {
     _heatMapData = heatMapData;
     _yMin = (float) yMin;
     _yMax = (float) Math.Min(yMax, float.MaxValue);
 }