How to use the pynetdicom.presentation.PresentationContext function in pynetdicom

To help you get started, we’ve selected a few pynetdicom 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 / pynetdicom / pynetdicom / benchmarks / bench_presentation.py View on Github external
def time_create_double_transfer_syntax(self):
        """Time creating context with two transfer syntaxes."""
        for x in range(500):
            cx = PresentationContext()
            cx.context_id = 1
            cx.abstract_syntax = '1.2.840.10008.5.1.4.1.1.2'
            cx.transfer_syntax = ['1.2.840.10008.1.2', '1.2.840.10008.1.2.1']
github pydicom / pynetdicom / pynetdicom / presentation.py View on Github external
=JPEG Baseline (Process 1)

    Returns
    -------
    presentation.PresentationContext
    """
    if transfer_syntax is None:
        transfer_syntax = DEFAULT_TRANSFER_SYNTAXES

    abstract_syntax = UID(abstract_syntax)

    # Allow single transfer syntax values for convenience
    if isinstance(transfer_syntax, str):
        transfer_syntax = [transfer_syntax]

    context = PresentationContext()
    context.abstract_syntax = abstract_syntax
    context.transfer_syntax = transfer_syntax

    return context
github pydicom / pynetdicom / pynetdicom / benchmarks / bench_presentation.py View on Github external
def setup(self):
        # Requestor presentation contexts - max 128
        self.requestor_contexts = []

        for ii, cx in enumerate(StoragePresentationContexts):
            cx.context_id = ii * 2 + 1
            self.requestor_contexts.append(cx)

        # Acceptor presentation contexts - no max
        self.acceptor_contexts = []

        for uid in UID_dictionary:
            cx = PresentationContext()
            cx.abstract_syntax = uid
            cx.transfer_syntax = ['1.2.840.10008.1.2',
                                  '1.2.840.10008.1.2.1',
                                  '1.2.840.10008.1.2.2']
            self.acceptor_contexts.append(cx)
github pydicom / pynetdicom / pynetdicom / ae.py View on Github external
if transfer_syntax is None:
            transfer_syntax = DEFAULT_TRANSFER_SYNTAXES

        if len(self.requested_contexts) >= 128:
            raise ValueError(
                "Failed to add the requested presentation context as there "
                "are already the maximum allowed number of requested contexts"
            )

        abstract_syntax = UID(abstract_syntax)

        # Allow single transfer syntax values for convenience
        if isinstance(transfer_syntax, str):
            transfer_syntax = [transfer_syntax]

        context = PresentationContext()
        context.abstract_syntax = abstract_syntax
        context.transfer_syntax = [UID(syntax) for syntax in transfer_syntax]

        self._requested_contexts.append(context)
github pydicom / pynetdicom / pynetdicom / pdu_primitives.py View on Github external
def presentation_context_definition_results_list(self, value_list):
        """Set the Presentation Context Definition Results List parameter.

        Parameters
        ----------
        value_list : list of utils.PresentationContext
            The results of the Presentation Contexts proposal by the
            Association Requestor
        """
        # pylint: disable=attribute-defined-outside-init
        if isinstance(value_list, list):
            valid_items = []
            for item in value_list:
                if isinstance(item, PresentationContext):
                    valid_items.append(item)
                else:
                    LOGGER.warning("Attempted to set A_ASSOCIATE.presentation"
                                   "_context_definition_results_list to a "
                                   "list which includes one or more invalid "
                                   "items.")

            self._presentation_context_definition_results_list = valid_items

        else:
            LOGGER.error("A_ASSOCIATE.presentation_context_definition_"
                         "results_list must be a list")
            raise TypeError("A_ASSOCIATE.presentation_context_definition_"
                            "results_list must be a list")
github pydicom / pynetdicom / pynetdicom / ae.py View on Github external
# For convenience allow single transfer syntax values
        if isinstance(transfer_syntax, str):
            transfer_syntax = [transfer_syntax]
        transfer_syntax = [UID(syntax) for syntax in transfer_syntax]

        # If the abstract syntax is already supported then update the transfer
        #   syntaxes
        if abstract_syntax in self._supported_contexts:
            context = self._supported_contexts[abstract_syntax]
            for syntax in transfer_syntax:
                context.add_transfer_syntax(syntax)
            context.scu_role = None or scu_role
            context.scp_role = None or scp_role
        else:
            context = PresentationContext()
            context.abstract_syntax = abstract_syntax
            context.transfer_syntax = transfer_syntax
            context.scu_role = None or scu_role
            context.scp_role = None or scp_role

            self._supported_contexts[abstract_syntax] = context
github pydicom / pynetdicom / pynetdicom / benchmarks / bench_presentation.py View on Github external
def time_create_from_sop(self):
        """Test the time taken to create a PresentationContext from every
        available standard DICOM UID.
        """
        for uid in UID_dictionary:
            cx = PresentationContext()
            cx.context_id = 1
            cx.abstract_syntax = uid
            cx.transfer_syntax = ['1.2.840.10008.1.2',
                                  '1.2.840.10008.1.2.1',
                                  '1.2.840.10008.1.2.2']
github pydicom / pynetdicom / pynetdicom / benchmarks / bench_presentation.py View on Github external
def setup(self):
        self.contexts = []
        for x in range(500):
            cx = PresentationContext()
            cx.context_id = 1
            cx.abstract_syntax = '1.2.840.10008.5.1.4.1.1.2'
            cx.transfer_syntax = ['1.2.840.10008.1.2',
                                  '1.2.840.10008.1.2.1',
                                  '1.2.840.10008.1.2.2']
            self.contexts.append(cx)
github pydicom / pynetdicom / pynetdicom / benchmarks / bench_presentation.py View on Github external
def time_create_triple_transfer_syntax(self):
        """Time creating context with three transfer syntaxes."""
        for x in range(500):
            cx = PresentationContext()
            cx.context_id = 1
            cx.abstract_syntax = '1.2.840.10008.5.1.4.1.1.2'
            cx.transfer_syntax = ['1.2.840.10008.1.2',
                                  '1.2.840.10008.1.2.1',
                                  '1.2.840.10008.1.2.2']