| Conditions | 2 |
| Total Lines | 19 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import sys |
||
| 6 | def DICOM_validator(file_path): |
||
| 7 | """ |
||
| 8 | validate to check if the DICOM file is an actual DICOM file. |
||
| 9 | :param file_path: |
||
| 10 | :return: |
||
| 11 | """ |
||
| 12 | logger = logging.getLogger(__name__) |
||
| 13 | |||
| 14 | global dicom |
||
| 15 | dicom = None |
||
| 16 | |||
| 17 | from pydicom.filereader import InvalidDicomError |
||
| 18 | from pydicom.filereader import read_file |
||
| 19 | try: |
||
| 20 | dicom = read_file(file_path) |
||
| 21 | except InvalidDicomError: |
||
| 22 | logger.info(file_path + " is not a DICOM file. Skipping") |
||
| 23 | return False, None |
||
| 24 | return True, dicom |
||
| 25 | |||
| 38 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.