33340_neutronactivation_histolyzer
https://github.com/tonyletiantang/33340_neutronactivation_histolyzer
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.0%) to scientific vocabulary
Repository
Basic Info
- Host: GitHub
- Owner: tonyletiantang
- License: mit
- Language: Python
- Default Branch: main
- Size: 166 KB
Statistics
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
Gamma Radiation Spectrum Analyzer
A Python tool for analyzing gamma radiation spectra, particularly useful for neutron activation analysis experiments. This tool processes CSV files containing radiation spectrum data, identifies peaks, and performs Gaussian fitting to accurately determine peak positions.
Features
- Process multiple spectrum files in batch mode
- Interactive peak selection with background subtraction
- Gaussian curve fitting for accurate peak center determination
- Comprehensive uncertainty estimation using proper error propagation
- Detailed visualization of spectra and fitted peaks
- Summary of all peak positions across multiple isotopes
- Automatic output organization
- Channel to energy conversion with the form Channel = a + b*Energy
- Save user inputs to JSON for reproducible analysis
- Load previous analysis settings from JSON files
- Detailed chi-square statistics for goodness of fit evaluation
Installation
Clone this repository:
git clone https://github.com/yourusername/histogram_analyzer.git cd histogram_analyzerInstall required packages:
pip install -r requirements.txt
Usage
Run the program by executing:
python histogram_analyzer.py
Input Data Format
The tool accepts CSV files containing radiation spectrum data with these structures: - Files with "Channel Data:" marker followed by channel data - Files with headers containing "channel" and "counts" - Simple CSV files with minimal headers
The application will intelligently try to interpret various file formats.
Processing Modes
- Single File Mode: Process one spectrum file with multiple peaks
- Multiple Isotopes Mode: Process multiple files representing different isotopes
Workflow
- Optionally load saved settings from a previous analysis
- Select input mode (single file vs. multiple isotopes)
- Choose files from a folder or enter file paths manually
- View the full spectrum
- Select channels for background subtraction
- Review Gaussian fits, uncertainty analysis, and chi-square statistics
- Optionally convert channels to energy using the formula Channel = a + b*Energy
- Get a summary of all peak positions
- Save all inputs and settings to JSON for reproducibility
Output
The tool generates: - Spectrum plots (.png) - Gaussian fit visualizations with uncertainty bands - Processed data files (.csv) - Fit results with detailed uncertainty estimates (.csv) - JSON files containing all user inputs for reproducibility (.json)
Examples
Basic Workflow
Run the program:
python histogram_analyzer.pySelect processing mode (1 for single file or 2 for multiple isotopes)
Browse to your data files
For each peak, provide start and end channels for background subtraction
Review the results and plots
Dependencies
- pandas: Data handling and CSV processing
- matplotlib: Visualization
- numpy: Numerical operations
- scipy: Signal processing and curve fitting
Uncertainty Calculation
The peak position uncertainty is determined using multiple independent error sources. The calculation involves these steps:
- Calculate individual error components
- Combine the first three components in quadrature to get a combined error
- Take the maximum of this combined error and a width-based estimate
The final formula is:
combined_err = sqrt(statistical_err² + window_variation_err² + channel_discretization_err²)
final_err = max(combined_err, width_based_err)
The four error components are:
Statistical error: The formal uncertainty derived from the covariance matrix of the Gaussian fit. This represents the statistical uncertainty inherent in fitting a mathematical model to experimental data.
Window variation error: This error is calculated by varying the selection window endpoints by ±5% of the window size and performing 1000 independent Gaussian fits (configurable via the WINDOWVARIATIONRUNS parameter). The standard deviation of these peak positions provides an estimate of how sensitive the measurement is to the specific window selection.
Channel discretization error: A fixed value of 0.5 channels that accounts for the inherent uncertainty due to the discrete nature of the channel data. Since data is binned into integer channels, there is a minimum positional uncertainty of half a channel width.
Width-based error: A simple heuristic estimate calculated as 10% of the peak width (sigma). This provides a fallback that scales with the width of the peak.
⚠️ IMPORTANT NOTE ON UNCERTAINTY ESTIMATION ⚠️
The uncertainty calculation implemented here is a relatively crude estimate and may need adjustment for your specific experimental conditions. Users are encouraged to customize the uncertainty calculation by:
- Applying different scaling factors to individual error components - Changing the window variation ratio (currently set at ±5%) - Using different combination methods (maximum, quadrature sum, linear sum) - Adding additional error terms specific to your experimental setup
USERS ARE STRONGLY ENCOURAGED TO EXPERIMENT WITH THESE METHODS TO FIND THE BEST APPROACH FOR THEIR SPECIFIC DATA AND EXPERIMENTAL NEEDS!
Uncertainty estimation is inherently experimental-dependent, and the method implemented here should be considered a starting point rather than a definitive solution.
By using the maximum of the combined statistical error and the width-based estimate, we ensure a comprehensive uncertainty value that: - Accounts for all significant error sources - Scales appropriately with peak width - Follows standard error propagation principles - Never underestimates the true uncertainty
This approach provides a reasonable baseline for uncertainty estimation in typical neutron activation analysis experiments.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Owner
- Name: Tony (Letian) Tang
- Login: tonyletiantang
- Kind: user
- Company: Carnegie Mellon University
- Repositories: 1
- Profile: https://github.com/tonyletiantang
Undergraduate Researcher in Quantum Information at Carnegie Mellon University (Physics + CS)
Citation (citation.cff)
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
title: "Gamma Radiation Spectrum Analyzer"
authors:
- family-names: "Tang"
given-names: "Letian"
affiliation: "Carnegie Mellon University"
version: 1.0.0
date-released: 2025-04-18
repository-code: "https://github.com/yourusername/histogram_analyzer"
license: MIT
abstract: "A Python tool for analyzing gamma radiation spectra from neutron activation experiments. Processes CSV files containing radiation spectrum data, identifies peaks, and performs Gaussian fitting to accurately determine peak positions."
keywords:
- gamma radiation
- spectroscopy
- neutron activation
- data analysis
- peak fitting
GitHub Events
Total
Last Year
Dependencies
- matplotlib >=3.4.0
- numpy >=1.20.0
- pandas >=1.3.0
- scipy >=1.7.0