pynetdicom.association.Association

class pynetdicom.association.Association(ae, mode, local_socket=None)[source][source]

Manage an Association with a peer AE.

acceptor

Representation of the association’s acceptor AE.

Type:association.ServiceUser
acse

The Association Control Service Element provider.

Type:acse.ACSE
ae

The local AE.

Type:ae.ApplicationEntity
dimse

The DICOM Message Service Element provider.

Type:dimse.DIMSEServiceProvider
dul

The DICOM Upper Layer service provider.

Type:dul.DULServiceProvider
is_aborted

True if the association has been aborted, False otherwise.

Type:bool
is_established

True if the association has been established, False otherwise.

Type:bool
is_rejected

True if the association was rejected, False otherwise.

Type:bool
is_released

True if the association has been released, False otherwise.

Type:bool
mode

The mode of the local AE, either the association ‘requestor’ or association ‘acceptor’.

Type:str
requestor

Representation of the association’s requestor AE.

Type:association.ServiceUser
__init__(ae, mode, local_socket=None)[source][source]

Create a new Association instance.

Association negotiation won’t begin until Association.start() is called.

Parameters:
  • ae (ae.ApplicationEntity) – The local AE.
  • mode (str) – Must be “requestor” or “acceptor”.
  • local_socket (socket.socket or None) – If mode is ‘acceptor’ then this is the connection to the peer, otherwise will be None.

Methods

__init__(ae, mode[, local_socket]) Create a new Association instance.
abort() Sends an A-ABORT to the remote AE and kills the Association.
debug_association_aborted([primitive]) Debugging information when an A-ABORT request received.
debug_association_accepted(primitive) Debugging information when an A-ASSOCIATE accept is received.
debug_association_rejected(primitive) Debugging information when an A-ASSOCIATE rejection received.
debug_association_released([primitive]) Debugging information when an A-RELEASE request received.
debug_association_requested(primitive) Debugging information when an A-ASSOCIATE request received.
getName()
isAlive() Return whether the thread is alive.
isDaemon()
is_alive() Return whether the thread is alive.
join([timeout]) Wait until the thread terminates.
kill() Kill the main association thread loop.
release() Send an A-RELEASE request to the peer.
run() The main Association control.
send_c_echo([msg_id]) Send a C-ECHO request to the peer AE.
send_c_find(dataset[, msg_id, priority, …]) Send a C-FIND request to the peer AE.
send_c_get(dataset[, msg_id, priority, …]) Send a C-GET request to the peer AE.
send_c_move(dataset, move_aet[, msg_id, …]) Send a C-MOVE request to the peer AE.
send_c_store(dataset[, msg_id, priority, …]) Send a C-STORE request to the peer AE.
send_n_action(dataset, action_type, …[, …]) Send an N-ACTION request message to the peer AE.
send_n_create(dataset, class_uid, instance_uid) Send an N-CREATE request message to the peer AE.
send_n_delete(class_uid, instance_uid[, msg_id]) Send an N-DELETE request message to the peer AE.
send_n_event_report(dataset, event_type, …) Send an N-EVENT-REPORT request message to the peer AE.
send_n_get(identifier_list, class_uid, …) Send an N-GET request message to the peer AE.
send_n_set(dataset, class_uid, instance_uid) Send an N-SET request message to the peer AE.
setDaemon(daemonic)
setName(name)
start() Start the thread’s activity.

Attributes

accepted_contexts Return a list of accepted Presentation Contexts.
ae Return the Association’s parent ApplicationEntity.
daemon A boolean value indicating whether this thread is a daemon thread.
ident Thread identifier of this thread or None if it has not been started.
is_acceptor Return True if the local AE is the association acceptor.
is_requestor Return True if the local AE is the association requestor.
local Return a dict with information about the local AE.
mode Return the Association’s mode as a str.
name A string used for identification purposes only.
rejected_contexts Return a list of rejected Presentation Contexts.
remote Return a dict with information about the peer AE.
abort()[source][source]

Sends an A-ABORT to the remote AE and kills the Association.

accepted_contexts

Return a list of accepted Presentation Contexts.

ae

Return the Association’s parent ApplicationEntity.

daemon

A boolean value indicating whether this thread is a daemon thread.

This must be set before start() is called, otherwise RuntimeError is raised. Its initial value is inherited from the creating thread; the main thread is not a daemon thread and therefore all threads created in the main thread default to daemon = False.

The entire Python program exits when no alive non-daemon threads are left.

static debug_association_aborted(primitive=None)[source][source]

Debugging information when an A-ABORT request received.

Parameters:assoc_primitive (pynetdicom.pdu_primitives.A_ABORT) – The A-ABORT (RQ) primitive received from the DICOM Upper Layer
static debug_association_accepted(primitive)[source][source]

