This repository contains code for an image processing pipeline used for analyzing THG (Third Harmonic Generation) microscopy data, as described in our paper [to be added].
THG-segmentation/
├──data/
├──src/
│ ├── preprocessing.py
│ ├── segmentation.py
│ └── clustering.py
├── .gitignore
├── README.md
├── requirements.txt
└── run_pipeline.py
-
Clone the repository:
git clone https://github.com/LaboratoryOpticsBiosciences/THG-segmentation.git cd THG-segmentation -
Install the required packages:
pip install -r requirements.txt
To run the complete pipeline with all steps:
python run_pipeline.py --input_dir ./data --output_dir ./processed_data --steps preprocess segment cluster
You can run individual steps of the pipeline:
python run_pipeline.py --steps preprocess / segment / cluster
The preprocessing step includes several parameters that can be adjusted:
--radius: Radius for outlier removal (default: 2)--threshold: Threshold for outlier removal (default: 70)--wradius: Radius ratio for white tophat (default: 0.05, as fraction of image size)--threshold_percentage: Threshold percentage for inpainting (default: 0.999)--use_clahe: Enable CLAHE enhancement (disabled by default)
Example:
python run_pipeline.py --steps preprocess --radius 3 --threshold 65 --wradius 0.06
The THG microscopy dataset contains four categories:
- DIV8_Control (Myelinated)
- DIV8_LPC (Demyelinated)
- DIV11_Control (Myelinated)
- DIV11_LPC (Remyelinated)
Due to the large size of the dataset, it is not included in this repository. Please contact the authors for access to the full dataset.
-
Preprocessing:
- Inpainting to remove bright spots
- White tophat transform to enhance small bright features
- Outlier removal using a median filter
-
Segmentation:
- Hessian eigenvalue-based segmentation to detect fiber-like structures
- Meijering ridge detection for enhancing neurite structures
- Small object removal to clean up the segmentation
-
K-means Clustering:
- Feature extraction from segmented regions
- K-means clustering on morphological features
- Interactive cluster selection to remove outliers
- Final image reconstruction based on selected clusters
If you use this code in your research, please cite our paper:
[Citation information will be added]