Repository navigation
Releases: ratchanonth60/baseline-model
Release list
Release v2.3.0
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
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
ILoggerServiceand LoggerService to write logs to thelogs/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
IHemgFittingServicevia dependency injection, improving testability and modularity. - HEMG Stability: Enhanced HemgFittingService with better error trapping and logging.
- Validation: Added
IsValidchecks to fitting results to ensure only valid curves are rendered on the plots.
Async I/O & UI Responsiveness
- Asynchronous File Operations: Converted
BaselineFileService,FileHelper, andObservationExcelHelperto 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
ProgressBarranges 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
IHemgFittingServiceandILoggerServicein the global DI container.
v2.2.1 HEMG Fit Accuracy Fixes
Key Improvements
-
- 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.
- Accurate Baseline Fitting
-
- 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.
- Centralized User Interface
-
- 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.
- Under-the-Hood Optimization
π οΈ 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
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.
- Standardized BaselineData to use
- Code Cleanup:
- Removed unused files and services (
FileService.cs,HeaderValidator.cs, etc.) to reduce technical debt.
- Removed unused files and services (
π Bug Fixes
- Data Type Compatibility:
- Resolved
float[]vsdouble[]type mismatches in the data processing pipeline, preventing runtime casting errors.
- Resolved
- Flux Plotting:
- Fixed issues where Flux graphs would not render or update correctly when changing settings.
- Merge Stability:
- Successfully resolved complex conflicts between
mainanddevbranches, effectively combiningdev's new features withmain's architectural refactoring.
- Successfully resolved complex conflicts between
Baseline Mode v2.1.0
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
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
π Bug Fixes (10 items)
- Fix
LoadMeanFromFileusing wrong path β now usesGetDailyOutputDirectory() - Fix
ApplyThresholdingusing RMS instead of mean-centered std dev - Fix
ProcessDatanot checkingSelectedModefor file-based mean loading - Fix histogram range hardcoded to 0-16383 even after baseline subtraction
- Fix nullable warnings (CS8618/CS8622) on
RequestPlotUpdateand_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
ChannelViewModelstats 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.StatisticsNuGet packages - Remove dead code:
InterpolateFitCurve,PerformFit,createMarkerShape - Remove empty folders:
Infrastructure/,Presentation/ RefreshChannelPlots()reduced from ~70 β ~25 linesProcessDataParallel.For body reduced from ~70 β ~25 lines- Net -38 lines (324 added, 362 removed)
π Build
β 0 errors, 0 warnings
Release V1.3.1
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
FittingResultmodel with HEMG parameters (A, ΞΌ, Ο, ΟL, ΟR, Ξ·L, Ξ·R) - Updated
IMathServiceinterface withHyperEMGDoubleSidedFit()method - Enhanced
MathServicewith 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 backgroundHEMG_USAGE_EXAMPLES.md- Integration examples and parameter guideCONVERSION_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
π Features & Improvements
- Fixed Graph Plotting Bug: Corrected the hex data parsing offsets in
FileServiceto match the legacy application. Graphs now correctly display Gaussian distribution. - Accord.NET Integration: Added
Accord.NETlibrary 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/modelsnamespace. - Moved Resources (Styles, Colors) to
Views/Resources.
- Moved ViewModels to
- Testing: Added Unit Tests for
MainViewModelandFileVerification.
π¦ Dependencies
- Added
Accord.Mathv3.8.0 - Added
Accord.Statisticsv3.8.0
Release v1.2.0
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, andFittingResultto the distinctModelsnamespace for better maintainability. - Optimized MathService: Replaced tuple returns with structured
FittingResultobjects.