public IsolationWindow(EditIsolationWindow isolationWindow) { Start = isolationWindow.Start.HasValue ? isolationWindow.Start.Value : TransitionFullScan.MIN_RES_MZ; End = isolationWindow.End.HasValue ? isolationWindow.End.Value : TransitionFullScan.MAX_RES_MZ; Target = isolationWindow.Target; StartMargin = isolationWindow.StartMargin; EndMargin = isolationWindow.EndMargin; CERange = isolationWindow.CERange; DoValidate(); }
private int FindErrorCell(EditIsolationWindow editWindow) { if (!editWindow.Start.HasValue) { return(COLUMN_START); } if (!editWindow.End.HasValue) { return(COLUMN_END); } if (cbSpecifyMargin.Checked && !editWindow.StartMargin.HasValue) { return(COLUMN_START_MARGIN); } if (cbSpecifyCERange.Checked && !editWindow.CERange.HasValue) { return(COLUMN_CE_RANGE); } return(-1); }
private IList <EditIsolationWindow> CreateIsolationWindows() { var isolationWindows = new List <EditIsolationWindow>(); double start; double end; double windowWidth; double margin; int windowsPerScan = 0; double overlap = Overlap; double.TryParse(textMargin.Text, out margin); // No isolation windows if we don't have enough information or it is nonsense. if (!double.TryParse(textStart.Text, out start) || !double.TryParse(textEnd.Text, out end) || !double.TryParse(textWidth.Text, out windowWidth) || (Multiplexed && !int.TryParse(textWindowsPerScan.Text, out windowsPerScan))) { return(isolationWindows); } bool isIsolation = Equals(comboWindowType.SelectedItem, EditIsolationSchemeDlg.WindowType.MEASUREMENT); if (isIsolation) { start += margin; end -= margin; windowWidth -= 2 * margin; } if (start >= end || windowWidth <= 0 || overlap >= 100 || (Multiplexed && windowsPerScan == 0)) { return(isolationWindows); } // Calculate how many windows will be needed. double windowStep = windowWidth * (100 - overlap) / 100; int windowCount = (int)Math.Ceiling((end - start) / windowStep); if (Multiplexed && windowCount % windowsPerScan != 0) { windowCount = (windowCount / windowsPerScan + 1) * windowsPerScan; } // For optimized window placement, we try to align windows with the low spots // in m/z space. This requires us to adjust both the window width // and the starting offset of the windows. if (cbOptimizeWindowPlacement.Checked) { windowStep = Math.Ceiling(windowWidth * (100 - overlap) / 100) * OPTIMIZED_WINDOW_WIDTH_MULTIPLE; windowWidth = Math.Ceiling(windowWidth) * OPTIMIZED_WINDOW_WIDTH_MULTIPLE; start = Math.Ceiling(start / OPTIMIZED_WINDOW_WIDTH_MULTIPLE) * OPTIMIZED_WINDOW_WIDTH_MULTIPLE + OPTIMIZED_WINDOW_OFFSET; } while (start + (windowCount - 1) * windowStep + windowWidth > TransitionFullScan.MAX_RES_MZ || windowCount > MAX_GENERATED_WINDOWS) { windowCount -= Multiplexed ? windowsPerScan : 1; } double?ceRange = null; if (!string.IsNullOrWhiteSpace(textCERange.Text)) { double ceRangeValue; if (double.TryParse(textCERange.Text, out ceRangeValue)) { ceRange = ceRangeValue; } } // Generate window list. bool generateMargin = !Equals(margin, 0.0); if (overlap > 0) { if (windowCount % 2 == 0) { windowCount++; } windowCount++; start -= (windowWidth - windowStep); } for (int i = 0; i < windowCount; i++, start += windowStep) { // Apply instrument limits to method start and end. var methodStart = Math.Max(start - margin, TransitionFullScan.MIN_RES_MZ); var methodEnd = Math.Min(start + windowWidth + margin, TransitionFullScan.MAX_RES_MZ); // Skip this isolation window if it is empty due to instrument limits. if (methodStart + margin >= methodEnd - margin) { continue; } var window = new EditIsolationWindow { Start = methodStart + (isIsolation ? 0 : margin), End = methodEnd - (isIsolation ? 0 : margin), Target = null, StartMargin = generateMargin ? (double?)margin : null, EndMargin = generateMargin ? (double?)margin : null, CERange = ceRange }; if (overlap > 0) { var index = Math.Max(Math.Min(i % 2 == 1 ? i / 2 : i, isolationWindows.Count), 0); isolationWindows.Insert(index, window); // when optimized isolation windows are used the windows do not overlap evenly // the window step must flip-flop between the smaller and larger overlapping region windowStep = windowWidth - windowStep; } else { isolationWindows.Add(window); } } return(isolationWindows); }
private IList<EditIsolationWindow> CreateIsolationWindows() { var isolationWindows = new List<EditIsolationWindow>(); double start; double end; double windowWidth; double margin; int windowsPerScan = 0; double overlap = Overlap; double.TryParse(textMargin.Text, out margin); // No isolation windows if we don't have enough information or it is nonsense. if (!double.TryParse(textStart.Text, out start) || !double.TryParse(textEnd.Text, out end) || !double.TryParse(textWidth.Text, out windowWidth) || (Multiplexed && !int.TryParse(textWindowsPerScan.Text, out windowsPerScan))) { return isolationWindows; } bool isIsolation = Equals(comboWindowType.SelectedItem, EditIsolationSchemeDlg.WindowType.MEASUREMENT); if (isIsolation) { start += margin; end -= margin; windowWidth -= 2*margin; } if (start >= end || windowWidth <= 0 || overlap >= 100 || (Multiplexed && windowsPerScan == 0)) { return isolationWindows; } // Calculate how many windows will be needed. double windowStep = windowWidth * (100 - overlap) / 100; int windowCount = (int) Math.Ceiling((end - start) /windowStep); if (Multiplexed && windowCount % windowsPerScan != 0) { windowCount = (windowCount/windowsPerScan + 1)*windowsPerScan; } // For optimized window placement, we try to align windows with the low spots // in m/z space. This requires us to adjust both the window width // and the starting offset of the windows. if (cbOptimizeWindowPlacement.Checked) { windowStep = Math.Ceiling(windowWidth * (100 - overlap) / 100) * OPTIMIZED_WINDOW_WIDTH_MULTIPLE; windowWidth = Math.Ceiling(windowWidth) * OPTIMIZED_WINDOW_WIDTH_MULTIPLE; start = Math.Ceiling(start / OPTIMIZED_WINDOW_WIDTH_MULTIPLE) * OPTIMIZED_WINDOW_WIDTH_MULTIPLE + OPTIMIZED_WINDOW_OFFSET; } while (start + (windowCount-1) * windowStep + windowWidth > TransitionFullScan.MAX_RES_MZ || windowCount > MAX_GENERATED_WINDOWS) { windowCount -= Multiplexed ? windowsPerScan : 1; } double? ceRange = null; if (!string.IsNullOrWhiteSpace(textCERange.Text)) { double ceRangeValue; if (double.TryParse(textCERange.Text, out ceRangeValue)) ceRange = ceRangeValue; } // Generate window list. bool generateMargin = !Equals(margin, 0.0); if (overlap > 0) { if (windowCount%2 == 0) { windowCount ++; } windowCount ++; start -= (windowWidth - windowStep); } for (int i = 0; i < windowCount; i++, start += windowStep) { // Apply instrument limits to method start and end. var methodStart = Math.Max(start - margin, TransitionFullScan.MIN_RES_MZ); var methodEnd = Math.Min(start + windowWidth + margin, TransitionFullScan.MAX_RES_MZ); // Skip this isolation window if it is empty due to instrument limits. if (methodStart + margin >= methodEnd - margin) continue; var window = new EditIsolationWindow { Start = methodStart + (isIsolation ? 0 : margin), End = methodEnd - (isIsolation ? 0 : margin), Target = null, StartMargin = generateMargin ? (double?)margin : null, EndMargin = generateMargin ? (double?)margin : null, CERange = ceRange }; if (overlap > 0) { var index = Math.Max(Math.Min(i%2 == 1 ? i/2 : i, isolationWindows.Count), 0); isolationWindows.Insert(index, window); // when optimized isolation windows are used the windows do not overlap evenly // the window step must flip-flop between the smaller and larger overlapping region windowStep = windowWidth - windowStep; } else isolationWindows.Add(window); } return isolationWindows; }