|
1
|
|
|
from DICOM.elements import DICOM_elements |
|
|
|
|
|
|
2
|
|
|
from LocalDB.query import LocalDB_query |
|
|
|
|
|
|
3
|
|
|
from LocalDB.schema import CNBP_blueprint |
|
|
|
|
|
|
4
|
|
|
from dotenv import load_dotenv |
|
5
|
|
|
import logging |
|
|
|
|
|
|
6
|
|
|
from DICOM.validate import DICOM_validate |
|
|
|
|
|
|
7
|
|
|
#from LORIS.candidates import LORIS_candidates |
|
8
|
|
|
|
|
9
|
|
|
class Integration: |
|
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
@staticmethod |
|
12
|
|
|
def step2_dicom2LORIS(folder_paths): |
|
|
|
|
|
|
13
|
|
|
""" |
|
14
|
|
|
Within each folder, verify they all have the same PatientID. |
|
15
|
|
|
:param folder_paths: |
|
16
|
|
|
:return: |
|
17
|
|
|
""" |
|
18
|
|
|
|
|
19
|
|
|
database_path = load_dotenv("LocalDatabase") |
|
20
|
|
|
|
|
21
|
|
|
logger = logging.getLogger(__name__) |
|
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
for folder in folder_paths: |
|
24
|
|
|
success, DICOM_files = DICOM_validate.path(folder) |
|
|
|
|
|
|
25
|
|
|
|
|
26
|
|
|
if not success or DICOM_files is None: |
|
27
|
|
|
return False |
|
28
|
|
|
|
|
29
|
|
|
# At this point, we know all DICOM files from the folder has the same name. |
|
30
|
|
|
MRN = DICOM_elements.retrieveMRN(DICOM_files[0]) |
|
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
# Store MRN in database. |
|
33
|
|
|
mrn_exist_in_database, _ = LocalDB_query.check_value(database_path, CNBP_blueprint.table_name, CNBP_blueprint.keyfield, MRN) |
|
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
# Continue to next subject if MRN already exist in the database. |
|
36
|
|
|
if mrn_exist_in_database: |
|
37
|
|
|
continue |
|
38
|
|
|
|
|
39
|
|
|
# else database the subject. |
|
40
|
|
|
elif not mrn_exist_in_database: |
|
41
|
|
|
|
|
42
|
|
|
# Create the subject |
|
43
|
|
|
LocalDB_query.create_entry(database_path, CNBP_blueprint.table_name, CNBP_blueprint.keyfield, MRN) |
|
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
# Retrieve the PSCID based on the scanner protocol |
|
46
|
|
|
#DICOM_elements.get_ResearchProtocol() |
|
47
|
|
|
|
|
48
|
|
|
#LORIS_candidates.check_PSCID_compliance(PSCID) |
|
49
|
|
|
|
|
50
|
|
|
# Contact LORIS to request new MRN number. |
|
51
|
|
|
|
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.