Skip to main content

Automated lung size measurements using deep learning and computer vision on portable chest radiographs.

Project description

AILungMeasure

AILungMeasure is a Python package designed for automated lung size measurements using deep learning and computer vision on portable chest radiographs. This package aims to improve accuracy, reduce variability, and streamline the lung transplantation size matching process.

Model_Framework

Features

  • Automated lung mask extraction from chest radiographs
  • Feature points detection to generate lung height and width measurements
  • Validation against measurements reported by radiologists
  • Robust performance even with technically challenging radiographs

Installation

You can install AILungMeasure via pip:

pip install AILungMeasure

Usage

Loading the Model

AILungMeasure includes a pre-trained model for lung size measurements. When importing the package, the model will be automalically downloaded and loaded.

import AILungMeasure

Segmenting Lung Images

To get the lung mask, use the get_mask function:

input_image = '/path/to/your/image' # can be dicom, jpg, png, etc.. 
mask = AILungMeasure.get_mask(input_image)

To visualize the mask, use the show_mask function:

mask = AILungMeasure.show_mask(input_image)
 
# or plot it 
matplotlib.pyplot.imshow(mask)

Get Measurements

To plot the lung measurements, use the show_measurments function:

AILungMeasure.show_measurments(input_image , dpi=200) # dpi controls the image resolution

To get the measurments, use the get_measurments function:

measurments = AILungMeasure.get_measurments(input_image)

Note that this will work if the input_image is dicom, which already includes the pixel size in its meta data. The reported measurments will be in mm.
If you are using jpg, png, etc.. then the returned measurments will be in pixels.

Example Script

import AILungMeasure

input_image = '/media/Mostafa12TB/CXRs/dicom-3_15_2024/DICOMS Only/EE0C0DF7'
AILungMeasure.show_measurments(input_image)

Model_Framework

AILungMeasure.get_measurments(input_image)
# Measurments in mm if input image is dicom
{'R-ACPA': 209.51056325555803,
 'R-AMD': 155.81790884489396,
 'L-ACPA': 235.95200821775532,
 'L-AMD': 204.3306113771206,
 'width-at-hilum': 258.89750000000004,
 'width-at-base': 287.53000000000003}

License

This project is licensed under the Creative Commons ATTRIBUTION-NONCOMMERCIAL-SHAREALIKE 4.0 INTERNATIONAL.

Contact

For questions or issues, please contact Mostafa Ismail at mostafa.ismail.k@gmail.com.

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

ailungmeasure-0.1.6.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

AILungMeasure-0.1.6-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file ailungmeasure-0.1.6.tar.gz.

File metadata

  • Download URL: ailungmeasure-0.1.6.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.60.0 CPython/3.8.10

File hashes

Hashes for ailungmeasure-0.1.6.tar.gz
Algorithm Hash digest
SHA256 1c7c87c41cdbf464106188c8f9e2a27a69fe841c5066d6c740fc695d05c8b2b3
MD5 3d934942624cbb9cbb802c31bc77b94f
BLAKE2b-256 6aadea0aacc19952a4de1b89e7001e374814233a56bbe622b0493f2b40b887dd

See more details on using hashes here.

File details

Details for the file AILungMeasure-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: AILungMeasure-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.60.0 CPython/3.8.10

File hashes

Hashes for AILungMeasure-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 7d4d738c4cad6fc434c0b704a2b38d6de85f4e754ca4ea0fb3339bb8a5ae5776
MD5 f96d501bee6e54e1a8467ef38c7de990
BLAKE2b-256 849ded3a25fe489e92bc6070c6ec00a4d3417b1518192d22430fa8d2309f483b

See more details on using hashes here.

Supported by

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