Esempio n. 1
0
    def put_accession(self, accession_number, dest: Orthanc):

        dixels = self.find_items_for(accession_number)
        for d in dixels:
            # logging.debug(type(d))
            d = self.filehandler.get(d, view="file")
            dest.put(d)
Esempio n. 2
0
def test_psend(setup_orthanc0, setup_orthanc1):

    O = Orthanc(peername="peer0")
    print(O)
    O.check()

    O2 = Orthanc(port=8043, peername="peer0")
    print(O2)
    O2.check()

    dicom_dir = find_resource("resources/dcm")
    D = DcmDir(path=dicom_dir)

    d = D.get("IM2263", view=DixelView.TAGS_FILE)
    O2.put(d)

    logging.debug(O2.gateway._get("peers"))

    O2.psend(d.oid(), O)

    e = O.get(d.oid(), level=DicomLevel.INSTANCES)

    logging.debug(e)

    assert d.oid() == e.oid()
Esempio n. 3
0
def test_orthanc_upload(setup_orthanc0):

    logging.debug("Test Orthanc Upload")

    O = Orthanc()

    dicom_dir = find_resource("resources/dcm")
    D = DcmDir(path=dicom_dir)
    d = D.get("IM2263", view=DixelView.TAGS_FILE)

    O.put(d)

    q = {"PatientID": "AW15119516.678.1392297407"}
    result = O.find(q)

    if result:
        id = result[0]

    logging.debug(id)

    result = O.exists(id)

    logging.debug(result)

    assert (result)

    O.delete(d)

    result = O.exists(id)
    assert (not result)
Esempio n. 4
0
def orth_test_runner():
    O = Orthanc()
    dicom_dir = find_resource("resources/dcm")
    D = DcmDir(path=dicom_dir)

    print("Starting script")
    time.sleep(1)
    d = D.get("IM2263", view=DixelView.FILE)
    O.put(d)
    O.check()
    print("Ending script")
Esempio n. 5
0
def _handle_instance_in_dcm_dir(item: Dixel, orth: Orthanc, salt: str):

    orth.put(item)
    anon = ShamDixel.from_dixel(item, salt=salt)
    afile = orth.anonymize(anon, replacement_map=anon.orthanc_sham_map())
    anon.file = afile
    orth.put(anon)
    orth.delete(item)

    anon_study_id = anon.sham_parent_oid(DCMLv.STUDIES)
    logging.debug(anon_study_id)
    logging.debug(tagged_studies)
    if anon_study_id not in tagged_studies:
        logging.debug("Tagging parent study: {}".format(anon_study_id))
        siren_info = pack_siren_info(anon)
        orth.gateway.put_metadata(anon_study_id, DCMLv.STUDIES, "siren_info",
                                  siren_info)
        tagged_studies.append(anon_study_id)
Esempio n. 6
0
 def poll(self, dest: Orthanc = None):
     if datetime.now() > self._next_study:
         print("{}: Study ready to push".format(self.station_name))
         study = self.gen_study()
         pprint(study.tags)
         for d in study.instances():
             d.gen_file()
             if dest:
                 dest.put(d)
         delay = 60 * 60 / self.studies_per_hour
         R = random.Random()
         delay = R.randint(int(0.5 * delay), int(1.5 * delay))
         self._next_study = datetime.now() + timedelta(seconds=delay)
         print("{}: Next study at {}".format(self.station_name,
                                             self._next_study))
     else:
         logging.debug("No study, next at {}".format(self._next_study))
         time.sleep(self.action_interval)
Esempio n. 7
0
def test_anon(setup_orthanc0):
    O = Orthanc()
    dicom_dir = find_resource("resources/dcm")
    D = DcmDir(path=dicom_dir)
    d = D.get("IM2263", view=DixelView.TAGS_FILE)
    O.put(d)

    d.tags["AccessionNumber"] = "123456"
    d.tags["PatientBirthDate"] = "20000101"
    d.tags["PatientID"] = "ABC"
    d.tags["PatientName"] = "XYZ"
    d.level = DicomLevel.STUDIES
    e = ShamDixel.from_dixel(d)
    rep = e.orthanc_sham_map()

    O.anonymize("959e4e9f-e954be4e-11917c87-09d0f98f-7cc39128",
                level=DicomLevel.STUDIES,
                replacement_map=rep)
Esempio n. 8
0
import os, yaml
from diana.apis import DcmDir, Orthanc

D = DcmDir(path="/data")

svcs_t = os.environ.get("DIANA_SERVICES")
svcs = yaml.load(svcs_t)

print(svcs)

args = svcs.get("renalstone")
O = Orthanc(**args)

for d in D.files(rex="*.zip"):

    file_set = D.get_zipped(d)

    for f in file_set:

        O.put(f)