Skip to main content

Downloads arXiv Read the Docs PyPI version GitHub Tutorial RLAD + PVBM Tutorial Download on the App Store


PVBM: A Python Vasculature Biomarker Toolbox Based on Retinal Blood Vessel Segmentation

Jonathan Fhima • Jan Van Eijgen • Ingeborg Stalmans • Yevgeniy Men • Moti Freiman • Joachim A. Behar

Pipeline

Installation

Available on pip. Run:

pip install pvbm

Vasculature Biomarkers

Digital fundus images are specialized photographs of the interior surface of the eye, capturing detailed views of the retina, including blood vessels, the optic disc, and the macula. They are invaluable tools in ophthalmology and optometry for diagnosing and monitoring various ocular diseases, including diabetic retinopathy, glaucoma, and macular degeneration.

The fundus image allows for the visualization of numerous vascular features, notably the arterioles (small arteries) and venules (small veins). Advanced image processing and machine learning techniques now enable the extraction of arterioles and venules from fundus images, a process known as A/V segmentation. By isolating these vessels, we can examine their morphology and distribution in greater detail, revealing subtle changes that might otherwise go unnoticed.

From this A/V segmentation, we can compute vasculature biomarkers, which are quantifiable indicators of biological states or conditions. By analyzing these vasculature biomarkers, healthcare professionals can gain deeper insights into a patient's ocular health and potentially detect early signs of disease. This approach represents a promising frontier in eye care, allowing for more proactive and personalized treatment strategies.

Fifteen biomarkers have been engineered independently on the arterioles and venules segmentation, namely:

  • Area: Area of the blood vessels computed by summing the number of pixels within the segmented arteriole or venule regions. Expressed in square pixels.
  • Length: Cumulative length of the segmented blood vessels, calculated as the distance required to traverse the entire skeleton. Expressed in pixels.
  • Tortuosity Index: Tortuosity measure based on the overall arc-chord ratio.
  • Median Tortuosity: Median value of the per-vessel tortuosity, computed using the arc-chord ratio.
  • Number of Startpoints: Number of skeleton points situated on the optic disc, representing vessel start points.
  • Number of Endpoints: Number of skeleton points terminating the blood vessels.
  • Number of Intersection Points: Number of skeleton points where vessels branch into two smaller vessels.
  • Median Branching Angle: Median value of the branching angle distribution evaluated for all blood vessels. Expressed in degrees (°).
  • Capacity Dimension: Also known as the box-counting dimension, measuring the space-filling capacity of the pattern.
  • Entropy Dimension: Also known as the entropy dimension, measuring the distribution of the pattern.
  • Correlation Dimension: Also known as the correlation dimension, measuring the correlation of the pattern.
  • Singularity Length: Range of fluctuation in the fractal dimension, providing insights into the complexity of local variations within the image.
  • Central Retinal Arteriolar Equivalent (Knudtson and Hubbard): Central Retinal Arterial Equivalent (CRAE) computed using the Knudtson or Hubbard formula, estimating the caliber of the central retinal arteriole.
  • Central Retinal Venular Equivalent (Knudtson and Hubbard): Central Retinal Venous Equivalent (CRVE) computed using the Knudtson or Hubbard formula, estimating the caliber of the central retinal vein.
  • Arterio-Venous Ratio (Knudtson and Hubbard): The AVR is calculated using the ratios of CRAE and CRVE. This ratio assesses the relationship between retinal arterioles and venules, providing insights into vascular health and potential cardiovascular risk factors. (It is not included in the tutorial but can be easily inferred by dividing the CRAE by the CRVE.)

Look at the tutorial for a code example, or the RLAD + PVBM end-to-end tutorial for a full pipeline starting from a raw fundus image, segmented with RLAD-SwinV2-Large.

Artery/Veins Blood Vessel Segmentation Datasets

You can access the external test set used in the LUNet paper directly from PVBM: (These include Crop_HRF, INSPIRE, and UNAF.)