Debugging information when an A-ASSOCIATE accept is received.

Parameters:primitive (pynetdicom.pdu_primitives.A_ASSOCIATE) – The A-ASSOCIATE (AC) PDU received from the DICOM Upper Layer
static debug_association_rejected(primitive)[source][source]

Debugging information when an A-ASSOCIATE rejection received.

Parameters:assoc_primitive (pynetdicom.pdu_primitives.A_ASSOCIATE) – The A-ASSOCIATE (RJ) primitive received from the DICOM Upper Layer
static debug_association_released(primitive=None)[source][source]

Debugging information when an A-RELEASE request received.

Parameters:assoc_primitive (pynetdicom.pdu_primitives.A_RELEASE) – The A-RELEASE (RQ) primitive received from the DICOM Upper Layer
static debug_association_requested(primitive)[source][source]

Debugging information when an A-ASSOCIATE request received.

Parameters:primitive (pynetdicom.pdu_primitives.A_ASSOCIATE) – The A-ASSOCIATE (RQ) PDU received from the DICOM Upper Layer
ident

Thread identifier of this thread or None if it has not been started.

This is a nonzero integer. See the get_ident() function. Thread identifiers may be recycled when a thread exits and another thread is created. The identifier is available even after the thread has exited.

isAlive()[source]

Return whether the thread is alive.

This method returns True just before the run() method starts until just after the run() method terminates. The module function enumerate() returns a list of all alive threads.

is_acceptor

Return True if the local AE is the association acceptor.

is_alive()[source]

Return whether the thread is alive.

This method returns True just before the run() method starts until just after the run() method terminates. The module function enumerate() returns a list of all alive threads.

is_requestor

Return True if the local AE is the association requestor.

join(timeout=None)[source]

Wait until the thread terminates.

This blocks the calling thread until the thread whose join() method is called terminates – either normally or through an unhandled exception or until the optional timeout occurs.

When the timeout argument is present and not None, it should be a floating point number specifying a timeout for the operation in seconds (or fractions thereof). As join() always returns None, you must call isAlive() after join() to decide whether a timeout happened – if the thread is still alive, the join() call timed out.

When the timeout argument is not present or None, the operation will block until the thread terminates.

A thread can be join()ed many times.

join() raises a RuntimeError if an attempt is made to join the current thread as that would cause a deadlock. It is also an error to join() a thread before it has been started and attempts to do so raises the same exception.

kill()[source][source]

Kill the main association thread loop.

local

Return a dict with information about the local AE.

mode

Return the Association’s mode as a str.

name

A string used for identification purposes only.

It has no semantics. Multiple threads may be given the same name. The initial name is set by the constructor.

rejected_contexts

Return a list of rejected Presentation Contexts.

release()[source][source]

Send an A-RELEASE request to the peer.

remote

Return a dict with information about the peer AE.

run()[source][source]

The main Association control.

send_c_echo(msg_id=1)[source][source]

Send a C-ECHO request to the peer AE.

Parameters:

msg_id (int, optional) – The DIMSE Message ID, must be between 0 and 65535, inclusive, (default 1).

Returns:

status – If the peer timed out or sent an invalid response then returns an empty Dataset. If a valid response was received from the peer then returns a Dataset containing at least a (0000,0900) Status element, and, depending on the returned Status value, may optionally contain additional elements (see DICOM Standard Part 7, Annex C).

The DICOM Standard Part 7, Table 9.3-13 indicates that the Status value of a C-ECHO response “shall have a value of Success”. However Section 9.1.5.1.4 indicates it may have any of the following values:

Success
0x0000 Success
Failure
0x0122 SOP class not supported
0x0210 Duplicate invocation
0x0211 Unrecognised operation
0x0212 Mistyped argument

As the actual status depends on the peer SCP, it shouldn’t be assumed that it will be one of these.

Return type:

pydicom.dataset.Dataset

Raises:
  • RuntimeError – If called without an association to a peer SCP.
  • ValueError – If the association has no accepted Presentation Context for ‘Verification SOP Class’.

See also

ae.ApplicationEntity.on_c_echo(), dimse_primitives.C_ECHO(), service_class.VerificationServiceClass()

References

send_c_find(dataset, msg_id=1, priority=2, query_model='P')[source][source]

Send a C-FIND request to the peer AE.

Yields (status, identifier) pairs.

