This package provides tools for analyzing acoustic hologram optimization results, with a focus on quantifying high-frequency detail preservation.
When optimizing acoustic holograms using phased arrays, it's important to evaluate how well the algorithm preserves high-frequency details in the target pattern. This package provides metrics and visualization tools specifically designed for this purpose.
frequency_analysis.py
- Core functions for frequency domain analysisanalyze_results.py
- Functions to load and analyze result filesrun_analysis.py
- Simple command-line interface for running analysis
- Clone or download this repository
- Install required dependencies:
pip install numpy scipy matplotlib h5py
To analyze all results in a directory:
python run_analysis.py /path/to/results/folder
This will:
- Find all result files (
.mat
or.npy
) in the specified directory - Load and analyze each file
- Generate frequency analysis plots
- Calculate metrics and scores
- Create a comparison report if multiple results are found
To analyze a specific result file:
python run_analysis.py /path/to/results/folder --single_file phased_array_hologram_20250413-123456.mat
The analysis calculates several metrics to quantify high-frequency detail preservation:
The frequency spectrum is divided into three bands:
- Low frequencies: 0-20% of maximum frequency
- Mid frequencies: 20-60% of maximum frequency
- High frequencies: 60-100% of maximum frequency
- High Frequency Retention: How much of the high-frequency power from the target is preserved in the achieved image
- High Frequency Detail Preservation: Compares the high-to-low frequency ratios between target and achieved images
- High Frequency Weighted Retention: Weighted sum that emphasizes higher frequencies
- Spectral Norm Ratio: Another perspective on high-frequency content preservation
- Hologram Detail Score: Composite score combining multiple metrics (0-1 scale, higher is better)
The analysis generates several visualization plots:
- Spectrum Visualization: Shows the original images and their frequency spectrums
- Power Distribution: Shows how power is distributed across frequency bands
- Retention Ratio: Shows how well each frequency band is preserved
- Comparison Report: When analyzing multiple results, creates a bar chart for easy comparison
The analysis supports both older (.mat v7.2 and earlier) and newer HDF5-based (.mat v7.3+) MATLAB file formats. For newer formats, the h5py package is required.
This analysis package is designed to work with the results from the acoustic hologram optimization code. After running optimization with the main.py script, you can analyze the results using this package.
- Run hologram optimization:
python main.py
- Analyze the results:
python run_analysis.py results/
- Review the metrics and visualizations to evaluate the quality of the optimization