How to use the deid.utils.parse_value 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 / parser.py View on Github external
def add_field(self, field, value):
        """add a field to the dicom. If it's already present, update the value.
        """
        value = parse_value(
            item=self.lookup, value=value, field=field, dicom=self.dicom
        )

        # Assume we don't want to add an empty value
        if value is not None:

            # If provided a field object, create based on keyword or tag identifer
            name = field
            if isinstance(field, DicomField):
                name = field.element.keyword or field.stripped_tag

            # Generate a tag item, add if it's a name found in the dicom dictionary
            tag = get_tag(name)

            # Second try, it might be a private (or other numerical) string identifier
            if not tag:
github pydicom / deid / deid / dicom / parser.py View on Github external
# Jitter the field by the supplied value
                jitter_timestamp(
                    dicom=self.dicom, field=field.element.keyword, value=value
                )
            else:
                bot.warning("JITTER %s unsuccessful" % field)

        # elif "KEEP" --> Do nothing. Keep the original

        # Remove the field entirely
        elif action == "REMOVE":

            # If a value is defined, parse it (could be filter)
            do_removal = True
            if value != None:
                do_removal = parse_value(
                    item=self.lookup, dicom=self.dicom, value=value, field=field
                )

            if do_removal == True:
                self.delete_field(field)
github pydicom / deid / deid / dicom / parser.py View on Github external
"""
        # Blank the value
        if action == "BLANK":
            self.blank_field(field)

        # Unlikely to be called from perform_action
        elif action == "ADD":
            self.add_field(field, value)

        # Code the value with something in the response
        elif action == "REPLACE":
            self.replace_field(field, value)

        # Code the value with something in the response
        elif action == "JITTER":
            value = parse_value(
                item=self.lookup, dicom=self.dicom, value=value, field=field
            )
            if value is not None:

                # Jitter the field by the supplied value
                jitter_timestamp(
                    dicom=self.dicom, field=field.element.keyword, value=value
                )
            else:
                bot.warning("JITTER %s unsuccessful" % field)

        # elif "KEEP" --> Do nothing. Keep the original

        # Remove the field entirely
        elif action == "REMOVE":