Parameters:
  • dataset (pydicom.dataset.Dataset) – The C-FIND request’s Identifier dataset. The exact requirements for the Identifier dataset are Service Class specific (see the DICOM Standard, Part 4).
  • msg_id (int, optional) – The DIMSE Message ID, must be between 0 and 65535, inclusive, (default 1).
  • priority (int, optional) –

    The C-FIND operation Priority (may not be supported by the peer), one of:

    • 0 - Medium
    • 1 - High
    • 2 - Low (default)
  • query_model (str, optional) –

    The Information Model to use, one of the following:

    • P - Patient Root Information Model - FIND 1.2.840.10008.5.1.4.1.2.1.1 (default)
    • S - Study Root Information Model - FIND 1.2.840.10008.5.1.4.1.2.2.1
    • O - Patient Study Only Information Model - FIND 1.2.840.10008.5.1.4.1.2.3.1
    • W - Modality Worklist Information - FIND 1.2.840.10008.5.1.4.31
    • G - General Relevant Patient Information Query 1.2.840.10008.5.1.4.37.1
    • B - Breast Imaging Relevant Patient Information Query 1.2.840.10008.5.1.4.37.2
    • C - Cardiac Relevant Patient Information Query 1.2.840.10008.5.1.4.37.3
    • PC - Product Characteristics Query Information Model - FIND 1.2.840.10008.5.1.4.41
    • SA - Substance Approval Query Information Model - FIND 1.2.840.10008.5.1.4.42
    • H - Hanging Protocol Information Model - FIND 1.2.840.10008.5.1.4.38.2
    • D - Defined Procedure Protocol Information Model - FIND 1.2.840.10008.5.1.4.20.1
    • CP - Color Palette Information Model - FIND 1.2.840.10008.5.1.4.39.2
    • IG - Generic Implant Template Information Model - FIND 1.2.840.10008.5.1.4.43.2
    • IA - Implant Assembly Template Information Model - FIND 1.2.840.10008.5.1.4.44.2
    • IT - Implant Template Group Information Model - FIND 1.2.840.10008.5.1.4.44.2
Yields:
  • status (pydicom.dataset.Dataset) – If the peer timed out or sent an invalid response then yields an empty Dataset. If a response was received from the peer then yields a Dataset containing at least a (0000,0900) Status element, and depending on the returned value, may optionally contain additional elements (see the DICOM Standard, Part 7, Section 9.1.2.1.5 and Annex C).

    The status for the requested C-FIND operation should be one of the following values, but as the returned value depends on the peer this can’t be assumed:

    General C-FIND (Part 7, Section 9.1.2.1.5 and Annex C)

    Cancel
    0xFE00 Matching terminated due to Cancel request
    Success
    0x0000 Matching is complete: no final Identifier is supplied
    Failure
    0x0122 SOP class not supported

    Query/Retrieve Service, Basic Worklist Management Service, Hanging Protocol Query/Retrieve Service, Defined Procedure Protocol Query/Retrieve Service, Substance Administration Query Service, Color Palette Query/Retrieve Service and Implant Template Query/Retrieve Service specific (DICOM Standard Part 4, Annexes C.4.1, K.4.1.1.4, U.4.1, HH, V.4.1.1.4, X and BB):

    Failure
    0xA700 Out of resources
    0xA900 Identifier does not match SOP Class
    0xC000 to 0xCFFF Unable to process
    Pending
    0xFF00 Matches are continuing: current match is supplied and any Optional Keys were supported in the same manner as Required Keys
    0xFF01 Matches are continuing: warning that one or more Optional Keys were not supported for existence and/or matching for this Identifier)

    Relevant Patient Information Query Service specific (DICOM Standard Part 4, Annex Q.2.1.1.4):

    Failure
    0xA700 Out of resources
    0xA900 Identifier does not match SOP Class
    0xC000 Unable to process
    0xC100 More than one match found
    0xC200 Unable to support requested template
    Pending
    0xFF00 Matches are continuing: current match is supplied and any Optional Keys were supported in the same manner as Required Keys
  • identifier (pydicom.dataset.Dataset or None) – If the status is ‘Pending’ then the C-FIND response’s Identifier Dataset. If the status is not ‘Pending’ this will be None. The exact contents of the response Identifier are Service Class specific (see the DICOM Standard, Part 4).

Raises:
  • RuntimeError – If send_c_find is called with no established association.
  • ValueError – If no accepted Presentation Context for dataset exists or if unable to encode the Identifier dataset.

See also

ae.ApplicationEntity.on_c_find(), dimse_primitives.C_FIND(), service_class.QueryRetrieveFindServiceClass(), service_class.RelevantPatientInformationQueryServiceClass(), service_class.SubstanceAdministrationQueryServiceClass(), service_class.HangingProtocolQueryRetrieveServiceClass(), service_class.DefinedProcedureProtocolQueryRetrieveServiceClass(), service_class.ColorPaletteQueryRetrieveServiceClass(), service_class.ImplantTemplateQueryRetrieveServiceClass()

References

send_c_get(dataset, msg_id=1, priority=2, query_model='P')[source][source]

Send a C-GET request to the peer AE.

