Exemple #1
0
 def scan(identifier):
     examination = Catalog.get(identifier)
     #Zmiana statusu w bazie danych
     examination.status = Status.scanning
     Catalog.commit()
     print("Scanning patient")
     return
Exemple #2
0
 def scan_status(identifier):
     examination = Catalog.get(identifier)
     #Zmiana statusu w bazie danych
     examination.status = Status.finished_scanning
     Catalog.commit()
     print("The Scan was executed")
     return
Exemple #3
0
 def start_reconstruction(identifier):
     examination = Catalog.get(identifier)
     #Zmiana statusu w bazie danych
     examination.status = Status.reco_queued
     Catalog.commit()
     print("Reconstruction queued")
     return
Exemple #4
0
 def register(identifier):
     #Generowanie identyfikatora zadania na klastrze i zapis do bazy danych
     examination = Catalog.get(identifier)
     #Zmiana statusu w bazie danych
     examination.status = Status.reco_registered
     Catalog.commit()
     print("Reconstruction registered")
     return
Exemple #5
0
 def mpps_completed(identifier):
     pydicom.dcmread("mpps_completed.dcm", force=True)
     examination = Catalog.get(identifier)
     #Zapis pliku mpps_discontinued.dcm do bazy danych
     examination.path = "C:\\Users\\Anna\\Desktop\\pynetdicom_git_clone\\pynetdicom3\\pynetdicom3\\apps\\findscu\\mpps_completed.dcm"
     #Zmiana statusu w bazie danych
     examination.status = Status.dicom_completed
     Catalog.commit()
     return
Exemple #6
0
 def get_output_data(identifier, file_path_cluster):
     final_image_controller = "C:\\Users\\Anna\\Desktop\\pynetdicom_git_clone\\pynetdicom3\\pynetdicom3\\apps\\findscu\\controller\\"
     shutil.copy(file_path_cluster, final_image_controller)
     examination = Catalog.get(identifier)
     #Zmiana statusu w bazie danych
     examination.status = Status.send_final_data
     Catalog.commit()
     print("The results have been sent")
     return
Exemple #7
0
 def send_input_data(identifier, path):
     cluster_path = "C:\\Users\\Anna\\Desktop\\pynetdicom_git_clone\\pynetdicom3\\pynetdicom3\\apps\\findscu\\cluster"
     file_cluster_path = shutil.copy(path, cluster_path)
     examination = Catalog.get(identifier)
     #Zmiana statusu w bazie danych
     examination.status = Status.reco_data_ready
     Catalog.commit()
     print("Downloading input data for reconstruction")
     return file_cluster_path
Exemple #8
0
 def build_final_image(identifier, path2):
     cluster_path = 'C:\\Users\\Anna\\Desktop\\pynetdicom_git_clone\\pynetdicom3\\pynetdicom3\\apps\\findscu\\cluster\\'
     final_file_cluster_path = os.path.join(cluster_path,
                                            str(identifier) + "_final")
     os.rename(path2, final_file_cluster_path)
     examination = Catalog.get(identifier)
     #Zmiana statusu w bazie danych
     examination.status = Status.build_final_image
     Catalog.commit()
     print("Final image construction in progress")
     return final_file_cluster_path
Exemple #9
0
 def save_final_data(identifier, file_path_cluster):
     final_image_controller = "C:\\Users\\Anna\\Desktop\\pynetdicom_git_clone\\pynetdicom3\\pynetdicom3\\apps\\findscu\\controller\\"
     final_file = shutil.copy(file_path_cluster, final_image_controller)
     examination = Catalog.get(identifier)
     #Zapis pliku do bazy danych
     examination.final_image = final_file
     #Zmiana statusu w bazie danych
     examination.status = Status.procedure_completed
     Catalog.commit()
     print("Final data are saved")
     return
Exemple #10
0
 def send_scan_results(identifier):
     scanner_pet_path = "C:\\Users\\Anna\\Desktop\\pynetdicom_git_clone\\pynetdicom3\\pynetdicom3\\apps\\findscu\\scanner\\"
     controller_path = "C:\\Users\\Anna\\Desktop\\pynetdicom_git_clone\\pynetdicom3\\pynetdicom3\\apps\\findscu\\controller\\"
     file_scanner_path = os.path.join(scanner_pet_path, str(identifier))
     file_controller_path = shutil.copy(file_scanner_path, controller_path)
     examination = Catalog.get(identifier)
     #Zapis pliku do bazy danych
     examination.raw_data_file = file_controller_path
     #Zmiana statusu w bazie danych
     examination.status = Status.send_raw_data
     Catalog.commit()
     print("The results were sent to the controller")
     return file_controller_path
