Skip to content

Releases: ratchanonth60/baseline-model

Release v2.3.0

Choose a tag to compare

@ratchanonth60 ratchanonth60 released this 19 Feb 04:00

This release introduces significant improvements to the Baseline Mode application, focusing on performance, fitting capabilities, and observation features.

πŸš€ New Features

  • HEMG Double-Sided Fitting: Added support for Hyper-EMG double-sided fitting, allowing for more accurate analysis of complex spectral peaks.
  • Parallel Processing: Implemented parallel processing for channel data, significantly speeding up bulk operations.
  • Observation Mode Enhancements:
    • Manual Peak Locking for consistent analysis.
    • Configurable X-Axis units (ADC, Voltage, Energy).
    • Improved histogram visualization and controls.

⚑ Performance Improvements

  • Loading Smoothness: Refactored data processing to run asynchronously, preventing UI freezes during large file loads or parameter changes.
  • Background Calculations: Moved heavy mathematical computations (histograms, statistics, fitting) to background threads.
  • Batched UI Updates: Optimized UI thread interactions by batching updates, resulting in a smoother user experience.

πŸ›  Fixes & Refactoring

  • Codebase Cleanup: Massive refactoring of MainViewModel to improve readability and maintainability.
  • MathService Consolidation: Unified fitting logic into a single MathService.
  • Bug Fixes: Resolved issues with Plot rendering, Flux tab interactions, and generic fit visibility.

πŸ“¦ Changes

  • Bumped version to 2.3.0.

Full Changelog: v2.2.3...v2.3.0

Release Notes - Version 2.2.3

Choose a tag to compare

@ratchanonth60 ratchanonth60 released this 16 Feb 08:35

Release Notes - Version 2.2.3

πŸš€ New Features

Centralized Logging & Error Handling (ROP)

  • Railway Oriented Programming (ROP): Adopted the ROP pattern across all core services and ViewModels (MainViewModel, ObservationViewModel, FluxViewModel, CalibrationViewModel) to ensure explicit and verifiable error handling.
  • Persistent Logging: Introduced ILoggerService and LoggerService to write logs to the logs/ directory, improving post-mortem analysis and debugging.
  • Global Exception Handling: Unhandled exceptions are now caught and logged via App.xaml.cs to prevent silent crashes.

Improved Fitting Engine

  • Refactored MathService: Updated MathService to integrate IHemgFittingService via dependency injection, improving testability and modularity.
  • HEMG Stability: Enhanced HemgFittingService with better error trapping and logging.
  • Validation: Added IsValid checks to fitting results to ensure only valid curves are rendered on the plots.

Async I/O & UI Responsiveness

  • Asynchronous File Operations: Converted BaselineFileService, FileHelper, and ObservationExcelHelper to use fully asynchronous patterns, preventing UI freezes during large file processing.
  • Progress Feedback: Updated status bars in UnifiedMainWindow to support indeterminate states for operations with unknown duration.

πŸ› Bug Fixes

  • Kalman Filter: Fixed naming conventions and initialization logic in MathService.KalmanFilter.
  • Plotting: Resolved issues where invalid fitting curves could cause rendering artifacts.
  • UI State: Fixed ProgressBar ranges and indeterminate states to correctly reflect background activity.

πŸ›  Technical Improvements

  • Modern Syntax: Refactored code to use C# collection expressions ([...]) for cleaner and more readable code.
  • Thread Safety: Updated LoggerService to use modern thread-locking mechanisms.
  • Dependency Injection: Registered IHemgFittingService and ILoggerService in the global DI container.

v2.2.1 HEMG Fit Accuracy Fixes

Choose a tag to compare

@ratchanonth60 ratchanonth60 released this 16 Feb 01:10

