本帖最后由 medimage 于 2015-12-4 21:29 编辑
十、dcmsr程序库
dcmsr是一个结构化报表库和可用工具。这个模块包括一些类来读、写、创建、修改、访问、打印和显示DICOM结构化报表文档。所支持的SOP类列表由DSRTypes::E_DocumentType提供。 主要接口:
--DSRDocument: Interface class for 'dcmsr' (DICOM Structured Reporting Documents). This class supports reading, writing, creation, printing and rendering of DICOM SR documents (according to DICOM PS 3.x-2004, formerly known as Supplement 23). The list of supported SOP classes is available in file "dsrtypes.h". 在dsrdoc.h中定义。
--DSRDocumentTree: 管理SR文档树的类。在dsrdoctr.h中定义。
--DSRContentItem: Interface class for content items. This class allows to access the document tree nodes without using any pointers. 在dsrcitem.h中定义。
--DSRCodedEntryValue: Class for coded entry values. 在dsrcodvl.h中定义。 工具:
dsr2html: Render DICOM SR file and data set to HTML
dsr2xml: Convert DICOM SR file and data set to XML
dsrdump: Dump DICOM SR file and data set
xml2dsr: Convert DICOM SR file and data set to XML 举例:
--载入一个DICOM结构化报表,并以HTML格式显示其内容。
DcmFileFormat fileformat;
OFCondition status = fileformat.loadFile("test.dcm");
if (status.good())
{
DSRDocument document;
status = document.read(*fileformat.getDataset());
if (status.good())
{
status = document.renderHTML(cout);
if (status.bad())
cerr << "Error: cannot render SR document (" << status.text() << ")" << endl;
} else
cerr << "Error: cannot parse SR document (" << status.text() << ")" << endl;
} else
cerr << "Error: cannot read DICOM file (" << status.text() << ")" << endl;
--创建一个DICOM结构化报告,并将其存为文件。
DSRDocument document;
document.setPatientsName("Doe^John");
/* ... */
document.getTree().addContentItem(DSRTypes::RT_isRoot, DSRTypes::VT_Container);
document.getTree().getCurrentContentItem().setConceptName(DSRCodedEntryValue(/* some code */));
document.getTree().addContentItem(DSRTypes::RT_hasObsContext, DSRTypes::VT_Code, DSRTypes::AM_belowCurrent);
/* ... */
DcmFileFormat fileformat;
OFCondition status = document.write(*fileformat.getDataset())
if (status.good())
{
status = fileformat.saveFile("test.dcm", EXS_LittleEndianExplicit);
if (status.bad())
cerr << "Error: cannot write DICOM file (" << status.text() << ")" << endl;
} else
cerr << "Error: cannot write SR document (" << status.text() << ")" << endl;
--读取文档树的属性,并直接修改。
DSRDocument document(DSRTypes: T_KeyObjectDoc);
/* ... */
document.getTree().addContentItem(DSRTypes::RT_isRoot, DSRTypes::VT_Container);
DSRCodedEntryValue *codePtr = document.getTree().getCurrentContentItem().getConceptNamePtr();
if (codePtr != NULL)
codePtr->setCode("113000", "DCM", "Of Interest");
/* ... */
document.getTree().addContentItem(DSRTypes::RT_contains, DSRTypes::VT_Image);
DSRImageReferenceValue *imagePtr = document.getTree().getCurrentContentItem().getImageReferencePtr();
if (imagePtr != NULL)
{
imagePtr->setValue(DSRImageReferenceValue(UID_UltrasoundMultiframeImageStorage, /* image UID */));
imagePtr->setPresentationState(DSRCompositeReferenceValue(UID_GrayscaleSoftcopyPresentationStateStorage, /* GSPS UID */));
imagePtr->getFrameList().addItem(2);
imagePtr->getFrameList().addItem(5);
}
|