Passed
Push — master ( 9e6838...cf264a )
by Yang
27s
created

Python.DICOM.validate.DICOM_validator()   A

Complexity

Conditions 2

Size

Total Lines 19
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 19
rs 9.8
c 0
b 0
f 0
cc 2
nop 1
1
import sys
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
import logging
3
4
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
5
6
def DICOM_validator(file_path):
0 ignored issues
show
Coding Style Naming introduced by
The name DICOM_validator does not conform to the function naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
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
0 ignored issues
show
Bug introduced by
Global variable 'dicom' undefined at the module level
Loading history...
Coding Style Naming introduced by
The name dicom does not conform to the constant naming conventions ((([A-Z_][A-Z0-9_]*)|(__.*__))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
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):
0 ignored issues
show
Coding Style Naming introduced by
The name DICOM_batchValidator does not conform to the function naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Unused Code introduced by
The argument dir_path seems to be unused.
Loading history...
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)
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (160/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
30
    Birthday date, subject name, etc MUST BE CONSISTENT across a SINGLE subject's folder, RIGHT!
31
32
    :param dir_path:
33
    :return:
34
    """
35
36
37
#if __name__ == '__main__':
38