Skip to content

Conversation

@YukiMatsuzawa
Copy link
Contributor

Add SpectrumLabel and label selection to UI

  • Updated DisplayScan to include SpectrumLabel for detailed peak information.
  • Changed ViewTemplates to bind chart:Annotator to SpectrumLabel.
  • Added ComboBox for selecting label type (m/z or NL) in the UI.
  • Introduced LabelProperty in SplitSpectrumsViewModel for binding.

- Updated DisplayScan to include SpectrumLabel for detailed peak information.
- Changed ViewTemplates to bind chart:Annotator to SpectrumLabel.
- Added ComboBox for selecting label type (m/z or NL) in the UI.
- Introduced LabelProperty in SplitSpectrumsViewModel for binding.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces spectrum label functionality and UI controls for selecting label types in the spectrum viewer. The changes enable users to switch between displaying m/z values and neutral loss (NL) values as labels on spectrum peaks.

  • Added SpectrumLabel property to DisplayScan for providing peak label data
  • Modified chart annotations to bind to SpectrumLabel instead of Spectrum and support dynamic label selection
  • Added ComboBox UI control for selecting between m/z and NL label types

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
SplitSpectrumsViewModel.cs Added LabelProperty for binding label type selection
ViewTemplates.xaml Updated chart annotators to use SpectrumLabel and added ComboBox for label selection
DisplayScan.cs Added SpectrumLabel property with anonymous objects containing Mass, Intensity, and NeutralLoss

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

public ChromXs ChromXs { get => Scan.ChromXs; set => Scan.ChromXs = value; }
public IonMode IonMode { get => Scan.IonMode; set => Scan.IonMode = value; }
public double PrecursorMz { get => Scan.PrecursorMz; set => Scan.PrecursorMz = value; }
public object[] SpectrumLabel => Scan.Spectrum.Select(p => new { p.Mass, p.Intensity, NeutralLoss = p.Mass - Scan.PrecursorMz }).ToArray();
Copy link

Copilot AI Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This property creates a new array every time it's accessed. Consider caching the result or making it a method to make the performance cost explicit, especially if this property is bound to UI controls that may access it frequently.

Suggested change
public object[] SpectrumLabel => Scan.Spectrum.Select(p => new { p.Mass, p.Intensity, NeutralLoss = p.Mass - Scan.PrecursorMz }).ToArray();
public object[] GetSpectrumLabel() {
return Scan.Spectrum.Select(p => new { p.Mass, p.Intensity, NeutralLoss = p.Mass - Scan.PrecursorMz }).ToArray();
}

Copilot uses AI. Check for mistakes.
public ChromXs ChromXs { get => Scan.ChromXs; set => Scan.ChromXs = value; }
public IonMode IonMode { get => Scan.IonMode; set => Scan.IonMode = value; }
public double PrecursorMz { get => Scan.PrecursorMz; set => Scan.PrecursorMz = value; }
public object[] SpectrumLabel => Scan.Spectrum.Select(p => new { p.Mass, p.Intensity, NeutralLoss = p.Mass - Scan.PrecursorMz }).ToArray();
Copy link

Copilot AI Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using anonymous objects and object[] creates a weakly-typed API that's prone to runtime errors. Consider creating a dedicated class or struct (e.g., SpectrumLabelData) with Mass, Intensity, and NeutralLoss properties for better type safety.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants