Passed
Pull Request — master (#3)
by Yang
04:58
created

BatchDateCalculation()   B

Complexity

Conditions 7

Size

Total Lines 23
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 15
nop 1
dl 0
loc 23
rs 8
c 0
b 0
f 0
1
import csv
0 ignored issues
show
Coding Style Naming introduced by
The name DICOM_InfoDump does not conform to the module naming conventions ((([a-z_][a-z0-9_]*)|([A-Z][a-zA-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...
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
from PythonUtils.folder import recursive_list
0 ignored issues
show
introduced by
Unable to import 'PythonUtils.folder'
Loading history...
3
from DICOM.validate import DICOM_validate
0 ignored issues
show
introduced by
Unable to import 'DICOM.validate'
Loading history...
4
from DICOM.elements import DICOM_elements
0 ignored issues
show
introduced by
Unable to import 'DICOM.elements'
Loading history...
5
6
output=[]
0 ignored issues
show
Coding Style introduced by
Exactly one space required around assignment
Loading history...
Coding Style Naming introduced by
The name output 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...
7
8
9
def BatchDateCalculation(path):
0 ignored issues
show
Coding Style Naming introduced by
The name BatchDateCalculation 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...
Coding Style introduced by
This function 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...
10
    file_list = recursive_list(path)
11
    for file in file_list:
12
13
        if DICOM_validate.file(file):
14
15
            # Try to extract these information from the files.
16
            success1, StudyDate = DICOM_elements.retrieve(file, "StudyDate")
0 ignored issues
show
Coding Style Naming introduced by
The name StudyDate does not conform to the variable 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...
17
            success2, PatientBirthDate = DICOM_elements.retrieve(file, "PatientBirthDate")
0 ignored issues
show
Coding Style Naming introduced by
The name PatientBirthDate does not conform to the variable 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...
18
            success3, age = DICOM_elements.computeScanAge(file)
19
20
            # Skip this file if it is not successful.
21
            if not success1 or not success2 or not success3:
22
                continue
23
24
            # Print, store and append the information acquired.
25
            A = [file, StudyDate, PatientBirthDate, str(age)]
0 ignored issues
show
Coding Style Naming introduced by
The name A does not conform to the variable 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...
26
            print(A)
27
            output.append(A)
28
29
    with open("output.csv",'w') as resultFile:
0 ignored issues
show
Coding Style introduced by
Exactly one space required after comma
Loading history...
Coding Style Naming introduced by
The name resultFile does not conform to the variable 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...
30
        wr = csv.writer(resultFile, dialect='excel')
0 ignored issues
show
Coding Style Naming introduced by
The name wr does not conform to the variable 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...
31
        wr.writerow(output)
32
33
34
if __name__ == "__main__":
35
    BatchDateCalculation(r"C:\FullyAnonymizedSubjects\BDP Subjects\BDP_TSE_T2")
0 ignored issues
show
Coding Style introduced by
Final newline missing
Loading history...