How to use the deid.dicom.get_files function in deid

To help you get started, we’ve selected a few deid examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pydicom / deid / deid / main.py View on Github external
# If a deid is given, check against format
    if args.deid is not None:
        from deid.config import load_deid
        params = load_deid(args.deid)
        if params['format'] != args.format:
            bot.error("Format in deid (%s) doesn't match choice here (%s) exiting." %(params['format'],
                                                                                      args.format))

    # Get list of dicom files
    base = args.folder
    if base is None:
        bot.info("No input folder specified, will use demo dicom-cookies.")
        base = get_dataset('dicom-cookies')
    basename = os.path.basename(base)
    dicom_files = get_files(base)

    # Does the user want to inspect files?
    if args.action == "inspect":
        from deid.dicom import has_burned_pixels
        has_burned_pixels(dicom_files)
        sys.exit(0) 


    do_get = False
    do_put = False
    ids = None
    if args.action == "all":
        bot.info("GET and PUT identifiers from %s" %(basename))
        do_get = True
        do_put = True
github pydicom / deid / examples / dicom / pixels / run-inspect-pixels.py View on Github external
# This is a complete example of inspecting pixels for PHI
# based on a deid.dicom specification
# https://pydicom.github.io/deid


# This will get a set of example cookie dicoms
from deid.dicom import get_files, has_burned_pixels
from pydicom import read_file
from deid.data import get_dataset
from deid.logger import bot
import os

bot.level = 3

base = get_dataset("dicom-cookies")
dicom_files = list(get_files(base))  # todo : consider using generator functionality

results = has_burned_pixels(dicom_files=dicom_files, deid="examples/deid")
github pydicom / deid / examples / dicom / header-manipulation / func-replacement.py View on Github external
#!/usr/bin/env python3

from deid.dicom import get_files, replace_identifiers
from deid.utils import get_installdir
from deid.data import get_dataset
import os

# This is an example of replacing fields in dicom headers,
# but via a function instead of a preset identifier.

# This will get a set of example cookie dicoms
base = get_dataset("dicom-cookies")
dicom_files = list(get_files(base))  # todo : consider using generator functionality


# This is the function to get identifiers
from deid.dicom import get_identifiers

items = get_identifiers(dicom_files)

# **
# The function performs an action to generate a uid, but you can also use
# it to communicate with databases, APIs, or do something like
# save the original (and newly generated one) in some (IRB approvied) place
# **

################################################################################
# The Deid Recipe
#
github pydicom / deid / deid / main / identifiers.py View on Github external
# If a deid is given, check against format
    if args.deid is not None:
        params = load_deid(args.deid)
        if params["format"] != args.format:
            bot.error(
                "Format in deid (%s) doesn't match choice here (%s) exiting."
                % (params["format"], args.format)
            )
    # Get list of dicom files
    base = args.input
    if base is None:
        bot.info("No input folder specified, will use demo dicom-cookies.")
        base = get_dataset("dicom-cookies")
    basename = os.path.basename(base)
    dicom_files = list(get_files(base))  # todo : consider using generator functionality

    do_get = False
    do_put = False
    ids = None
    if args.action == "all":
        bot.info("GET and PUT identifiers from %s" % (basename))
        do_get = True
        do_put = True

    elif args.action == "get":
        do_get = True
        bot.info("GET and PUT identifiers from %s" % (basename))

    elif args.action == "put":
        bot.info("PUT identifiers from %s" % (basename))
        do_put = True
github pydicom / deid / deid / main / inspect.py View on Github external
deid = args.deid
    if deid is not None:
        params = load_deid(deid)
        if params["format"] != args.format:
            bot.error(
                "Format in deid (%s) doesn't match choice here (%s) exiting."
                % (params["format"], args.format)
            )
    # Get list of dicom files
    base = args.folder
    if base is None:
        bot.info("No input folder specified, will use demo dicom-cookies.")
        base = get_dataset("dicom-cookies")

    dicom_files = list(
        get_files(base, pattern=args.pattern)
    )  # todo : consider using generator functionality
    result = has_burned_pixels(dicom_files, deid=deid)

    print("\nSUMMARY ================================\n")
    if result["clean"]:
        bot.custom(
            prefix="CLEAN", message="%s files" % len(result["clean"]), color="CYAN"
        )

    if result["flagged"]:
        for group, files in result["flagged"].items():
            bot.flag("%s %s files" % (group, len(files)))

    if args.save:
        folders = "-".join([os.path.basename(folder) for folder in base])
        outfile = "pixel-flag-results-%s-%s.tsv" % (
github pydicom / deid / examples / dicom / pixels / run-cleaner-client.py View on Github external
# This is a complete example of using the cleaning client to inspect
# and clean pixels
# based on a deid.dicom specification
# https://pydicom.github.io/deid

#########################################
# 1. Get List of Files
#########################################

# This will get a set of example cookie dicoms
from deid.dicom import get_files
from deid.data import get_dataset

base = get_dataset("dicom-cookies")
dicom_files = list(get_files(base))  # todo : consider using generator functionality
dicom_file = dicom_files[3]


#########################################
# 2. Create Client
#########################################

client = DicomCleaner()

# You can set the output folder if you want, otherwis tmpdir is used
client = DicomCleaner(output_folder="/home/vanessa/Desktop")

# Steps are to detect, clean, and save in desired format, one image
# at a time.
# client.detect(dicom_file)
# client.clean()
github pydicom / deid / examples / dicom / recipe / deid-dicom-example.py View on Github external
#!/usr/bin/env python3

from deid.dicom import get_files, replace_identifiers
from deid.utils import get_installdir
from deid.data import get_dataset
import os

# This is a complete example of doing de-identifiction. For details, see our docs
# https://pydicom.github.io/deid


# This will get a set of example cookie dicoms
base = get_dataset("dicom-cookies")
dicom_files = list(get_files(base))  # todo : consider using generator functionality


# This is the function to get identifiers
from deid.dicom import get_identifiers

ids = get_identifiers(dicom_files)

# **
# Here you might save them in your special (IRB approvied) places
# And then provide replacement anonymous ids to put back in the data
# A cookie tumor example is below
# **

################################################################################
# The Deid Recipe
#