Skip to main content

This package provides a set of tools for checking OPV DICOM compliance and converting OPV DICOM to CSV or JSON.

Project description

PyOPV

This package provides functionality for working with the OPV DICOM files provided by various vendors. The package facilitates reading, analyzing, and processing these DICOM files for compliance and data extraction. The primary use case is for handling ophthalmology visual field-related DICOM files and ensuring they meet the latest DICOM standards.

Publication and Citation

PyOPV has been published in the Journal of Glaucoma.

Publication links:

If you use pyopv in your research or software, please cite this paper.

Recommended citation (NLM/PubMed format):

Hallaj S, Boland MV, Halfpenny W, Myers JS, Weinreb RN, Zangwill LM, Baxter SL. PyOPV: An Open-Source Python Package for Ophthalmic Visual Field Data Management. J Glaucoma. 2026 Mar 1;35(3):150-156. doi:10.1097/IJG.0000000000002654. Epub 2025 Feb 17. PMID: 40044977.

@article{hallaj2026pyopv,
  title={PyOPV: An Open-Source Python Package for Ophthalmic Visual Field Data Management},
  author={Hallaj, Shahin and Boland, Michael V. and Halfpenny, William and Myers, Jonathan S. and Weinreb, Robert N. and Zangwill, Linda M. and Baxter, Sally L.},
  journal={J Glaucoma},
  year={2026},
  month={mar},
  volume={35},
  number={3},
  pages={150--156},
  doi={10.1097/IJG.0000000000002654},
  pmid={40044977}
}

Installation

  1. Install the package from PyPi:
pip install pyopv

Once installed, you can import the package and use its various utilities for DICOM file processing:

import pyopv

Working with PyOPV

Sample Code Snippet for Processing DICOM Files:

To begin processing, you'll first need the latest SAP DICOM standard. This standard is updated regularly to ensure compliance with industry norms. The package allows you to download the latest version of the SAP DICOM standard in CSV format. Here's a simple example:

from pyopv import get_dicom_standard

# Download and save the latest DICOM standard
get_dicom_standard() # This will create a CSV file in the current working directory

Processing a Single File:

Here’s how you can process a single DICOM file to check compliance and extract relevant data:

# Define the path to the DICOM file
file_path = '/path/to/your/dicom/file'

# Read the DICOM file using PyOPV
m_opvdicom = pyopv.read_dicom(file_path)

# Check if the file meets the DICOM compliance standards
missing_tags_df, incorrect_tags_df = m_opvdicom.check_dicom_compliance()

# Display missing and incorrect tags
display(missing_tags_df)
display(incorrect_tags_df)

# Convert the DICOM data to a pandas DataFrame for further analysis
m_opvdicom_df = m_opvdicom.to_pandas()
display(m_opvdicom_df)

# Extract pointwise data from the DICOM file and convert it to a pandas DataFrame
pointwise_data = m_opvdicom.pointwise_to_pandas()
display(pointwise_data)

# Alternatively, save the pointwise data as a nested JSON structure for more flexible use cases
pointwise_data_json = m_opvdicom.pointwise_to_nested_json()

Bulk Processing OPV DICOM Files:

For scenarios where you need to process multiple DICOM files from a directory, PyOPV provides an efficient bulk processing capability. Here's how to do it:

# Import the necessary class for handling multiple DICOM files
from pyopv import OPVDicomSet

# Specify the directory containing your DICOM files
dicom_directory = '/path/to/your/dicom/files'

# Read all the DICOM files in the specified directory
m_opvdicoms, errors = pyopv.read_dicom_directory(dicom_directory, file_extension='dcm')

# Check for missing tags across all files in the directory
missingtags_df = m_opvdicoms.check_dicom_compliance()
display(missingtags_df)

# Convert all DICOM files to pandas DataFrames, returning a wide DataFrame for analysis
result_df, error_df = m_opvdicoms.to_pandas()
display(result_df)
display(error_df)

# Similarly, extract pointwise data from all files in the directory and convert to DataFrames
pointwise_data, error_df = m_opvdicoms.pointwise_to_pandas()
display(pointwise_data)
display(error_df)

# Optionally, save the pointwise data into a nested JSON structure for each file
nested_json = m_opvdicoms.opvdicoms_pointwise_to_nested_json()

With these utilities, PyOPV makes it easy to handle large-scale DICOM datasets while ensuring compliance with industry standards. The ability to extract, analyze, and convert data into user-friendly formats like CSV, pandas DataFrames, and JSON structures helps streamline the workflow for researchers and clinicians working with ophthalmic imaging data.

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

pyopv-0.1.2.3.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

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

pyopv-0.1.2.3-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

Details for the file pyopv-0.1.2.3.tar.gz.

File metadata

  • Download URL: pyopv-0.1.2.3.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for pyopv-0.1.2.3.tar.gz
Algorithm Hash digest
SHA256 33f5d1dca89313dce4d03fd24778f46274153ec33bd37148a1d8799f62fdc174
MD5 444e1ef33e694b19939024fdfbbb95f6
BLAKE2b-256 516a94fc23ed39fc7569adb7c3499d138e80b1e0ee6901edce65bc5e9855336f

See more details on using hashes here.

File details

Details for the file pyopv-0.1.2.3-py3-none-any.whl.

File metadata

  • Download URL: pyopv-0.1.2.3-py3-none-any.whl
  • Upload date:
  • Size: 19.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for pyopv-0.1.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b90665a733119fe5336f82ea7103734c38058035a17a0e0908459d262c7e4139
MD5 62df2ac325e5ced707b3e6274b2134f0
BLAKE2b-256 960dc5d864836b1cb914f91beb4ac6b05404ee08cf402d3a2a1e5e61f928eb95

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