Skip to main content

A tool for processing and analyzing digital pathology images stored in DICOM format.

Project description

MiniPath README

Overview

MiniPath is a Python-based tool designed for processing and analyzing digital pathology images stored in DICOM format, particularly from whole slide images (WSIs). The primary focus of MiniPath is to extract and rank diverse image patches based on entropy and cluster analysis. The tool leverages several machine learning techniques, including Principal Component Analysis (PCA) and KMeans clustering, to identify representative patches that can be used for further analysis at higher magnification levels.

MiniPath includes various utilities for reading DICOM files from local storage or Google Cloud Storage (GCS), calculating image entropy, and selecting representative patches for downstream processing.

Key Features

  • DICOM Image Handling: Supports reading DICOM images from local paths, GCS, and DICOMweb.
  • Entropy Calculation: Uses entropy as a feature for image patch diversity ranking.
  • PCA and Clustering: Applies PCA to reduce feature dimensionality and KMeans clustering to group similar patches.
  • Patch Ranking: Ranks patches for diversity and selects representative patches.
  • High-Resolution Image Extraction: Extracts relevant high-magnification frames corresponding to selected low-magnification patches.

Installation

To install the necessary dependencies, you can use the provided requirements.txt file:

pip install -r requirements.txt

Environment Setup

This tool relies on environment variables to connect to Google Cloud services. Ensure that you have a .env file in the root directory with the following contents:

GOOGLE_APPLICATION_CREDENTIALS=path/to/your/credentials.json

Replace path/to/your/credentials.json with the actual path to your Google Cloud credentials file.

Usage

Initialization

from minipath import MiniPath
minipath = MiniPath(csv='path/to/csv_file.csv', subset=True)
  • csv: Path to a CSV file containing metadata and GCS URLs for high-magnification DICOM images.
  • subset: Boolean flag to decide if only a subset of diverse patches should be used. Defaults to True. If you set it to false, all patches will be extracted.

Get Representative Patches

minipath.get_representatives(full_url='https://path.to.dicom.web/resource')
  • full_url: The URL pointing to the low-magnification DICOM image. This method extracts image patches from the provided DICOM file, computes entropy for each patch, applies PCA, and clusters the patches to select the most representative ones.

Extract High-Resolution Frames

high_res_frames = minipath.get_high_res()
  • high_res_patches will be an array of dictionaries with the following keys:
    • 'row_min': Pixel coordinate of first row
    • 'row_max': Pixel coordinate of last row
    • 'col_min': Pixel coordinate of first col
    • 'col_max': Pixel coordinate of last col
    • 'frame': The dicom frame that represents this coordinate set
    • 'img_array': a numpy array of the image values

This method extracts high-resolution frames corresponding to the representative patches identified at low magnification. You can loop through this array for running a model.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

minipath-0.1.1.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

minipath-0.1.1-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file minipath-0.1.1.tar.gz.

File metadata

  • Download URL: minipath-0.1.1.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for minipath-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0553171b82b35323f0d0ab1079d7be525dbe5d72f3d1b887e51a95e625e2ac0f
MD5 25df8a9d01a1a455a6cf8c46b59d4a7a
BLAKE2b-256 428888a1669a1df4e1b97d2e7d9a7f8f15be73d5a4b08c18d4deb9995db8ddcb

See more details on using hashes here.

File details

Details for the file minipath-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: minipath-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for minipath-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 def34bb748a945d63c735934fdd9b9cb52546db54613f664a068cf3903893af4
MD5 fdfed653d54143c9403990edadcdeda7
BLAKE2b-256 032c4c2b29fb6f3db8c5488d392ee46daf7ce31f67f2a5a421e557ff26a35e0b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page