예제 #1
0
def test_orthanc_upload():

    O = Orthanc()
    O.clear()

    ROOTP = "~/data/dcm/ibis2"
    D = DicomDirectory(ROOTP)

    d = D.get("IM1", binary=True)
    print(d.summary())
    O.put(d)
    g = O.get(d.oid(), dlvl=DLv.INSTANCE)
    Dixel.comparator = CTy.METADATA
    assert d == g

    e = Dixel.from_child(d)
    h = O.get(e.oid(), dlvl=DLv.SERIES)
    assert e == h

    f = Dixel.from_child(e)
    i = O.get(f.oid(), dlvl=DLv.STUDY)
    assert f == i
예제 #2
0
                      archive: Orthanc = None,
                      clear_source: bool = False):

    for oid in queue.inventory():
        anonymize_and_send_w_registry(oid, queue, reg, archive, clear_source)


def review_patient_ids(queue: Orthanc):

    for study_oid in queue.inventory():
        study_dx = O.get(study_oid)
        pt_id = best_pt_id(study_dx)
        print("------------------------")
        print(f"Patient ID: {study_dx.tags.get('PatientID')}")
        print(f"Patient Name: {study_dx.tags.get('PatientName')}")
        print(f"Best Patient ID: {pt_id}")


if __name__ == "__main__":

    O = Orthanc(url=ORTHANC_QUEUE_URL)
    P = Orthanc(url=ORTHANC_PEER_URL)
    if CLEAR_TARGET:
        input("Are you sure that you want to clear the target archive?")
        P.clear()
    H = HashRegistry(cache_file=CACHE_FILE)
    # anonymize_and_send_w_registry(STUDY_OID, O, H, P, clear_source=CLEAR_SOURCE)

    anon_and_push_all(O, H, P, clear_source=CLEAR_SOURCE)
    # review_patient_ids(O)
예제 #3
0
                    print(f"Registered {n} files")
                H.put(dx)
                if upload and O is not None:
                    o += 1
                    if o % ANNOUNCEMENT_INTERVAL == 0:
                        print(f"Uploaded {o} files")
                    O.put(dx)

    toc = time.time()
    print(f"----------------------------")
    print(f"Checked {m} files")
    print(f"Registered new {n} instances")
    print(f"Uploaded {o} instances")
    print(f"Elapsed time: {toc-tic:.2f} ({max([n,1])/(toc-tic):.2f}dx/s)")
    print(f"----------------------------")

    H.shelve()

    pprint(H.find(q={"dlvl": DLv.STUDY}))


if __name__ == "__main__":

    D = DicomDirectory(root=ROOT_PATH)
    H = HashRegistry(clear_cache=CLEAR_HASHES, cache_file=CACHE_FILE)
    O = Orthanc(url=ORTHANC_URL)
    if CLEAR_DICOM:
        input("Are you sure that you want to clear the queue?")
        O.clear()
    register_path(D, H, O, upload=UPLOAD_DICOM)