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.
Installation
- 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
get_dicom_standard()
Processing a Single File:
Here’s how you can process a single DICOM file to check compliance and extract relevant data:
file_path = '/path/to/your/dicom/file'
m_opvdicom = pyopv.read_dicom(file_path)
missing_tags_df, incorrect_tags_df = m_opvdicom.check_dicom_compliance()
display(missing_tags_df)
display(incorrect_tags_df)
m_opvdicom_df = m_opvdicom.to_pandas()
display(m_opvdicom_df)
pointwise_data = m_opvdicom.pointwise_to_pandas()
display(pointwise_data)
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:
from pyopv import OPVDicomSet
dicom_directory = '/path/to/your/dicom/files'
m_opvdicoms, errors = pyopv.read_dicom_directory(dicom_directory, file_extension='dcm')
missingtags_df = m_opvdicoms.check_dicom_compliance()
display(missingtags_df)
result_df, error_df = m_opvdicoms.to_pandas()
display(result_df)
display(error_df)
pointwise_data, error_df = m_opvdicoms.pointwise_to_pandas()
display(pointwise_data)
display(error_df)
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.