This repository contains a Python pipeline for processing, analyzing, and visualizing Stimulated Brillouin Scattering data, provide both backend data processing and a graphical user interface (GUI) for interactive exploration.
The main functionalities include:
- Data Reading: Reads raw data from CSV files.
- Preprocessing: Performs interpolation and reshaping of the raw data.
- Peak Fitting: Fits single or double Lorentzian peaks to the data using GPU-accelerated fitting via
pygpufit
. - Visualization: Displays 2D heatmaps, frequency plots, and histograms for various parameters.
- Interactive GUI: Provides an intuitive interface for users to interact with processed data through plots, histograms, and tables.
-
Data Preprocessing:
- Reshapes raw data into structured arrays.
- Applies interpolation to align data points.
-
Single and Double Peak Fitting:
- Utilizes GPU-based least squares fitting (
pygpufit
) for high-performance computation. - Supports fitting of both single and double Lorentzian peaks with constraints.
- Utilizes GPU-based least squares fitting (
-
Visualization:
- Generates 2D heatmaps for amplitude, shift, width, offset, and error.
- Displays frequency plots for individual pixels.
- Produces histograms for statistical analysis of fitted parameters.
-
Export Options:
- Saves processed data as TIFF files.
- Generates colorbars for visualization consistency.
-
Interactive GUI:
- Allows users to navigate through planes, adjust visualization parameters, and view detailed information for specific pixels.
Ensure the following dependencies are installed in your Python environment:
-
Python 3.x: Ensure Python 3.x is installed on your system.
-
Required Libraries:
numpy
pandas
matplotlib
pyqt5
scipy
joblib
pyarrow
tifffile
Install these libraries using pip:
pip install numpy pandas matplotlib pyqt5 scipy joblib pyarrow tifffile
-
pygpufit:
- A library for GPU-accelerated Lorentzian fitting.
- Homepage: github.com/gpufit/Gpufit
- Customization: We have extended the functionality of
gpufit
by adding support for Lorentzian line shapes, enabling more accurate fitting for our specific use case. - Installation:
- Download the appropriate
.whl
file from the GitHub Releases page. - Install using pip:
pip install path_to_wheel_file/pygpufit-*.whl
- Download the appropriate
- Compatibility: The library has been tested and optimized for NVIDIA GPUs in the RTX series, including RTX20**, RTX30**, and RTX40**. These GPUs provide excellent performance for GPU-accelerated computations.
-
UI File:
- Ensure the UI file (
Ui_dou3.py
) generated by PyQt5'spyuic
tool is available in the project directory.
- Ensure the UI file (
-
Data Files:
- Place the required data files
test2.txt
,test2_append.txt
in the specified directory (D:\workspace\01\20240809\test2
).
- Place the required data files
Before running the application, you may need to adjust certain parameters in the script or configuration files. Key parameters include:
- File Paths: Ensure the paths to your data files (
test2.txt
,test2_append.txt
) are correctly set. - Experiment Settings: Modify the
experiment_settings
class inmain.py
to match your experimental setup, such assamples_ignored
,shift
,x_pixel_to_um
,y_pixel_to_um
, etc. - Constraints: Adjust the constraints for peak fitting in
pipeline.py
if necessary.
Run the main script using the following command:
python main.py
The application automatically loads data from the predefined file paths. Ensure the data files exist in the specified directories.
- Use the slider (
zplane
) to select the plane you want to visualize. - Adjust the minimum and maximum frequency values (
minfreq
,maxfreq
) to control the color scale of the heatmap.
- Choose a parameter from the dropdown menus (
comboBox
,comboBox_2
) to display corresponding heatmaps and histograms. - Parameters include
shift
,amplitude
,width
,offset
,error
, and double peak-specific parameters likel1_shift
,l1_amplitude
, etc.
- Click on any point in the heatmap to view the frequency plot for that pixel.
- The frequency plot displays raw data, single fit, and double fit (if enabled) for the selected pixel.
- Check the
double_peak
checkbox to enable double peak fitting. - Additional parameters for double peaks will appear in the dropdown menus.
- The application automatically saves the processed data as TIFF files in the
tiff_export
subfolder.
Close the application window to exit.
The application calculates and displays the total processing time, including:
- Time taken to read files.
- Time for preprocessing.
- Time for fitting.
- Total execution time.
Example output:
读文件:0.1234s
预处理:0.5678s
拟合:1.2345s
总计:2.3456s
- Ensure all required files and libraries are correctly placed and installed before running the application.
- Modify file paths in the script if your data files are stored in different directories.
- For advanced customization, refer to the
pipeline
module and adjust preprocessing and fitting functions as needed.
If you are interested in more details, please refer to our paper "Stimulated Brillouin scattering microscopy with a high-peak-power 780 nm pulsed laser system"
This project is licensed under the MIT License - see the LICENSE file for details.