java dcm4che3,从dcm4che2迁移到dcm4che3

博主在Java项目中使用dcm4che2的API,现想迁移到dcm4che3,但原API在dcm4che3中未找到。文中给出解决方案,指出新的“Dicom对象”是Attributes,迁移需重写查询和处理标签的代码,还给出从PACS检索研究的完整示例。

I have used below mentioned API of dcm4che2 from this repository http://www.dcm4che.org/maven2/dcm4che/ in my java project.

dcm4che-core-2.0.29.jar

org.dcm4che2.data.DicomObject

org.dcm4che2.io.StopTagInputHandler

org.dcm4che2.data.BasicDicomObject

org.dcm4che2.data.UIDDictionary

org.dcm4che2.data.DicomElement

org.dcm4che2.data.SimpleDcmElement

org.dcm4che2.net.service.StorageCommitmentService

org.dcm4che2.util.CloseUtils

dcm4che-net-2.0.29.jar

org.dcm4che2.net.CommandUtils

org.dcm4che2.net.ConfigurationException

org.dcm4che2.net.NetworkApplicationEntity

org.dcm4che2.net.NetworkConnection

org.dcm4che2.net.NewThreadExecutor

org.dcm4che3.net.service.StorageService

org.dcm4che3.net.service.VerificationService

Currently i want to migrate to dcm4che3 but, above listed API is not found in dcm4che3 which i have downloaded from this repository http://sourceforge.net/projects/dcm4che/files/dcm4che3/

Could you please guide me for alternate approach?

解决方案

As you have already observed, the BasicDicomObject is history -- alongside quite a few others.

The new "Dicom object" is Attributes -- an object is a collection of attributes.

Therefore, you create Attributes, populate them with the tags you need for RQ-behaviour (C-FIND, etc) and what you get in return is another Attributes object from which you pull the tags you want.

In my opinion, dcm4che 2.x was vague on the subject of dealing with individual value representations. dcm4che 3.x is quite a bit clearer.

The migration demands a rewrite of your code regarding how you query and how you treat individual tags. On the other hand, dcm4che 3.x makes the new code less convoluted.

A fairly complete example, retrieving studies from a PACS given accession numbers; setting up the query and handling the result:

String modality = null;

String accessionNumber = "1234567890";

//--------------------------------------------------------

// HERE follows setup of a query, using an Attributes object

//--------------------------------------------------------

Attributes query = new Attributes();

// Indicate character set

{

int tag = Tag.SpecificCharacterSet;

VR vr = ElementDictionary.vrOf(tag, query.getPrivateCreator(tag));

query.setString(tag, vr, "ISO_IR 100");

}

// Study level query

{

int tag = Tag.QueryRetrieveLevel;

VR vr = ElementDictionary.vrOf(tag, query.getPrivateCreator(tag));

query.setString(tag, vr, "STUDY");

}

// Accession number

{

int tag = Tag.AccessionNumber;

VR vr = ElementDictionary.vrOf(tag, query.getPrivateCreator(tag));

query.setString(tag, vr, accessionNumber);

}

// Optionally filter on modality in study if 'modality' is provided,

// otherwise retrieve modality

{

int tag = Tag.ModalitiesInStudy;

VR vr = ElementDictionary.vrOf(tag, query.getPrivateCreator(tag));

if (null != modality && modality.length() > 0) {

query.setString(tag, vr, modality);

} else {

query.setNull(tag, vr);

}

}

// We are interested in study instance UID

{

int tag = Tag.StudyInstanceUID;

VR vr = ElementDictionary.vrOf(tag, query.getPrivateCreator(tag));

query.setNull(tag, vr);

}

// Do the actual query, needing an AppliationEntity (ae),

// a local (local) and remote (remote) Connection, and

// an AAssociateRQ (rq) set up earlier.

// 1) Open a connection to the SCP

Association as = ae.connect(local, remote, rq);

// 2) Query

int priority = 0x0002; // low for the sake of demo :)

as.cfind(UID.StudyRootQueryRetrieveInformationModelFIND, query, null,

new DimseRSPHandler(as.nextMessageID()) {

@Override

public void onDimseRSP(Association assoc, Attributes cmd,

Attributes response) {

super.onDimseRSP(assoc, cmd, response);

int status = cmd.getInt(Tag.Status, -1);

if (Status.isPending(status)) {

//--------------------------------------------------------

// HERE follows handling of the response, which

// is just another Attributes object

//--------------------------------------------------------

String studyInstanceUID = response.getString(Tag.StudyInstanceUID);

// etc...

}

}

});

// 3) Close the connection to the SCP

if (as != null && as.isReadyForDataTransfer()) {

as.waitForOutstandingRSP();

as.release();

as = null;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值