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

Python.DICOM.anonymize.DICOM_anonymizer_save_as()   A

Complexity

Conditions 4

Size

Total Lines 20
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 20
rs 9.9
c 0
b 0
f 0
cc 4
nop 3
1
from DICOM.validate import DICOM_validator
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...
introduced by
Unable to import 'DICOM.validate'
Loading history...
2
from DICOM.elements import DICOM_updateElement
0 ignored issues
show
introduced by
Unable to import 'DICOM.elements'
Loading history...
3
4
5
def DICOM_anonymizer(path, PSCID):
0 ignored issues
show
Coding Style Naming introduced by
The name DICOM_anonymizer 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 Naming introduced by
The name PSCID does not conform to the argument 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...
6
    """
7
    Anonymize the DICOMS to remove any identifiable information
8
    :param path:
9
    :param PSCID:
10
    :return:
11
    """
12
13
    return DICOM_anonymizer_save_as(path, PSCID, path)
14
15
16
def DICOM_anonymizer_save_as(path, PSCID, out_path):
0 ignored issues
show
Coding Style Naming introduced by
The name DICOM_anonymizer_save_as 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 Naming introduced by
The name PSCID does not conform to the argument 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
    """
18
    Anonymize the DICOMS to remove any identifiable information
19
    :param path:
20
    :param PSCID:
21
    :return:
22
    """
23
24
    success, dataset = DICOM_validator(path)
0 ignored issues
show
Unused Code introduced by
The variable dataset seems to be unused.
Loading history...
25
    if not success:
26
        return False
27
28
    success1, _ = DICOM_updateElement(path, "PatientID", PSCID, out_path)
29
    success2, _ = DICOM_updateElement(path, "PatientName", PSCID, out_path)
30
31
    if success1 and success2:
0 ignored issues
show
Unused Code introduced by
The if statement can be replaced with 'return bool(test)'
Loading history...
unused-code introduced by
Unnecessary "else" after "return"
Loading history...
32
        return True
33
    else:
34
        return False
35
    return True
0 ignored issues
show
Coding Style introduced by
Final newline missing
Loading history...