from PVBM.Datasets import PVBMDataDownloader
path_to_save_datasets = "../PVBM_datasets"
dataset_downloader = PVBMDataDownloader()
dataset_downloader.download_dataset(name="Crop_HRF", save_folder_path=path_to_save_datasets)
dataset_downloader.download_dataset(name="INSPIRE", save_folder_path=path_to_save_datasets)
dataset_downloader.download_dataset(name="UNAF", save_folder_path=path_to_save_datasets)
print("Images downloaded successfully")

Optic Disc Segmentation

We have included an optic disc segmenter to perform more accurate VBM estimation. This has been done using LUNet.

from PVBM.DiscSegmenter import DiscSegmenter

# Initialize the segmenter
segmenter = DiscSegmenter()

# Define the segmentation path and replace specific parts of the path
image_path = '../PVBM_datasets/INSPIRE/images/image13.png'
# Extract the segmentation
optic_disc = segmenter.segment(image_path=image_path)
#Extract the optic disc features
center, radius, roi, zones_ABC = segmenter.post_processing(segmentation=optic_disc, max_roi_size = 600)

Geometrical VBMs

### First run the optic disc segmentation snippet to extract center, radius, roi, zones_ABC

from PVBM.GeometryAnalysis import GeometricalVBMs #Import the geometry analysis module
import numpy as np
from skimage.morphology import skeletonize
from PIL import Image
#Preprocessing and roi extraction
blood_vessel_segmentation_path = '../PVBM_datasets/INSPIRE/artery/image13.png'
segmentation = np.array(Image.open(blood_vessel_segmentation_path))/255 #Open the segmentation
skeleton = skeletonize(segmentation)*1
geometricalVBMs = GeometricalVBMs() #Instanciate a geometrical VBM object
segmentation_roi, skeleton_roi = geometricalVBMs.apply_roi(
    segmentation=segmentation, 
    skeleton=skeleton,
    zones_ABC=zones_ABC,
    roi=roi
)
vbms, visual = geometricalVBMs.compute_geomVBMs(
    blood_vessel=segmentation_roi,
    skeleton=skeleton_roi,
    xc=center[0],
    yc=center[1],
    radius=radius
)
area, TI, medTor, ovlen, medianba, startp, endp, interp = vbms

Fractal Analysis

### First run the optic disc segmentation snippet to extract center, radius, roi, zones_ABC
### Then compute the segmentation_roi array as done in the previous code snippet

from PVBM.FractalAnalysis import MultifractalVBMs
import numpy as np
from PIL import Image
fractalVBMs = MultifractalVBMs(n_rotations = 25,optimize = True, min_proba = 0.0001, maxproba = 0.9999)
D0,D1,D2,SL = fractalVBMs.compute_multifractals(segmentation_roi.copy())

Central Retinal Equivalent Analysis

### First run the optic disc segmentation snippet to extract center, radius, roi, zones_ABC

from PVBM.CentralRetinalAnalysis import CREVBMs
import numpy as np
from skimage.morphology import skeletonize
from PIL import Image
#Preprocessing and roi extraction
creVBMs = CREVBMs()

####Artery
blood_vessel_segmentation_path = '../PVBM_datasets/INSPIRE/artery/image13.png'
segmentation = np.array(Image.open(blood_vessel_segmentation_path))/255 #Open the segmentation
skeleton = skeletonize(segmentation)*1
segmentation_roi, skeleton_roi = creVBMs.apply_roi(
    segmentation=segmentation,
    skeleton=skeleton,
    zones_ABC=zones_ABC
)
out, _ = creVBMs.compute_central_retinal_equivalents(
    blood_vessel=segmentation_roi.copy(),
    skeleton=skeleton_roi.copy(),
    xc=center[0],
    yc=center[1],
    radius=radius,
    artery = True,
    Toplot = False #This allows to generate the CRE visualisation but require a lot of RAM
    # If you are only interested about the VBMs values then set Toplot to False
)
craek, craeh = out["craek"], out["craeh"]  # out = (result_dict, plot_list)

