0

尝试使用 dcm4che (v.2) 工具包实现 DICOM 路由器桌面 (Java) 应用程序。

DICOM 路由器应该接受任何传入的 DICOM 发送请求,将文件存储在本地(在某个文件夹结构中),并且在每个 DICOM 研究发送请求完成后,它应该以某种方式处理文件(内部操作)。

我正在使用 dcmrcv util/tool 通过以下方式实现 DICOM 接收器(getDcmRcv() 实际上是一个 dmcRcv 对象):

...
private final CustomStorageService storageSCP = new CustomStorageService(CUIDS);
...
public DcmRcv(String name) {
    device = new Device(name);
    executor = new NewThreadExecutor(name);

    device.setNetworkApplicationEntity(ae);
    device.setNetworkConnection(nc);
    ae.setNetworkConnection(nc);
    ae.setAssociationAcceptor(true);
    ae.register(new VerificationService());
    ae.register(storageSCP);
    ae.register(stgcmtSCP);        
    ae.addAssociationListener(storageSCP);
}

我以某种方式修改了 StorageService 以通过以下方式管理 AssociationListener:

private final class CustomStorageService extends StorageService implements AssociationListener {
    public CustomStorageService(final String[] sopClasses) {
        super(sopClasses);
    }

    @Override
    protected void onCStoreRQ(final Association association, final int pcid, final DicomObject dcmReqObj,
                               final PDVInputStream dataStream, final String transferSyntaxUID,
                               final DicomObject dcmRspObj)
            throws DicomServiceException, IOException {

        final String classUID = dcmReqObj.getString(Tag.AffectedSOPClassUID);
        final String instanceUID = dcmReqObj.getString(Tag.AffectedSOPInstanceUID);

        GlobalConfig config = new GlobalConfig();
        final File associationDir = config.getAssocDirFile();

        final String prefixedFileName = instanceUID;
    final String dicomFileBaseName = prefixedFileName + DICOM_FILE_EXTENSION;

    File dicomFile = new File(associationDir, dicomFileBaseName + PARTIAL_FILE_EXTENSION);
    assert !dicomFile.exists();

    final BasicDicomObject fileMetaDcmObj = new BasicDicomObject();
    fileMetaDcmObj.initFileMetaInformation(classUID, instanceUID, transferSyntaxUID);

    final DicomOutputStream outStream = new DicomOutputStream(
        new BufferedOutputStream(new FileOutputStream(dicomFile), 600000));
    try {
        outStream.writeFileMetaInformation(fileMetaDcmObj);
        dataStream.copyTo(outStream);

    } finally {
        outStream.close();
    }
        dicomFile.renameTo(new File(associationDir, dicomFileBaseName));
        System.out.println("DICOM file name: " + dicomFile.getName());
    }
}

这样,我可以接受来自客户端(例如 Mayam)的 DICOM 发送请求,但文件存储在目录“rootDirectory”(C:\XXXXXX\YYYY\Development\AssocDir)中的平面结构中。

我正在尝试从关联对象中获取诸如 StudyID 和 SeriedID 之类的信息,以创建一个文件夹结构,例如:来自 dcmReqObj 或 dicomFile 的 root/StudyID/SeriesID/DicmFile ... 但是:

dcmReqObj 实际上是空的(仅填充了 AffectedSOPClassUID 和 AffectedSOPInstanceUID 标签)

即使我尝试在之后获取它: outStream.writeFileMetaInformation(fileMetaDcmObj) 尚未填充 StudyID 标记(在此方法内)...

同样在此方法中,如果我尝试在 onCStoreRQ 中获取“dicomFile”,我只能将其置于尚未填充的 DICOM 对象的过渡阶段...

我在这里错过了什么?

4

2 回答 2

1

在您的场景中,如果 Java/Dcm4Che 的使用不是强制性的,您可以将Orthanc作为 Dcm4che 的补充来实现 DICOM 自动路由。Orthanc 是一个提供脚本功能的轻量级开源 DICOM 服务器:提供了通过Lua 脚本或通过REST 调用进行 DICOM 自动路由的示例。

于 2014-10-28T11:13:25.283 回答
1

您需要做的不仅仅是按原样使用 DcmRcv 类。

以它为起点,但您还需要实现

org.dcm4che2.net.AssociationListener

拦截关联请求的接口,以及

org.dcm4che2.net.service.StorageService

用于实际数据传输的类。

于 2014-10-27T18:25:47.640 回答