使用JAVA程序中的dcm4che连接到dcm4chee [英] Connecting to dcm4chee using dcm4che from a JAVA program

查看:97
本文介绍了使用JAVA程序中的dcm4che连接到dcm4chee的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新



我在dcm4che的源代码中进行了更深的挖掘,发现如果出现 IncompatibleConnectionException ,则 p>


  • 未安装连接

  • 或未设置协议类型或未设置协议类型



我不知道连接已安装是什么意思,但是可以手动设置该标志,所以我将本地和远程连接都设置为 true (甚至使用 getInstalled()检查它们是否已安装-是的,现在是-以前此属性为 null )。



关于协议,他们没有指定,因此对于两个连接,我都将它们设置为 DICOM



结果:我仍然得到相同的结果






我想在 dcm4chee (2.18.3)和我的JAVA ap使用 dcm4che (5.12.0)工具包进行复制。



问题在于,似乎没有任何有关如何在JAVA应用程序中使用dcm4che的文档,因此,我所能做的就是阅读dcm4che的源代码,并尝试弄清其类和方法的用途。 ,但我被卡住了。如果有人已经有了一个可行的示例,那将非常有帮助。



到目前为止,我有:

 导入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 =新的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.addConnection(localConn);
device.addApplicationEntity(locAE);

关联assoc = locAE.connect(remAE,assocReq);

但我不知道自己是否在正确的道路上。



我得到的错误:

  org.dcm4che3.net.IncompatibleConnectionException:不兼容可以在org.dcm4che3.net.ApplicationEntity.findCompatibelConnection(ApplicationEntity.java:646)
的THIS_JAVA_APP
上获得DCM4CHEE的连接,在org.dcm4che3.net.ApplicationEntity.connect(ApplicationEntity.java:651)


解决方案

工作代码如下:(我不知道是否这是最小的解决方案,请随时尝试...)

  ApplicationEntity locAE = new ApplicationEntity(); 
locAE.setAETitle( THIS_JAVA_APP);
locAE.setInstalled(true);

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);
remAE.setInstalled(true);

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 =新的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.addConnection(localConn);
device.addApplicationEntity(locAE);

执行器exec =(Runnable命令)-> {};
device.setExecutor(exec);

关联assoc = locAE.connect(localConn,remoteConn,assocReq);

和相关的dcm4chee日志:

  2018-03-02 23:21:42,832信息THIS_JAVA_APP-> DCM4CHEE(TCPServer-1)[org.dcm4cheri.net.FsmImpl]收到了AAssociateRQ 
appCtxName:1.2.840.10008 .3.1.1.1 / DICOM应用程序上下文名称
impl类:1.2.40.0.13.1.3
impl版本:dcm4che-5.12.0
被称为AET:DCM4CHEE
被调用AET:THIS_JAVA_APP
maxPDULen:16378
asyncOpsWindow:
pc-1:as = 1.2.840.10008.1.1 / Verification SOP Class
ts = 1.2.840.10008.1.2 / Implicit VR Little Endian
2018 -03-02 23:21:42,843信息THIS_JAVA_APP-> DCM4CHEE(TCPServer-1)[org.dcm4cheri.net.FsmImpl]发送AAssociateAC
appCtxName:1.2.840.10008.3.1.1.1 / DICOM应用上下文名称
impl类:1.2.40.0.13.1.1.1
impl版本:dcm4che-1.4.34
被称为AET:DCM4CHEE
被调用的AET:THIS_JAVA_APP
maxPDULen:16352
asyncOpsWindow:
pc-1:0-接受
ts = 1.2.840.10008.1.2 /隐式VR Little Endian

建立关联后,请参阅此其他帖子以了解如何执行C-FIND。 p>

Update

I dug deeper in dcm4che's source code and found that an IncompatibleConnectionException is thrown if either

  • a connection is "not installed"
  • or the types of protocols are not set or don't match.

I don't know what it means that a connection is "installed" but this flag can be set manually, so I set it for both the local and remote connections to true (even checked them with getInstalled() whether they are "installed" - and yes they are now - previously this property was null).

And as to the protocols, they weren't specified, so for both connections I set them to DICOM.

Results: I still get the same Exception.


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)

解决方案

Here is the working code: (I don't know if it's the minimal solution, feel free to experiment with it...)

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

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");
remAE.setInstalled(true);

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);

Executor exec = (Runnable command) -> {};
device.setExecutor(exec);

Association assoc = locAE.connect(localConn, remoteConn, assocReq);

And the relevant dcm4chee log:

2018-03-02 23:21:42,832 INFO  THIS_JAVA_APP->DCM4CHEE (TCPServer-1) [org.dcm4cheri.net.FsmImpl] received AAssociateRQ
    appCtxName: 1.2.840.10008.3.1.1.1/DICOM Application Context Name
    implClass:  1.2.40.0.13.1.3
    implVersion:    dcm4che-5.12.0
    calledAET:  DCM4CHEE
    callingAET: THIS_JAVA_APP
    maxPDULen:  16378
    asyncOpsWindow: 
    pc-1:   as=1.2.840.10008.1.1/Verification SOP Class
        ts=1.2.840.10008.1.2/Implicit VR Little Endian
2018-03-02 23:21:42,843 INFO  THIS_JAVA_APP->DCM4CHEE (TCPServer-1) [org.dcm4cheri.net.FsmImpl] sending AAssociateAC
    appCtxName: 1.2.840.10008.3.1.1.1/DICOM Application Context Name
    implClass:  1.2.40.0.13.1.1.1
    implVersion:    dcm4che-1.4.34
    calledAET:  DCM4CHEE
    callingAET: THIS_JAVA_APP
    maxPDULen:  16352
    asyncOpsWindow: 
    pc-1:   0 - acceptance
        ts=1.2.840.10008.1.2/Implicit VR Little Endian

After you have the association, see this other post for how to perform a C-FIND.

这篇关于使用JAVA程序中的dcm4che连接到dcm4chee的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