####Veins
blood_vessel_segmentation_path = '../PVBM_datasets/INSPIRE/veins/image13.png'
segmentation = np.array(Image.open(blood_vessel_segmentation_path))/255 #Open the segmentation
skeleton = skeletonize(segmentation)*1
segmentation_roi, skeleton_roi = creVBMs.apply_roi(
    segmentation=segmentation,
    skeleton=skeleton,
    zones_ABC=zones_ABC
)
out, _ = creVBMs.compute_central_retinal_equivalents(
    blood_vessel=segmentation_roi.copy(),
    skeleton=skeleton_roi.copy(),
    xc=center[0],
    yc=center[1],
    radius=radius,
    artery = False,
    Toplot = False #This allows to generate the CRE visualisation but require a lot of RAM
    # If you are only interested about the VBMs values then set Toplot to False
)
crvek, crveh = out["crvek"], out["crveh"]

AVR_h = craeh/crveh
AVR_k = craek/crvek

print(f"CRAE_H: {craeh}, CRAE_K: {craek},CRVE_H: {crveh}, CRVE_K: {crvek}, AVR_H: {AVR_h}, AVR_K: {AVR_k} ")

Citation

If you find this code or data to be useful for your research, please consider citing the following papers.

@inproceedings{fhima2022pvbm,
  title={PVBM: a Python vasculature biomarker toolbox based on retinal blood vessel segmentation},
  author={Fhima, Jonathan and Eijgen, Jan Van and Stalmans, Ingeborg and Men, Yevgeniy and Freiman, Moti and Behar, Joachim A},
  booktitle={European Conference on Computer Vision},
  pages={296--312},
  year={2022},
  organization={Springer}
}

@article{fhima2024lunet,
    title={LUNet: deep learning for the segmentation of arterioles and venules in high resolution fundus images},
    author={Fhima, Jonathan and Van Eijgen, Jan and Moulin-Roms{\'e}e, Marie-Isaline Billen and Brackenier, Helo{\"\i}se and Kulenovic, Hana and Debeuf, Val{\'e}rie and Vangilbergen, Marie and Freiman, Moti and Stalmans, Ingeborg and Behar, Joachim A},
    journal={Physiological Measurement},
    volume={45},
    number={5},
    pages={055002},
    year={2024},
    publisher={IOP Publishing}
}

@article{fhima2024computerized,
  title={Computerized analysis of the eye vasculature in a mass dataset of digital fundus images: the example of age, sex and primary open-angle glaucoma},
  author={Fhima, Jonathan and Eijgen, Jan Van and Reiner-Benaim, Anat and Beeckmans, Lennert and Abramovich, Or and Stalmans, Ingeborg and Behar, Joachim A},
  journal={medRxiv},
  pages={2024--07},
  year={2024},
  publisher={Cold Spring Harbor Laboratory Press}
}

Metadata

Release files for pvbm 3.0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pvbm 3.0.1.6
File Size Uploaded Provenance Actions
pvbm-3.0.1.6.tar.gz 5.1 MB Without provenance Details for pvbm-3.0.1.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pvbm 3.0.1.6
File Interpreter ABI Platform Actions
pvbm-3.0.1.6-py3-none-any.whl Python 3 none any Details for pvbm-3.0.1.6-py3-none-any.whl

Total release size: 10.2 MB

Release files / pvbm-3.0.1.6.tar.gz

Download URL pvbm-3.0.1.6.tar.gz
Size 5.1 MB
Tags Source
SHA-256 checksum
How to use checksums
948102e072258b541cb6ea56aa35001a3c111cbbf396e706b456842bc2464e0a
BLAKE2b-256 checksum
How to use checksums
630277a45bd7942421f7e94e5e2829f9a42292b9b70d70467b3fff91da6afee4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release files / pvbm-3.0.1.6-py3-none-any.whl

Download URL pvbm-3.0.1.6-py3-none-any.whl
Size 5.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
1b1e62786c175da502d3f790b869dd361b5304246acfc314354dc7a94ed42f93
BLAKE2b-256 checksum
How to use checksums
8c962f2e62fa2fc71f885001ffac1d7763bbd83ba82299575fb78a00cf774877
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Security for pvbm 3.0.1.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

3.0.1.6 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page