How to use the deid.utils.get_installdir 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 / config / utils.py View on Github external
def find_deid(path=None):
    """find_deid is a helper function to load_deid to find a deid file in
       a folder, or return the path provided if it is the file.

       Parameters
       ==========
       path: a path on the filesystem. If not provided, will assume PWD.

    """
    # A default deid will be loaded if all else fails
    default_deid = os.path.join(get_installdir(), "data", "deid.dicom")

    if path is None:
        path = os.getcwd()

    # The user has provided a directory
    if os.path.isdir(path):
        contenders = [
            "%s/%s" % (path, x) for x in os.listdir(path) if x.startswith("deid")
        ]

        if len(contenders) == 0:
            bot.warning(
                "No deid settings files found in %s, will use default dicom.deid."
                % path
            )
            contenders.append(default_deid)
github pydicom / deid / deid / data / __init__.py View on Github external
def get_dataset(dataset=None):
    """get_dataset will return some data provided by the application,
    based on a user-provided label. In the future, we can add https endpoints
    to retrieve online datasets.
    """
    data_base = get_installdir()
    valid_datasets = {
        "dicom-cookies": os.path.join(data_base, "data", "dicom-cookies"),
        "animals": os.path.join(data_base, "data", "animals"),
        "humans": os.path.join(data_base, "data", "humans"),
    }

    if dataset is not None:
        # In case the user gave an extension
        dataset = os.path.splitext(dataset)[0].lower()
        if dataset in valid_datasets:
            return valid_datasets[dataset]

    bot.info("Valid datasets include: %s" % (",".join(list(valid_datasets.keys()))))