Exemple #11
0
def run():
    #Zapytanie przez UI personel medyczny w formie imienia i nazwiska pacjenta
    name, surname = UI.query()
    #Na UI zwracana jest lista badan pacjentow o podanym imieniu i nazwisku
    list_of_examinations = controller.find_study(name, surname)
    #Personel medyczny wybiera, dla ktorego pacjenta przygotowywany bedzie protokol
    number = UI.do_study(list_of_examinations)

    #Pętla po elementach w scheduled procedure step sequence
    i = 0
    for step in list_of_examinations[number].ScheduledProcedureStepSequence:
        if step.ScheduledStationAETitle == 'FILMDIGITIZE':
            break
        i = +1
    if i > len(list_of_examinations[number].ScheduledProcedureStepSequence):
        print("AE title not found")

    # Tworzenie obiektu badanie, ktory bedzie dodany do bazy danych:
    examination_id = Catalog.newstudy(
        patient_name=str(list_of_examinations[number].PatientName),
        patient_id=list_of_examinations[number].PatientID,
        patients_sex=list_of_examinations[number].PatientSex,
        start_date=datetime.datetime.strptime(
            list_of_examinations[number].ScheduledProcedureStepSequence[i].
            ScheduledProcedureStepStartDate, '%Y%m%d'),
        end_date=datetime.datetime.strptime(
            list_of_examinations[number].ScheduledProcedureStepSequence[i].
            ScheduledProcedureStepEndDate, '%Y%m%d'),
        aetitle=list_of_examinations[number].ScheduledProcedureStepSequence[i].
        ScheduledStationAETitle,
        accession_number=list_of_examinations[number].AccessionNumber,
        requested_procedure_id=list_of_examinations[number].
        RequestedProcedureID,
        final_image=None,
        raw_data_file=None,
        path_mpps=None)

    #Pętla przetwarza badanie, aż nie zakończy się poprawnie lub zgłosi błąd. Dla każdego stanu wykorzystywana jest odpowiednia funkcja, która taki stan obsługuje.
    loop = True
    while (loop):
        examination = Catalog.get(examination_id)
        if examination.status == Status.new:
            #Przesłanie n-create oraz zmiana statusu na inprogress
            controller.mpps_inprogress(examination_id)
        elif examination.status == Status.dicom_inprogress:
            #Wykonywany jest skan pacjenta
            scanner.scan(examination_id)
        elif examination.status == Status.scanning:
            #Sprawdzany jest status skanowania
            scanner.scan_status(examination_id)
        elif examination.status == Status.finished_scanning:
            #Wysyłanie surowych danych ze skanera do kontrolera modalnosci
            path_controller = scanner.send_scan_results(examination_id)
        elif examination.status == Status.send_raw_data:
            #Następuje anonimizacja danych
            cluster.anonymisation(examination_id)
        elif examination.status == Status.finished_anonymisation:
            #Przez API rejestrowane są nowe zadania obliczeniowe. Klaster ma za zadanie zweryfikować nas, że podaje nam identyfikator zadania i czeka na wrzucenie danych
            cluster.register(examination_id)
        elif examination.status == Status.reco_registered:
            #Przesylane sa dane wejsciowe z kontrolera modalnosci na klaster obliczeniowy
            path_file_cluster = cluster.send_input_data(
                examination_id, path_controller)
        elif examination.status == Status.reco_data_ready:
            #Rekonstrukcja obrazu oczekuje w systemie kolejkowym na klastrze obliczeniowym na przydzielenie zasobow obliczeniowych
            cluster.start_reconstruction(examination_id)
        elif examination.status == Status.reco_queued or examination.status == Status.reco_running:
            # Po ukonczeniu rekonstrukcji nastepuje aktualizacja statusu w bazie danych
            cluster.status(examination_id)
        elif examination.status == Status.reco_finished:
            #Wysłanie danych z klastra do kontrolera modalnosci
            cluster.get_output_data(examination_id, path_file_cluster)
        elif examination.status == Status.send_final_data:
            # Budowanie koncowego obrazu na klastrze obliczeniowym
            final_file_cluster = controller.build_final_image(
                examination_id, path_file_cluster)
        elif examination.status == Status.build_final_image:
            #Wysłanie danych z klastra do kontrolera modalnosci
            controller.save_final_data(examination_id, final_file_cluster)
        elif examination.status == Status.procedure_completed:
            #Wysłanie n-create ze statusem completed, co w rzeczywistosci oznacza ukonczenie badania
            controller.mpps_completed(examination_id)
        elif examination.status == Status.dicom_completed:
            #Zakończenie pętli
            loop = False
        elif examination.status == Status.failed:
            # Wysłanie n-create ze statusem discontinued, co oznacza, że badanie zostało anulowane
            controller.mpps_discontinued(examination_id)
            #Zakończenie pętli
            loop = False
    return
Exemple #12
0
 def anonymisation(identifier):
     examination = Catalog.get(identifier)
     #Zmiana statusu w bazie danych
     examination.status = Status.finished_anonymisation
     Catalog.commit()
     return
Exemple #13
0
 def status(identifier):
     examination = Catalog.get(identifier)
     #Zmiana statusu w bazie danych
     examination.status = Status.reco_finished
     Catalog.commit()
     return