Transfer Syntax Control on the Network

How can I control the Transfer Syntax (compression) used when I send images over the network?

It is important first to understand how DICOM negotiation occurs in general.

The transfer syntaxes available for network transmission depend on what is agreed between the applications, During initial negotiation (only), the SCU sends the SCP a list of "presentation contexts", each of which has a SOP class and one or more transfer syntaxes. Normally each SOP class is offered only once, with a list of transfer syntaxes, though it is allowable to offer a SOP class more than once with a different list of offered transfer syntaxes. For each presentation context, the SCP chooses just one of the transfer syntaxes from each of those offered, or it may reject a presentation context entirely if it doesn't accept either the SOP class or any of the offered transfer syntaxes (Only support for default Implicit VR Little Endian is mandatory in DICOM SCPs) When the SCU sends an image it must use one of the negotiated presentation contexts. So, in the "normal" situation where an SCU offers each SOP class once, with a list of all the transfer syntaxes it supports, the choice of transfer syntax is effectively made by the SCP, not the SCU (though as described below, if lossy, only the SCU controls quality). So, how does this work in DicomObjects?

For DicomImage.Send, the list of offered transfer syntaxes comes from the registry, from the default value of the following key

HKEY_LOCAL_MACHINE/Software/Medical Connections/DicomObjects/TransferSyntax

NOTE: The above is a Key not a value. You need to edit the list of transfer syntaxes into the default value of that key.

or to change dynamically, it can be controlled by

DicomGlobal.RegString("TransferSyntax/") - note the trailing "/"

If you wish to make this change only for a single SOP class (a.k.a. Abstract Syntax), then you can use that as the value name (real registry) or following the "/" in the programmatic version - e.g.

HKEY_LOCAL_MACHINE/Software/Medical Connections/DicomObjects/TransferSyntax/1.2.840.10008.5.1.4.1.1.3.1

NOTE: The above is a value not a key.

or

DicomGlobal.RegString("TransferSyntax/1.2.840.10008.5.1.4.1.1.3.1") 

Whichever method is used, the string value is a space separated list of transfer syntax UIDs

Therefore, for DicomImage.Send, you can control the transfer syntaxes offered, using this mechanism, and if necessary, you can reduce it to a single transfer syntax to "force" this to be used, but if so, then you must be prepared to accept a failure and retry if the SCP rejects your chosen transfer syntax.

For DicomConnection.SendImages, the default is the same as above, but you can override this by making your own contexts explicitly.

e.g. in VB:

set cn = new DicomConnection
dim cxt as DicomContext 
set cxt = cn.Contexts.Add("1.2.840.10008.5.1.2.1.1.2") ' CT
cxt.OfferedTS = array("1.2.840.10008.1.2", "1.2.840.10008.1.2.4.51")
[COM  Version] cn.SetDestination.......
[.NET Version] cn.Open.......

This will offer CT (only - default values are not used once any override is made), with just default Implicit VR Little Endian and Lossy JPEG 12 bit.

You can if you wish use this mechanism to add the same SOP class more than once e.g.

set cn = new DicomConnection
dim cxt as DicomContext 
cxt = cn.Contexts.Add("1.2.840.10008.5.1.2.1.1.2") ' CT
cxt.OfferedTS = "1.2.840.10008.1.2"
set cxt = cn.Contexts.Add("1.2.840.10008.5.1.2.1.1.2") ' CT again
cxt.OfferedTS = "1.2.840.10008.1.2.4.51"
[COM  Version] cn.SetDestination.......
[.NET Version] cn.Open.......

This also avoids having to use arrays!

PreferredTS and PreferredPCID

Here, if the SCP accepts both contexts, then you have the choice which to use - see the PreferedTS and PreferedPCID help file entries to guide you further....just note that PCID numbers go 1,3,5 etc., not 1,2,3.......you may find looking at a log useful to see what is happening!

When DicomObjects is the SCP, the choice of transfer syntaxes accepted can be accomplished either internally, or through programmatic control.

For full control, you must put code in the AssociationRequest/AssociationRequest2 events to iterate through the contexts, and for each one choose which of the transfer syntaxes in the OfferedTS list you wish to accept, and put this into the AcceptedTS property. For any contexts where an explicit choice ha not been made, DicomObjects makes an internal choice, using the default list from the TransferSyntax registry key or global.RegString value as defined above. In this case, the transfer syntax accepted is the first in the default list which is also present in the list offered. Note that the order in which the transfer syntaxes are offered is therefore irrelevant.