How to use the deid.dicom.filter.apply_filter 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 / dicom / pixels.py View on Github external
config = read_json(config)

    # Load criteria (actions) for flagging
    for criteria in config:

        flagged = False
        filters = criteria["filters"]
        label = [x for x in [criteria['modality'],
                             criteria['manufacturer'],
                             criteria['label']]
                 if x is not None]

        for func,actions in filters.items():
            for action in actions:
                flagged = apply_filter(dicom=dicom,
                                       field=action['field'],
                                       filter_name=func,
                                       value=action["value"])
                                     
                if flagged:
                    label = " ".join(label)
                    bot.warning("FLAG for %s: %s" %(dicom_name,label))
                    return flagged


    bot.debug("%s header filter indicates pixels are clean." %dicom_name)
    return flagged
github pydicom / deid / deid / dicom / pixels / detect.py View on Github external
for group in item["filters"]:
                group_flags = []  # evaluation for a single line
                group_descriptions = []

                # You cannot pop from the list
                for a in range(len(group["action"])):

                    action = group["action"][a]
                    field = group["field"][a]
                    value = ""

                    if len(group["value"]) > a:
                        value = group["value"][a]

                    flag = apply_filter(
                        dicom=dicom,
                        field=field,
                        filter_name=action,
                        value=value or None,
                    )
                    group_flags.append(flag)
                    description = "%s %s %s" % (field, action, value)

                    if len(group["InnerOperators"]) > a:
                        inner_operator = group["InnerOperators"][a]
                        group_flags.append(inner_operator)
                        description = "%s %s" % (description, inner_operator)

                    group_descriptions.append(description)

            # At the end of a group, evaluate the inner group