Yields (status, identifier) pairs.

The AE.on_c_store callback should be implemented prior to calling send_c_get as the peer will return any matches via a C-STORE sub-operation over the current association. In addition, SCP/SCU Role Selection Negotiation must be supported by the Association.

Parameters:
  • dataset (pydicom.dataset.Dataset) – The C-GET request’s Identifier Dataset. The exact requirements for the Identifier are Service Class specific (see the DICOM Standard, Part 4).
  • msg_id (int, optional) – The DIMSE Message ID, must be between 0 and 65535, inclusive, (default 1).
  • priority (int, optional) –

    The C-GET operation Priority (may not be supported by the peer), one of:

    • 0 - Medium
    • 1 - High
    • 2 - Low (default)
  • query_model (str, optional) –

    The Query/Retrieve Information Model to use, one of the following:

    • P - Patient Root Information Model - GET 1.2.840.10008.5.1.4.1.2.1.3 (default)
    • S - Study Root Information Model - GET 1.2.840.10008.5.1.4.1.2.2.3
    • O - Patient Study Only Information Model - GET 1.2.840.10008.5.1.4.1.2.3.3
    • C - Composite Instance Root Retrieve - GET 1.2.840.10008.5.1.4.1.2.4.3
    • CB - Composite Instance Retrieve Without Bulk Data - GET 1.2.840.10008.5.1.4.1.2.5.3
    • H - Hanging Protocol Information Model - GET 1.2.840.10008.5.1.4.38.4
    • D - Defined Procedure Protocol Information Model - GET 1.2.840.10008.5.1.4.20.3
    • CP - Palette Color Information Model - GET 1.2.840.10008.5.1.4.39.4
    • IG - Generic Implant Template Information Model - GET 1.2.840.10008.5.1.4.43.4
    • IA - Implant Assembly Template Information Model - GET 1.2.840.10008.5.1.4.44.4
    • IT - Implant Template Group Information Model - GET 1.2.840.10008.5.1.4.44.4
Yields:
  • status (pydicom.dataset.Dataset) – If the peer timed out or sent an invalid response then yields an empty Dataset. If a response was received from the peer then yields a Dataset containing at least a (0000,0900) Status element, and depending on the returned value may optionally contain additional elements (see DICOM Standard Part 7, Section 9.1.2.1.5 and Annex C).

    The status for the requested C-GET operation should be one of the following values, but as the returned value depends on the peer this can’t be assumed:

    General C-GET (DICOM Standard Part 7, Section 9.1.3 and Annex C)

    Success
    0x0000 Sub-operations complete: no failures or warnings
    Failure
    0x0122 SOP class not supported
    0x0124 Not authorised
    0x0210 Duplicate invocation
    0x0211 Unrecognised operation
    0x0212 Mistyped argument

    Query/Retrieve Service, Hanging Protocol Query/Retrieve Service, Defined Procedure Protocol Query/Retrieve Service, Color Palette Query/Retrieve Service and Implant Template Query/Retrieve Service specific (DICOM Standard Part 4, Annexes C.4.3, Y.C.4.2.1.4, Z.4.2.1.4, U.4.3, X, BB and HH):

    Pending
    0xFF00 Sub-operations are continuing
    Cancel
    0xFE00 Sub-operations terminated due to Cancel indication
    Failure
    0xA701 Out of resources: unable to calculate number of matches
    0xA702 Out of resources: unable to perform sub-operations
    0xA900 Identifier does not match SOP class
    0xAA00 None of the frames requested were found in the SOP instance
    0xAA01 Unable to create new object for this SOP class
    0xAA02 Unable to extract frames
    0xAA03 Time-based request received for a non-time-based original SOP Instance
    0xAA04 Invalid request
    0xC000 to 0xCFFF Unable to process
    Warning
    0xB000 Sub-operations completed: one or more failures or warnings
  • identifier (pydicom.dataset.Dataset or None) – If the status is ‘Pending’ or ‘Success’ then yields None. If the status is ‘Warning’, ‘Failure’ or ‘Cancel’ then yields a Dataset which should contain an (0008,0058) Failed SOP Instance UID List element, however this is not guaranteed and may instead return an empty Dataset.

Raises:
  • RuntimeError – If send_c_get is called with no established association.
  • ValueError – If no accepted Presentation Context for dataset exists or if unable to encode the Identifier dataset.

See also

ae.ApplicationEntity.on_c_get(), ae.ApplicationEntity.on_c_store(), service_class.QueryRetrieveGetServiceClass(), service_class.HangingProtocolQueryRetrieveServiceClass(), service_class.DefinedProcedureProtocolQueryRetrieveServiceClass(), service_class.ColorPaletteQueryRetrieveServiceClass(), service_class.ImplantTemplateQueryRetrieveServiceClass(), dimse_primitives.C_GET()

