This project focuses on extracting patches from Whole Slide Images (WSI) using various extraction methods. It provides a modular and configurable approach to extract patches based on different criteria such as point annotations and tiles.
The project consists of the following components:
-
SVSLoader
package: Contains the code for loading and managing Whole Slide Images. -
Processing
package: Contains the code for different patch extraction methods and related utilities. -
Config
package: Contains configuration-related files and utilities. -
Utils
package: Contains utility functions used across the project. -
main.py
: The main script to run the patch extraction process.
To run the project, ensure that you have the following dependencies installed:
- Python (version 3.8)
- OpenCV (version X.X.X)
- Numpy (version X.X.X)
- PIL (version X.X.X)
- BeautifulSoup4 (version X.X.X)
-
Set up the project by cloning the repository and installing the required dependencies.
-
Prepare the Whole Slide Images (WSI) and associated files:
- Place the WSI files in the designated directory.
- Ensure the associated annotation files match the specified pattern.
-
Configure the extraction settings:
- Update the configuration file (
config.yaml
) in theConfig
directory according to your needs. - Adjust the extraction module, patches directory, patch size, scaling factor, and other parameters as required.
- Update the configuration file (
-
Run the patch extraction process:
-
Open a terminal and navigate to the project directory.
-
Execute the main script using the following command:
python main.py -c config/config.yaml
Make sure to provide the correct path to the configuration file.
-
-
Monitor the progress and results:
- The patch extraction process will start, and the progress will be displayed in the console.
- Extracted patches will be saved in the specified directory.
The config.yaml
file in the Config
directory allows you to customize the patch extraction process. It includes the
following sections:
WSL_DATA_DIR
: The directory path where the WSI files are located.ASSOCIATED_FILE_PATTERN
: The regular expression pattern used to load the associated annotation files.
EXTRACTION_MODULE
: The name of the patch extraction module to be used.PATCHES_DIR
: The directory path where the extracted patches will be saved.PATCH_SIZE
: The size of the patches to be extracted, specified as [width, height].SCALING_FACTOR
: The scaling factor applied to the patch size for improved resolution.USE_CIR_MASK
: A boolean value indicating whether to use a circular mask for the patches.CONTEXT_MASK_RADIUS
: The radius of the circular mask applied to the patches.
Contributions to this project are welcome. You can contribute by:
- Reporting issues or bugs.
- Suggesting new features or enhancements.
- Submitting pull requests to fix issues, add features, or improve the code.
Please refer to the Contributing Guidelines for more information.
This project is licensed under the MIT License.