Skip to content

Commit

Permalink
Replace removed pydicom API
Browse files Browse the repository at this point in the history
- makes it compatible to pydicom 3
- also promote to beta state
  • Loading branch information
mrbean-bremen committed Sep 9, 2024
1 parent 4f87e59 commit fba9ad6
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The released versions correspond to PyPi releases.

### Infrastructure
* use the current DICOM standard (2024c) for testing
* make the package compatible to `pydicom` 3.0

## [Version 0.6.2](https://pypi.python.org/pypi/dicom-validator/0.6.2) (2024-08-09)
Fixes a regression in version 0.6.1.
Expand Down
45 changes: 29 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ DICOM standard.

*Disclaimer:*
No guarantees are given for the correctness of the results.
This is alpha-stage software and mostly thought as a proof of concept.
This is beta-stage software which is mostly developed as a proof of concept.
Also check the limitations for `validate_iods` described below.

*Note:*
Expand All @@ -40,18 +40,18 @@ pip install dicom-validator

## Usage
```
validate_iods.py [-h] [--standard-path STANDARD_PATH]
[--revision REVISION] [--force-read] [--recreate-json]
[--verbose]
dicomfiles [dicomfiles ...]
dump_dcm_info.py [-h] [--standard-path STANDARD_PATH]
[--revision REVISION] [--max-value-len MAX_VALUE_LEN]
[--show-tags [SHOW_TAGS [SHOW_TAGS ...]]]
[--show-image-data] [--recreate-json]
dicomfiles [dicomfiles ...]
validate_iods [-h] [--standard-path STANDARD_PATH]
[--revision REVISION] [--force-read] [--recreate-json]
[--suppress-vr-warnings] [--verbose]
dicomfiles [dicomfiles ...]
dump_dcm_info [-h] [--standard-path STANDARD_PATH]
[--revision REVISION] [--max-value-len MAX_VALUE_LEN]
[--show-tags [SHOW_TAGS [SHOW_TAGS ...]]]
[--show-image-data] [--recreate-json]
dicomfiles [dicomfiles ...]
```
Use the `--help` option for each script do get usage info.
Use the `--help` option for each script do get more specific usage info.

## Access to the DICOM standard

Expand Down Expand Up @@ -128,17 +128,24 @@ Process finished with exit code 6
As mentioned, if the evaluation of conditions fails, the related module or
tag is considered optional, which may hide some non-conformity.
Condition evaluation may fail if:
- the needed information is not contained in the DICOM file (e.g. verbose
descriptions like "if the Patient is an animal")
- the needed information is not directly contained in the DICOM file (e.g. verbose
descriptions like "if the Patient is an animal", "if the image has been calibrated" etc.)
- the information is related to other DICOM files (e.g. referenced images)
- the parsing failed because the condition is too complicated, unexpected,
or due to a bug (please write an issue if you encounter such a problem)

#### Retired tags
Also note that only the given standard is used to evaluate the files. If
Only the given standard is used to evaluate the files. If
the DICOM file has been written using an older standard, it may conform to
that standard, but not to the newest one. Tags that are retired in the
version of the standard used for parsing are not considered at all.
You can always check against an older standard by using the `--revision` option.

#### Enumerated values and defined terms
Most enumerated values are checked against, but some are ignored due to parsing issues.
Support for more cases may be added in the future.
Defined terms are _not_ checked, because they are allowed to be user-defined, which means
that any value may be valid.

#### Unsupported cases (support may be added in future versions)
- SOP classes not in the table in PS3.3 such as Presentation States are not
Expand Down Expand Up @@ -188,7 +195,9 @@ c:\dev\DICOM Data\SR\image12.dcm

## Build executable on Windows

Here is a sample workflow:
A self-contained Windows executable is contained in the release artifacts.

Here is a sample workflow to build such an executable yourself:
```powershell
# Clone the repository
git clone [email protected]:pydicom/dicom-validator.git
Expand All @@ -204,3 +213,7 @@ pip install -r requirements-dev.txt
# Build executables. They will be placed in the `dist` subfolder.
pyinstaller dicom-validator.spec -y
```

## Contributing
Contributions are very welcome. If you submit a pull request for a bugfix
or a new feature, please make sure to also write respective tests.
8 changes: 4 additions & 4 deletions dicom_validator/tests/validator/test_dicom_file_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path

import pytest
from pydicom import write_file
from pydicom import dcmwrite
from pydicom.dataset import Dataset, FileDataset, FileMetaDataset

from dicom_validator.validator.dicom_file_validator import DicomFileValidator
Expand Down Expand Up @@ -51,14 +51,14 @@ def test_missing_sop_class(self, validator):
file_dataset = FileDataset(
filename, Dataset(), file_meta=self.create_metadata()
)
write_file(filename, file_dataset, write_like_original=False)
dcmwrite(filename, file_dataset, write_like_original=False)
self.assert_fatal_error(validator, filename, "Missing SOPClassUID")

def test_unknown_sop_class(self, validator):
dataset = Dataset()
dataset.SOPClassUID = "Unknown"
file_dataset = FileDataset("test", dataset, file_meta=self.create_metadata())
write_file("test", file_dataset, write_like_original=False)
dcmwrite("test", file_dataset, write_like_original=False)
self.assert_fatal_error(
validator, "test", "Unknown SOPClassUID (probably retired): Unknown"
)
Expand All @@ -79,7 +79,7 @@ def test_non_fatal_errors(self, validator):
dataset = Dataset()
dataset.SOPClassUID = "1.2.840.10008.5.1.4.1.1.2" # CT Image Storage
file_dataset = FileDataset("test", dataset, file_meta=self.create_metadata())
write_file("test", file_dataset, write_like_original=False)
dcmwrite("test", file_dataset, write_like_original=False)
error_dict = validator.validate("test")
assert len(error_dict) == 1
errors = error_dict["test"]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ classifiers = [
"License :: OSI Approved :: MIT License",
"Intended Audience :: Developers",
"Intended Audience :: Healthcare Industry",
"Development Status :: 3 - Alpha",
"Development Status :: 4 - Beta",
"Environment :: Console",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
Expand Down

0 comments on commit fba9ad6

Please sign in to comment.