References

send_c_move(dataset, move_aet, msg_id=1, priority=2, query_model='P')[source][source]

Send a C-MOVE request to the peer AE.

Yields (status, identifier) pairs.

The peer will attempt to start a new association with the AE with AE Title move_aet and hence must be known to the SCP. Once the association has been established it will use the C-STORE service to send any matching datasets.

Parameters:
  • dataset (pydicom.dataset.Dataset) – The C-MOVE request’s Identifier Dataset. The exact requirements for the Identifier are Service Class specific (see the DICOM Standard, Part 4).
  • move_aet (bytes) – The AE title of the destination for the C-STORE sub-operations performed by the peer.
  • msg_id (int, optional) – The DIMSE Message ID, must be between 0 and 65535, inclusive, (default 1).
  • priority (int, optional) –

    The C-MOVE operation Priority (if supported by the peer), one of:

    • 0 - Medium
    • 1 - High
    • 2 - Low (default)
  • query_model (str, optional) –

    The Query/Retrieve Information Model to use, one of the following:

    • P - Patient Root Information Model - MOVE 1.2.840.10008.5.1.4.1.2.1.2 (default)
    • S - Study Root Information Model - MOVE 1.2.840.10008.5.1.4.1.2.2.2
    • O - Patient Study Only Information Model - MOVE 1.2.840.10008.5.1.4.1.2.3.2
    • C - Composite Instance Root Retrieve - MOVE 1.2.840.10008.5.1.4.1.2.4.2
    • H - Hanging Protocol Information Model - MOVE 1.2.840.10008.5.1.4.38.3
    • D - Defined Procedure Protocol Information Model - MOVE 1.2.840.10008.5.1.4.20.2
    • CP - Color Palette Information Model - MOVE 1.2.840.10008.5.1.4.39.3
    • IG - Generic Implant Template Information Model - MOVE 1.2.840.10008.5.1.4.43.3
    • IA - Implant Assembly Template Information Model - MOVE 1.2.840.10008.5.1.4.44.3
    • IT - Implant Template Group Information Model - MOVE 1.2.840.10008.5.1.4.44.3
Yields:
  • status (pydicom.dataset.Dataset) – If the peer timed out or sent an invalid response then yields an empty Dataset. If a response was received from the peer then yields a Dataset containing at least a (0000,0900) Status element, and depending on the returned value, may optionally contain additional elements (see DICOM Standard Part 7, Section 9.1.4 and Annex C).

    The status for the requested C-MOVE operation should be one of the following values, but as the returned value depends on the peer this can’t be assumed:

    General C-MOVE (DICOM Standard Part 7, 9.1.4.1.7 and Annex C)

    Cancel
    0xFE00 Sub-operations terminated due to Cancel indication
    Success
    0x0000 Sub-operations complete: no failures
    Failure
    0x0122 SOP class not supported

    Query/Retrieve Service, Hanging Protocol Query/Retrieve Service, Defined Procedure Protocol Query/Retrieve Service, Color Palette Query/Retrieve Service and Implant Template Query/Retreive Service specific (DICOM Standard Part 4, Annexes C, U, Y, X, BB and HH):

    Failure
    0xA701 Out of resources: unable to calculate number of matches
    0xA702 Out of resources: unable to perform sub-operations
    0xA801 Move destination unknown
    0xA900 Identifier does not match SOP Class
    0xAA00 None of the frames requested were found in the SOP instance
    0xAA01 Unable to create new object for this SOP class
    0xAA02 Unable to extract frames
    0xAA03 Time-based request received for a non-time-based original SOP Instance
    0xAA04 Invalid request
    0xC000 to 0xCFFF Unable to process
    Pending
    0xFF00 Sub-operations are continuing
    Warning
    0xB000 Sub-operations complete: one or more failures
  • identifier (pydicom.dataset.Dataset or None) – If the status is ‘Pending’ or ‘Success’ then yields None. If the status is ‘Warning’, ‘Failure’ or ‘Cancel’ then yields a Dataset which should contain an (0008,0058) Failed SOP Instance UID List element, however this is not guaranteed and may instead return an empty Dataset.

See also

ae.ApplicationEntity.on_c_move(), ae.ApplicationEntity.on_c_store(), dimse_primitives.C_MOVE(), service_class.QueryRetrieveMoveServiceClass(), service_class.HangingProtocolQueryRetrieveServiceClass(), service_class.ColorPaletteQueryRetrieveServiceClass(), service_class.ImplantTemplateQueryRetrieveServiceClass()

References

send_c_store(dataset, msg_id=1, priority=2, originator_aet=None, originator_id=None)[source][source]

Send a C-STORE request to the peer AE.

