예제 #1
0
def test_zip_reader():

    p = find_resource("resources")
    D = DcmDir(path=p)

    f = D.get("dcm/IM2263", view=DixelView.TAGS_FILE)

    gs = D.get_zipped("dcm_zip/test.zip")

    for _g in gs:
        if "2263" in _g.meta["FileName"]:
            g = _g
            break

    logging.debug(f)
    logging.debug(g)

    assert(f.tags["StudyInstanceUID"] == g.tags["StudyInstanceUID"])

    from binascii import hexlify

    logging.debug("f file:")
    logging.debug( hexlify(f.file[1024:2048]) )
    logging.debug("g file:")
    logging.debug( hexlify(g.file[1024:2048]) )

    assert f.file == g.file
예제 #2
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)
예제 #3
0
import os, logging
from pprint import pformat
from diana.apis import DcmDir

logging.basicConfig(level=logging.DEBUG)

location = "/Users/derek/Desktop"

ep = DcmDir(path=location)

files = ["test.dum-1.zip"]

# for fi in ep.files(rex="*.zip"):
for fi in files:

    contents = ep.get_zipped(fi)

    # for item in contents:
    #     logging.debug("{}: {}: {}".format(item.fn, item.tags.get("Modality"), item.tags.get("SeriesNumber")))

    # contents = list(filter(lambda x: int(x.tags.get("SeriesNumber")) < 9999, contents))
    contents = list(filter(lambda x: x.tags.get("Modality") == "CT", contents))

    # logging.debug(pformat(contents))

    # for item in contents:
    #     logging.debug("{}: {}: {}".format(item.fn, item.tags.get("Modality"), item.tags.get("SeriesNumber")))

    # ep.delete(f)
    fo = "filtered-{}.zip".format('.'.join(os.path.splitext(fi)[:-1]))
    ep.put_zipped(fo, contents)