Connecting to dcm4chee using dcm4che from a JAVA program

611 views
Skip to first unread message

Tamás Sipos

unread,
Mar 1, 2018, 9:53:14 AM3/1/18
to dcm...@googlegroups.com

I'd like to establish a DICOM association between dcm4chee (2.18.3) and my JAVA application using the dcm4che (5.12.0) toolkit.

The problem is that it doesn't seem to be any documentation available on how to use dcm4che in a JAVA application, so all I can do is read dcm4che's source code and try to figure out what its classes and methods are for, but I'm stuck. If someone already has a working example it would be very helpful.

So far I have:

import org.dcm4che3.net.ApplicationEntity;
import org.dcm4che3.net.Association;
import org.dcm4che3.net.Connection;
import org.dcm4che3.net.Device;
import org.dcm4che3.net.pdu.AAssociateRQ;
import org.dcm4che3.net.pdu.PresentationContext;

...

ApplicationEntity locAE = new ApplicationEntity();
locAE.setAETitle("THIS_JAVA_APP");

Connection localConn = new Connection();
localConn.setCommonName("loc_conn");
localConn.setHostname("localhost");
localConn.setPort(11112);
localConn.setProtocol(Connection.Protocol.DICOM);
localConn.setInstalled(true);
locAE.addConnection(localConn);

ApplicationEntity remAE = new ApplicationEntity();
remAE.setAETitle("DCM4CHEE");

Connection remoteConn = new Connection();
remoteConn.setCommonName("rem_conn");
remoteConn.setHostname("localhost");
remoteConn.setPort(11112);
remoteConn.setProtocol(Connection.Protocol.DICOM);
remoteConn.setInstalled(true);
remAE.addConnection(remoteConn);

AAssociateRQ assocReq = new AAssociateRQ();
assocReq.setCalledAET(remAE.getAETitle());
assocReq.setCallingAET(locAE.getAETitle());
assocReq.setApplicationContext("1.2.840.10008.3.1.1.1");
assocReq.setImplClassUID("1.2.40.0.13.1.3");
assocReq.setImplVersionName("dcm4che-5.12.0");
assocReq.setMaxPDULength(16384);
assocReq.setMaxOpsInvoked(0);
assocReq.setMaxOpsPerformed(0);
assocReq.addPresentationContext(new PresentationContext(
    1, "1.2.840.10008.1.1", "1.2.840.10008.1.2"));

Device device = new Device("device");
device.addConnection(localConn);
device.addApplicationEntity(locAE);

Association assoc = locAE.connect(remAE, assocReq);

but I don't know whether I'm on the right path doing it.

The error I get:

org.dcm4che3.net.IncompatibleConnectionException: No compatible connection to DCM4CHEE available on THIS_JAVA_APP
at org.dcm4che3.net.ApplicationEntity.findCompatibelConnection(ApplicationEntity.java:646)
at org.dcm4che3.net.ApplicationEntity.connect(ApplicationEntity.java:651)

(To be honest, I have no idea what a Device is and why it is necessary, and what I should do with it, but I found an older implementation for an association in which a Device is used.)

And the parameters that I added to the request are from other forum topics I found (this and this).

Jon Ander Zuccaro

unread,
Mar 1, 2018, 8:08:42 PM3/1/18
to dcm4che
You have some working examples already, take a look at the "tools" folder:

https://github.com/dcm4che/dcm4che/tree/master/dcm4che-tool





On Thursday, March 1, 2018 at 10:53:14 AM UTC-4, Tamás Sipos wrote:

I'd like to establish a DICOM association between dcm4chee (2.18.3) and my JAVA application using the dcm4che (5.12.0) toolkit.

The problem is that it doesn't seem to be any documentation available on how to use dcm4che in a JAVA application, so all I can do is read dcm4che's source code and try to figure out what its classes and methods are for, but I'm stuck. If someone already has a working example it would be very helpful.