Key Improvements

    1. Accurate Baseline Fitting
      Perfect Overlap: Fixed the misalignment between histogram data and fitted curves by unifying the binning system to 1,6384 bins (1:1 mapping with ADC channels).
      Enhanced HEMG Algorithm:
      Integrated Peak Detection to intelligently initialize fitting parameters.
      Added a Gaussian Core to the HEMG model to accurately capture sharp peaks.
      Upgraded to the Levenberg-Marquardt optimizer for superior stability and faster convergence.
      Optimized Fit Range (ROI) to focus on the peak area, reducing noise interference.
    1. Centralized User Interface
      New Settings Panel: All graph-related configuration (Colors, Thresholds, Widths) has been moved to a slide-out panel, cleaning up the main toolbar.
      Universal Bar Width Control: Added a single slider to control the visual thickness of histogram bars across all modes (Baseline, Calibration, Observation, Flux).
      Algorithm Selection: Added a direct toggle between Gaussian, Lorentzian, and HEMG fitting algorithms in the settings panel.
    1. Under-the-Hood Optimization
      Color Standardization: Introduced a shared
      ColorHelper
      to ensure consistent visual aesthetics across all plots.
      Code Consolidation: Eliminated duplicate
      KalmanFilter
      implementations and refactored core fitting services for better maintainability.
      Bug Fixes: Resolved axis scaling issues when switching between ADC, Voltage, and Energy units.

πŸ› οΈ Verification Done

Zero Build Errors: Full compilation confirmed with 0 warnings.
Visual Validation: Verified fit accuracy on multi-peak histograms.
Units Sync: Confirmed conversion logic remains consistent across all modes.

v2.2.0

Choose a tag to compare

@ratchanonth60 ratchanonth60 released this 13 Feb 03:45

Release Notes v2.2.0

πŸš€ New Features

  • Unified Settings Panel:
    • Moved all graph settings (Baseline, Calibration, Observation, Flux) to a centralized side panel in UnifiedMainWindow.xaml.
    • Removed cluttered controls from the Ribbon/Toolbar for a cleaner, wider workspace.
  • Universal Bar Width Control:
    • Added adjustable Bar Width settings for all histogram and bar charts across all modes (Baseline, Calibration, Observation, Flux).
  • Flux Mode Enhancements:
    • Added dedicated settings card for Flux graphs.
    • Implemented dynamic bar width and marker size adjustments for Flux plots.

πŸ›  Improvements & Refactoring

  • MathService Consolidation:
    • Merged all fitting logic (Gaussian, Lorentzian, Hyper-EMG) into a single optimized MathService.
    • Removed HemgFittingService, streamlining the service layer.
  • Memory Optimization:
    • Standardized BaselineData to use float[] for layer data, significantly reducing memory usage during large dataset processing.
  • Code Cleanup:
    • Removed unused files and services (FileService.cs, HeaderValidator.cs, etc.) to reduce technical debt.

πŸ› Bug Fixes

  • Data Type Compatibility:
    • Resolved float[] vs double[] type mismatches in the data processing pipeline, preventing runtime casting errors.
  • Flux Plotting:
    • Fixed issues where Flux graphs would not render or update correctly when changing settings.
  • Merge Stability:
    • Successfully resolved complex conflicts between main and dev branches, effectively combining dev's new features with main's architectural refactoring.

Baseline Mode v2.1.0

Choose a tag to compare

@ratchanonth60 ratchanonth60 released this 12 Feb 08:06

Baseline Mode v2.1.0

This major release introduces a unified interface and full implementation of all core operation modes.

πŸš€ New Features

  • Unified Interface: Consolidates Baseline, Observation, Flux, and Calibration modes into a single UnifiedMainWindow.
  • Observation Mode:
    • New UI with dedicated detailed views.
    • Enhanced histogram plotting with dynamic binning.
    • Gaussian and Lorentzian fitting integration.
  • Flux Mode:
    • Complete data processing and visualization pipeline.
    • Adjustable time range configurations (Min/Max).
  • Calibration Mode:
    • Full calibration workflow implementation.
    • Dynamic X-axis ranges for ADC and Voltage views.
  • Baseline Mode:
    • Core data processing services and visualization.
    • Real-time data streaming support.

πŸ›  Improvements

  • MathService: Centralized mathematical operations for fitting, statistics, and filtering.
  • Data Processing: Optimized hex data parsing with FileService.
  • Performance: Improved plotting performance with ScottPlot integration.

πŸ“¦ Technical Details

  • Updated target framework to .NET 8.0 (or relevant version based on .csproj).
  • Refactored ViewModel architecture for better separation of concerns.

v2.0-beta

v2.0-beta Pre-release
Pre-release

Choose a tag to compare

@ratchanonth60 ratchanonth60 released this 10 Feb 09:06

New Features

  • Observation Mode β€” Full-featured observation data processing, analysis, and visualization with DSSD strip histograms (X1-X8, Y1-Y8) and BGO plots
  • Unified Main Window β€” Office-style ribbon UI with tabs (Home, Data, Analysis, Config, Observation), replacing the Navigation Rail with a single-window layout
  • Observation Detail View β€” Popup window with histogram plotting and curve fitting for individual channels
    Excel Export β€” Observation results exported to Excel via new ExcelHelper service
  • Channel Management β€” Core channel management with baseline processing and thresholding

Curve Fitting Improvements

  • Unified fitting β€” Observation view now uses the same MathService as Baseline, ensuring consistent Gaussian/Lorentzian results across both views

  • FWHM, Resolution, RΒ² β€” Gaussian fit now computes FWHM (
    2.355
    Οƒ
    2.355Οƒ), energy resolution, and R-squared statistics

  • Fit method selection β€” ComboBox to switch between Gaussian and Lorentzian fitting, with live plot refresh on change

  • Improved initial guess β€” CalculateWeightedMoments uses half-maximum peak detection instead of a hardcoded Β±200 bin window

Graph & UI Enhancements

  • Bar width fix β€” BarWidth set to actual bin width so histogram bars are visible (not just 1-pixel lines)
  • Bar border color β€” Border matches fill color instead of default black
  • Configurable graph background β€” Default changed from black to dark gray; user can customize via Settings
  • Customizable bar colors β€” DSSD (orange default) and BGO (cyan default) colors changeable in Settings

Project Structure

  • Restructured into Core / Infrastructure / Presentation layers
  • Views organized into Baseline / Observation / Shared folders
  • Status bar with progress indicator

v1.4.0 - Major bug fixes, HEMG double-tail support, and code refactoring

Choose a tag to compare

@ratchanonth60 ratchanonth60 released this 09 Feb 06:45

πŸ› Bug Fixes (10 items)

  • Fix LoadMeanFromFile using wrong path β†’ now uses GetDailyOutputDirectory()
  • Fix ApplyThresholding using RMS instead of mean-centered std dev
  • Fix ProcessData not checking SelectedMode for file-based mean loading
  • Fix histogram range hardcoded to 0-16383 even after baseline subtraction
  • Fix nullable warnings (CS8618/CS8622) on RequestPlotUpdate and _cts
  • Fix HEMG erfc formula errors in both left and right tails β†’ (Οƒ/Ο„ βˆ’ Ξ”x/Οƒ) / √2
  • Fix HEMG tau parameters not scaled to sigma units (caused exp overflow)
  • Fix HEMG fitCurve length mismatch with caller's binCenters
  • Fix ChannelViewModel stats annotation using wrong coordinate system
  • Fix FitCurve/BinCenters length guard missing

✨ New Features

  • Hyper-EMG double tail β€” added as 3rd fit method option (Gaussian / Single / Double)
  • Adaptive gradient descent β€” new optimizer with line search + central difference
  • Fit window Β±5Οƒ β€” fit only bins near peak for better speed & stability

♻️ Refactoring

  • Extract 5 shared helpers: GetLayerSelector, ExtractChannelData, ApplyBaselineSubtraction, BuildHistogram, CalculateMean
  • Remove duplicated code: layerSelector (4β†’1), baseline (2β†’1), histogram (2β†’1)
  • Remove unused AccordFittingService.cs + Accord.Math/Accord.Statistics NuGet packages
  • Remove dead code: InterpolateFitCurve, PerformFit, createMarkerShape
  • Remove empty folders: Infrastructure/, Presentation/
  • RefreshChannelPlots() reduced from ~70 β†’ ~25 lines
  • ProcessData Parallel.For body reduced from ~70 β†’ ~25 lines
  • Net -38 lines (324 added, 362 removed)

πŸ“Š Build

βœ… 0 errors, 0 warnings

Release V1.3.1

Choose a tag to compare

@ratchanonth60 ratchanonth60 released this 05 Feb 04:33

Release v1.3.1 - HEMG Double-Sided Fitting Service

πŸŽ‰ What's New

✨ Major Features

  • HEMG Double-Sided Fitting Service - Convert MATLAB HEMG_DS_fit to C#
    • Full mathematical implementation of Hyper-Exponentially Modified Gaussian (HEMG) function
    • Support for asymmetric peak modeling in energy spectroscopy
    • Gradient descent optimization with numerical differentiation
    • Automatic parameter bounds enforcement

πŸ“¦ New Components

  • Services/HemgFittingService.cs - Core HEMG fitting engine
  • Extended FittingResult model with HEMG parameters (A, ΞΌ, Οƒ, Ο„L, Ο„R, Ξ·L, Ξ·R)
  • Updated IMathService interface with HyperEMGDoubleSidedFit() method
  • Enhanced MathService with HEMG integration

πŸ”§ Technical Improvements

  • Hyper-EMG double-sided curve function with left/right tail modeling
  • Error function (erf) approximation using Abramowitz-Stegun formula
  • 16,384 bin histogram creation (0-16384 range)
  • Numerical overflow protection (clamping to 700)
  • NaN/Infinity value handling

πŸ“š Documentation

  • HEMG_CONVERSION_NOTES.md - Technical conversion details and mathematical background
  • HEMG_USAGE_EXAMPLES.md - Integration examples and parameter guide
  • CONVERSION_COMPLETE.md - Project completion summary

🎯 Use Cases

  • Nuclear energy detector calibration (alpha/beta spectroscopy)
  • Asymmetric peak fitting in complex spectra
  • Energy calibration workflow integration
  • Spectroscopic data analysis

⚑ Performance

  • Typical fit time: 100-500ms per spectrum
  • Memory usage: ~2MB per fit operation
  • Convergence: 50-100 iterations typical

βœ… Quality Assurance

  • βœ“ Build successful (0 errors, 3 warnings unrelated to HEMG)
  • βœ“ All code compiles and runs
  • βœ“ Integrated with existing MVVM architecture
  • βœ“ Ready for production use

πŸ“ Parameter Reference

  • A (Amplitude): Peak height [0, ∞)
  • ΞΌ (Mu): Peak center position [0, 16384]
  • Οƒ (Sigma): Peak width/standard deviation [0.01, 50]
  • Ο„L1 (Tau Left): Left tail decay constant [0.05, 5.0]
  • Ο„R1 (Tau Right): Right tail decay constant [0.05, 5.0]
  • Ξ·L1 (Eta Left): Left tail weight [0.0, 1.0]
  • Ξ·R1 (Eta Right): Right tail weight [0.0, 1.0]

πŸ”— Related

  • Based on MATLAB function: HEMG_DS_fit()
  • Uses Accord.NET for mathematical operations
  • Compatible with ScottPlot.WPF for visualization

πŸ“– Getting Started

var mathService = new MathService();
FittingResult result = mathService.HyperEMGDoubleSidedFit(energyData, energyData);
Console.WriteLine($"Mean: {result.Mu:F2}, Sigma: {result.Sigma:F2}");

v1.3.0 - Fix Graph Plotting & Accord.NET Integration

Choose a tag to compare

@ratchanonth60 ratchanonth60 released this 03 Feb 02:19

πŸš€ Features & Improvements

  • Fixed Graph Plotting Bug: Corrected the hex data parsing offsets in FileService to match the legacy application. Graphs now correctly display Gaussian distribution.
  • Accord.NET Integration: Added Accord.NET library for more accurate Gaussian curve fitting and statistics.
  • New Services:
    • AccordFittingService: Dedicated service for curve fitting.
    • MathService: Optimized math calculations.
    • IFileService: Interface for better testability.
  • Performance: Optimized voltage calculation logic.

πŸ›  Refactoring & Cleanup

  • Project Structure:
    • Moved ViewModels to Views/models namespace.
    • Moved Resources (Styles, Colors) to Views/Resources.
  • Testing: Added Unit Tests for MainViewModel and FileVerification.

πŸ“¦ Dependencies

  • Added Accord.Math v3.8.0
  • Added Accord.Statistics v3.8.0

Release v1.2.0

Choose a tag to compare

@ratchanonth60 ratchanonth60 released this 29 Jan 08:05

Release v1.2.0

New Features πŸš€

  • Added "Save Mean" Button: Users can now save mean values for all layers (L1, L2, L6, L7) directly from the UI.
  • Improved Z-Direction Visibility: Fixed an issue where Z-direction graphs were hidden. Now both X and Z channels are processed and displayed simultaneously.

Technical Improvements πŸ› οΈ

  • Refactored Models: Organized code by moving HeaderValidationResult, PlotUpdateEventArgs, and FittingResult to the distinct Models namespace for better maintainability.
  • Optimized MathService: Replaced tuple returns with structured FittingResult objects.