Parameters:
  • dataset (pydicom.dataset.Dataset) – The DICOM dataset to send to the peer.
  • msg_id (int, optional) – The DIMSE Message ID, must be between 0 and 65535, inclusive, (default 1).
  • priority (int, optional) –

    The C-STORE operation Priority (may not be supported by the peer), one of:

    • 0 - Medium
    • 1 - High
    • 2 - Low (default)
  • originator_aet (bytes, optional) – The AE title of the peer that invoked the C-MOVE operation for which this C-STORE sub-operation is being performed (default None).
  • originator_id (int, optional) – The Message ID of the C-MOVE request primitive from which this C-STORE sub-operation is being performed (default None).
Returns:

status – If the peer timed out or sent an invalid response then returns an empty Dataset. If a valid response was received from the peer then returns a Dataset containing at least a (0000,0900) Status element, and, depending on the returned value, may optionally contain additional elements (see DICOM Standard Part 7, Annex C).

The status for the requested C-STORE operation should be one of the following, but as the value depends on the peer SCP this can’t be assumed:

General C-STORE (DICOM Standard Part 7, 9.1.1.1.9 and Annex C):

Success
0x0000 Success
Failure
0x0117 Invalid SOP instance
0x0122 SOP class not supported
0x0124 Not authorised
0x0210 Duplicate invocation
0x0211 Unrecognised operation
0x0212 Mistyped argument

Storage Service and Non-Patient Object Storage Service specific (DICOM Standard Part 4, Annexes B.2.3 and GG):

Failure
0xA700 to 0xA7FF Out of resources
0xA900 to 0xA9FF Data set does not match SOP class
0xC000 to 0xCFFF Cannot understand
Warning
0xB000 Coercion of data elements
0xB006 Element discarded
0xB007 Data set does not match SOP class

Non-Patient Object Service Class specific (DICOM Standard Part 4, Annex GG.4.2)

Failure
0xA700 Out of resources
0xA900 Data set does not match SOP class
0xC000 Cannot understand

Return type:

pydicom.dataset.Dataset

Raises:
  • RuntimeError – If send_c_store is called with no established association.
  • AttributeError – If dataset is missing (0008,0016) SOP Class UID, (0008,0018) SOP Instance UID elements or the (0002,0010) Transfer Syntax UID file meta information element.
  • ValueError – If no accepted Presentation Context for dataset exists or if unable to encode the dataset.

See also

ae.ApplicationEntity.on_c_store(), dimse_primitives.C_STORE(), service_class.StorageServiceClass(), service_class.NonPatientObjectStorageServiceClass()

References

  • DICOM Standard Part 4, Annex B
  • DICOM Standard Part 4, Annex GG
  • DICOM Standard Part 7, Sections 9.1.1, 9.3.1 and Annex C
send_n_action(dataset, action_type, class_uid, instance_uid, msg_id=1)[source][source]

Send an N-ACTION request message to the peer AE.

Parameters:
  • dataset (pydicom.dataset.Dataset or None) – The dataset that will be sent as the Action Information parameter in the N-ACTION request, or None if not required.
  • action_type (int) – The value of the request’s (0000,1008) Action Type ID element.
  • class_uid (pydicom.uid.UID) – The UID to be sent in the request’s (0000,0003) Requested SOP Class UID element.
  • instance_uid (pydicom.uid.UID) – The UID to be sent in the request’s (0000,1001) Requested SOP Instance UID element.
  • msg_id (int, optional) – The DIMSE Message ID, must be between 0 and 65535, inclusive, (default 1).
Returns:

  • status (pydicom.dataset.Dataset) – If the peer timed out or sent an invalid response then yields an empty Dataset. If a response was received from the peer then yields a Dataset containing at least a (0000,0900) Status element, and depending on the returned value, may optionally contain additional elements (see the DICOM Standard, Part 7, Section 9.1.2.1.5 and Annex C).

    General N-ACTION (DICOM Standard Part 7, Section 10.1.4 and Annex C)

    Success
    0x0000 Successful operation
    Failure
    0x0110 Processing failure
    0x0112 No such SOP Instance
    0x0114 No such argument
    0x0115 Invalid argument value
    0x0117 Invalid object instance
    0x0118 No such SOP Class
    0x0119 Class-Instance conflict
    0x0123 No such action
    0x0124 Not authorised
    0x0210 Duplicate invocation
    0x0211 Unrecognised operation
    0x0212 Mistyped argument
    0x0213 Resource limitation
  • action_reply (pydicom.dataset.Dataset or None) – If the status is ‘Success’ then a Dataset containing attributes corresponding to those supplied in the Action Reply, otherwise returns None.

See also

ae.ApplicationEntity.on_n_action(), dimse_primitives.N_ACTION()

References