So far I have:

import org.dcm4che3.net.ApplicationEntity;
import org.dcm4che3.net.Connection;

import org.dcm4che3.net.pdu.AAssociateRQ;
import org.dcm4che3.net.pdu.PresentationContext;

...

ApplicationEntity locAE = new ApplicationEntity("THIS_JAVA_APP");
Connection localConn = new Connection("loc_conn", "localhost", 11112);
locAE.addConnection(localConn);

ApplicationEntity remAE = new ApplicationEntity("DCM4CHEE");
Connection remoteConn = new Connection("rem_conn", "localhost", 11112);

remAE.addConnection(remoteConn);

AAssociateRQ assocReq = new AAssociateRQ();
PresentationContext pc = new PresentationContext(1, 0, "1.2.840.10008.1.1");
assocReq.addPresentationContext(pc);

locAE.connect(remAE, assocReq);

Dr Suresh Viswanathan

unread,
Mar 2, 2018, 12:41:15 AM3/2/18
to dcm...@googlegroups.com
Mayam is an open source DICOM Workstation written in Java. You can go through the source code and see how DICOM associations take place. 

Suresh. 

On 01-Mar-2018, at 21:53, Tamás Sipos <swir...@gmail.com> wrote:

I'd like to establish a DICOM association between dcm4chee (2.18.3) and my JAVA application using the dcm4che (5.12.0) toolkit.


The problem is that it doesn't seem to be any documentation available on how to use dcm4che in a JAVA application, so all I can do is read dcm4che's source code and try to figure out what its classes and methods are for, but I'm stuck. If someone already has a working example it would be very helpful.


So far I have:


import org.dcm4che3.net.ApplicationEntity;
import org.dcm4che3.net.Connection;

import org.dcm4che3.net.pdu.AAssociateRQ;
import org.dcm4che3.net.pdu.PresentationContext;

...

ApplicationEntity locAE = new ApplicationEntity("THIS_JAVA_APP");
Connection localConn = new Connection("loc_conn", "localhost", 11112);

locAE.addConnection(localConn);

ApplicationEntity remAE = new ApplicationEntity("DCM4CHEE");
Connection remoteConn = new Connection("rem_conn", "localhost", 11112);

remAE.addConnection(remoteConn);


AAssociateRQ assocReq = new AAssociateRQ();
PresentationContext pc = new PresentationContext(1, 0, "1.2.840.10008.1.1");
assocReq.addPresentationContext(pc);


locAE.connect(remAE, assocReq);


but I don't know whether I'm on the right path doing it.


The error I get:


org.dcm4che3.net.IncompatibleConnectionException: No compatible connection to DCM4CHEE available on THIS_JAVA_APP
at org.dcm4che3.net.ApplicationEntity.findCompatibelConnection(ApplicationEntity.java:646)
at org.dcm4che3.net.ApplicationEntity.connect(ApplicationEntity.java:651)


--
You received this message because you are subscribed to the Google Groups "dcm4che" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dcm4che+u...@googlegroups.com.
To post to this group, send email to dcm...@googlegroups.com.
Visit this group at https://groups.google.com/group/dcm4che.
For more options, visit https://groups.google.com/d/optout.

Tamás Sipos

unread,
Mar 2, 2018, 3:59:19 AM3/2/18
to dcm4che
Thanks Jon for the suggestion, but those files I've already browsed over, looking for information which parameters and how should be defined for the association request (I mean things like Implementation Class UID, Implementation Version Name, Application Context Name, Application Name, etc) but I didn't find anything like that. I don't know how and where to specify the Presentation Context either.

I'm just guessing that all these things are necessary, maybe they're not, I don't know. Is it really inside the dcm4che-tool folder? I don't see any line for example in which things like Abstract Syntax or Transfer Syntax would be defined..

Tamás Sipos

unread,
Mar 2, 2018, 10:21:15 AM3/2/18
to dcm...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages