| Total Complexity | 3 |
| Total Lines | 29 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import sys |
||
|
|
|||
| 2 | import logging |
||
| 3 | |||
| 4 | logging.basicConfig(stream=sys.stdout, level=logging.INFO) |
||
| 5 | |||
| 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 | |||
| 26 | |||
| 27 | def DICOM_batchValidator(dir_path): |
||
| 28 | """ |
||
| 29 | Some basic information of the participants must be consistent across the files, such as the SCAN DATE (assuming they are not scanning across MIDNIGHT POINT) |
||
| 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.