send_n_create(dataset, class_uid, instance_uid, msg_id=1)[source][source]

Send an N-CREATE request message to the peer AE.

Parameters:
  • dataset (pydicom.dataset.Dataset or None) – The dataset that will be sent as the Attribute List parameter in the N-CREATE request, or None if not required.
  • class_uid (pydicom.uid.UID) – The UID to be sent in the request’s (0000,0002) Affected SOP Class UID element.
  • instance_uid (pydicom.uid.UID or None) – The UID to be sent in the request’s (0000,1000) Affected SOP Instance UID element or None if not required.
  • msg_id (int, optional) – The DIMSE Message ID, must be between 0 and 65535, inclusive, (default 1).
Returns:

  • status (pydicom.dataset.Dataset) – If the peer timed out or sent an invalid response then yields an empty Dataset. If a response was received from the peer then yields a Dataset containing at least a (0000,0900) Status element, and depending on the returned value, may optionally contain additional elements (see the DICOM Standard, Part 7, Section 9.1.2.1.5 and Annex C).

    General N-CREATE (DICOM Standard Part 7, Section 10.1.5 and Annex C)

    Success
    0x0000 Successful operation
    Failure
    0x0110 Processing failure
    0x0112 No such SOP Instance
    0x0114 No such argument
    0x0115 Invalid argument value
    0x0117 Invalid object instance
    0x0118 No such SOP Class
    0x0119 Class-Instance conflict
    0x0123 No such action
    0x0124 Not authorised
    0x0210 Duplicate invocation
    0x0211 Unrecognised operation
    0x0212 Mistyped argument
    0x0213 Resource limitation
  • attribute_list (pydicom.dataset.Dataset or None) – If the status is ‘Success’ then a Dataset containing attributes corresponding to those supplied in the Attribute List, otherwise returns None.

See also

ae.ApplicationEntity.on_n_create(), dimse_primitives.N_CREATE()

References

send_n_delete(class_uid, instance_uid, msg_id=1)[source][source]

Send an N-DELETE request message to the peer AE.

Parameters:
  • class_uid (pydicom.uid.UID) – The UID to be sent in the request’s (0000,0003) Requested SOP Class UID element.
  • instance_uid (pydicom.uid.UID) – The UID to be sent in the request’s (0000,1001) Requested SOP Instance UID element.
  • msg_id (int, optional) – The DIMSE Message ID, must be between 0 and 65535, inclusive, (default 1).
Returns:

status – If the peer timed out or sent an invalid response then yields an empty Dataset. If a response was received from the peer then yields a Dataset containing at least a (0000,0900) Status element, and depending on the returned value, may optionally contain additional elements (see the DICOM Standard, Part 7, Section 9.1.2.1.5 and Annex C).

General N-DELETE (DICOM Standard Part 7, Section 10.1.6 and Annex C)

Success
0x0000 Successful operation
Failure
0x0110 Processing failure
0x0112 No such SOP Instance
0x0117 Invalid object instance
0x0118 No such SOP Class
0x0119 Class-Instance conflict
0x0124 Not authorised
0x0210 Duplicate invocation
0x0211 Unrecognised operation
0x0212 Mistyped argument
0x0213 Resource limitation

Return type:

pydicom.dataset.Dataset

See also

ae.ApplicationEntity.on_n_delete(), dimse_primitives.N_DELETE()

References

send_n_event_report(dataset, event_type, class_uid, instance_uid, msg_id=1)[source][source]

Send an N-EVENT-REPORT request message to the peer AE.

Parameters:
  • dataset (pydicom.dataset.Dataset) – The dataset that will be sent as the Event Information parameter in the N-EVENT-REPORT request.
  • event_type (int) – The value to be sent in the request’s (0000,10002) Event Type ID element.
  • class_uid (pydicom.uid.UID) – The UID to be sent in the request’s (0000,0003) Affected SOP Class UID element.
  • instance_uid (pydicom.uid.UID) – The UID to be sent in the request’s (0000,1001) Affected SOP Instance UID element.
  • msg_id (int, optional) – The DIMSE Message ID, must be between 0 and 65535, inclusive, (default 1).
Returns:

  • status (pydicom.dataset.Dataset) – If the peer timed out or sent an invalid response then yields an empty Dataset. If a response was received from the peer then yields a Dataset containing at least a (0000,0900) Status element, and depending on the returned value, may optionally contain additional elements (see the DICOM Standard, Part 7, Section 9.1.2.1.5 and Annex C).

    General N-EVENT-REPORT (DICOM Standard Part 7, Section 10.1.1 and Annex C)

    Success
    0x0000 Successful operation
    Failure
    0x0110 Processing failure
    0x0112 No such SOP Instance
    0x0113 No such event type
    0x0114 No such argument
    0x0115 Invalid argument value
    0x0117 Invalid object instance
    0x0118 No such SOP Class
    0x0119 Class-Instance conflict
    0x0210 Duplicate invocation
    0x0211 Unrecognised operation
    0x0212 Mistyped argument
    0x0213 Resource limitation
  • event_reply (pydicom.dataset.Dataset or None) – If the status is ‘Success’ then a Dataset containing the optional reply to the event report.

See also

ae.ApplicationEntity.on_n_event_report(), dimse_primitives.N_EVENT_REPORT()

References

send_n_get(identifier_list, class_uid, instance_uid, msg_id=1)[source][source]

Send an N-GET request message to the peer AE.

Parameters:
  • identifier_list (list of pydicom.tag.Tag) – A list of DICOM Data Element tags to be sent in the request’s (0000,1005) Attribute Identifier List element. Should either be a list of pydicom Tag objects or a list of values that is acceptable for creating pydicom Tag objects.
  • class_uid (pydicom.uid.UID) – The UID to be sent in the request’s (0000,0003) Requested SOP Class UID element.
  • instance_uid (pydicom.uid.UID) – The UID to be sent in the request’s (0000,1001) Requested SOP Instance UID element.
  • msg_id (int, optional) – The DIMSE Message ID, must be between 0 and 65535, inclusive, (default 1).
Returns:

  • status (pydicom.dataset.Dataset) – If the peer timed out or sent an invalid response then yields an empty Dataset. If a response was received from the peer then yields a Dataset containing at least a (0000,0900) Status element, and depending on the returned value, may optionally contain additional elements (see the DICOM Standard, Part 7, Section 9.1.2.1.5 and Annex C).

    General N-GET (DICOM Standard Part 7, Section 10.1.2 and Annex C)

    Success
    0x0000 Successful operation
    Warning
    0x0107 Attribute list error
    Failure
    0x0110 Processing failure
    0x0112 No such SOP Instance
    0x0117 Invalid object instance
    0x0118 No such SOP Class
    0x0119 Class-Instance conflict
    0x0122 SOP class not supported
    0x0124 Not authorised
    0x0210 Duplicate invocation
    0x0211 Unrecognised operation
    0x0212 Mistyped argument
    0x0213 Resource limitation
  • attribute_list (pydicom.dataset.Dataset or None) – If the status is ‘Success’ then a Dataset containing attributes corresponding to those supplied in the Attribute Identifier List, otherwise returns None.

See also

ae.ApplicationEntity.on_n_get(), dimse_primitives.N_GET(), service_class.DisplaySystemManagementServiceClass()

References

send_n_set(dataset, class_uid, instance_uid, msg_id=1)[source][source]

Send an N-SET request message to the peer AE.

Parameters:
  • dataset (pydicom.dataset.Dataset) – The dataset that will be sent as the Modification List parameter in the N-SET request.
  • class_uid (pydicom.uid.UID) – The UID to be sent in the request’s (0000,0003) Requested SOP Class UID element.
  • instance_uid (pydicom.uid.UID) – The UID to be sent in the request’s (0000,1001) Requested SOP Instance UID element.
  • msg_id (int, optional) – The DIMSE Message ID, must be between 0 and 65535, inclusive, (default 1).
Returns:

  • status (pydicom.dataset.Dataset) – If the peer timed out or sent an invalid response then yields an empty Dataset. If a response was received from the peer then yields a Dataset containing at least a (0000,0900) Status element, and depending on the returned value, may optionally contain additional elements (see the DICOM Standard, Part 7, Section 9.1.2.1.5 and Annex C).

    General N-SET (DICOM Standard Part 7, Section 10.1.3 and Annex C)

    Success
    0x0000 Successful operation
    Warning
    0x0107 Attribute list error
    0x0116 Attribute value out of range
    Failure
    0x0105 No such attribute
    0x0106 Invalid attribute value
    0x0110 Processing failure
    0x0112 No such SOP Instance
    0x0117 Invalid object instance
    0x0118 No such SOP Class
    0x0119 Class-Instance conflict
    0x0121 Missing attribute value
    0x0122 SOP class not supported
    0x0124 Not authorised
    0x0210 Duplicate invocation
    0x0211 Unrecognised operation
    0x0212 Mistyped argument
    0x0213 Resource limitation
  • attribute_list (pydicom.dataset.Dataset or None) – If the status is ‘Success’ then a Dataset containing attributes corresponding to those supplied in the Attribute List, otherwise returns None.

See also

ae.ApplicationEntity.on_n_set(), dimse_primitives.N_SET()

References

start()[source]

Start the thread’s activity.

It must be called at most once per thread object. It arranges for the object’s run() method to be invoked in a separate thread of control.

This method will raise a RuntimeError if called more than once on the same thread object.