`
qimo601
  • 浏览: 3439275 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

DCMTK: Set output directory to DcmSCP

阅读更多

 

Author Message
 Post subject: Set output directory to DcmSCP
PostPosted: Thu, 2011-09-22, 13:26 
Offline

Joined: Thu, 2011-09-22, 12:54
Posts: 4
Location: France
Hello, 

I am a student working on a project (Skuld) which uses dcmtk on Android. 

Dcmtk runs perfectly on Android! I can send echo requests, find requests and initiate move requests. I followed the example of DcmSCU

The problem is, I need a SCP that will allow to store the dicom images. 

I already successfully used movescu as a binary file in Android. The problem is that we cannot ship this binary with our Android application (Actually we can put it in the installation bundle, but 

1) for security reasons it is not possible to execute it in its folder : 
either the user has to manipulate Android tools, not very user friendly, and some devices simply don't allow access to the internal filesystem. 

2) Ship a binary file increase installation bundle size, which is not very good for a mobile application. 

I wish to use DcmSCP for receiving incoming DICOM files, but I am not sure this tool would be able to satisfy what I want to do, so my questions are : 

1) Should I launch DcmSCP as a separate process running indefinitely? 

2) How to set the output folder for DcmSCP? I didn't see any method to handle this, is it taking a default folder? 

Thanks by advance,

_________________
Nicolas Zerr
 

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu, 2011-09-22, 14:17 
Offline
OFFIS DICOM Team
OFFIS DICOM Team

Joined: Fri, 2004-11-05, 14:47
Posts: 1153
Location: Oldenburg, Germany
Hi Nicolas, 

Quote:
Dcmtk runs perfectly on Android!

Great! That's good to know :-) If you have patches that were necessary we are happy to incorporate/offer them to other users. This might also help you to keep your Android DCMTK copy up-to-date with the latest DCMTK since you do not have to patch your changes into the latest version.

Quote:
1) Should I launch DcmSCP as a separate process running indefinitely?


If this is possible for you, you can do it like that. Note that also DcmSCP has a function to stop after the current request. If stopAfterCurrentAssociation() return OFTrue, then DcmSCP returns after the current association is ended by the SCU. Thus, you have to derive your own class from DcmSCP and overwrite this virtual function, making it returning OFTrue when the SCP should stop return the association.

There is no other method to stop listening, by now.

Quote:
2) How to set the output folder for DcmSCP? I didn't see any method to handle this, is it taking a default folder?


Note that there is currently no functionality for any DICOM service besides ECHO. So you have to add Storage Service Class functionality yourself, i.e. overwrite the function handleIncomingCommand() and switch for C-STORE to your own code within. 

Surprisingly (maybe) I implemented that already for DmSCU -- it is needed for C-GET functionality to receive and store DICOM objects. So you might have a look into the current DcmSCU implementation (see DCMTK's public git repository) and implement it similarly. 

Best regards, 
Michael


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu, 2011-09-22, 15:37 
Offline

Joined: Thu, 2011-09-22, 12:54
Posts: 4
Location: France
Hello Michael, 

Thank you for you quick answer. 

The C-GET functionnality in DcmSCU would be very useful and easy to use in my project, however it is said few software support C-GET command and implement rather C-MOVE that fires a C-STORE request, and I wish to be compatible with most of the PACS servers. Since I am not really in a medical environment, could you confirm this fact to me? 

I found maybe another solution, which consists in compiling storescp as a shared library, and pass the arguments from Java through JNI. 

I saw that you can set the output file in the DicomSCU class, however I think for me it would be easier to generate the filenames in the right folders. 

I will post a tutorial to compile and use it for Android (already in French here ). 

I will open a new topic, post the tutorial translated in English in a few days. 

For compiling purposes I only had to edit one line, like this : 

File : dcmdata/libsrc/dcuid.cc 
Line : 1484 

Code:
diff dcmtk-original/dcmdata/libsrc/dcuid.cc  dcmtk/dcmdata/libsrc/dcuid.cc


Code:
1484c1484
< #if defined(_REENTRANT) && !defined(_WIN32) && !defined(__CYGWIN__)
---
> #if defined(_REENTRANT) && !defined(_WIN32) && !defined(__CYGWIN__) && !defined(ANDROID)

_________________
Nicolas Zerr
 

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu, 2011-09-22, 15:43 
Offline
OFFIS DICOM Team
OFFIS DICOM Team

Joined: Fri, 2004-11-05, 14:47
Posts: 1153
Location: Oldenburg, Germany
Hi Nicolas, 

thanks for the tutorial link! If you ever do an English translation we will be happy to host it or at least link to it from our HOWTO page in the wiki

Ah, only one line? When I tried it some time ago, there was more to do. But that is good news! Did you compile the complete public toolkit or "only" ofstd, oflog, dcmdata and dcmnet? [Edit: Ah, just read it in your tutorial] 

I recommend you deriving your own class from DcmSCP and add the storage functionality yourself -- it works very similarly compared to what is already inDcmSCU

Hope to see your DCMTK application on the Android Market soon :-) 

Michael 

[Edit: Linked your tutorial in the wiki]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu, 2011-09-22, 17:07 
Offline

Joined: Thu, 2011-09-22, 12:54
Posts: 4
Location: France
Hello, 

I compiled all the dcmtk toolkit, including apps. I tried movescu, it worked fine, I don't know about the other tools but they should work too. 

I used android-cmake to build the application, and you may tried without this tool, that's why you had much work to do. This script makes the build process very easy (once the script installed, it only requires 4 or 5 steps!) 

I will write a cleaned Android makefile for all DCMTK modules, easy to include in other applications. 

For your information : 

Dicom images libraries are also working, I can display a dicom bitmap I generated with dcmimage. In fact, I first use DicomImage->writeBmp() 
then load the generated file with Android Bitmap API. 

The pictures are a little dark, we should process the bitmap pixels to make them brighter. 

I did not yet succeed in putting the pixels directly from DCMTK, because there's a problem with UInt8 that needs to be converted to java bytes (which are unsigned). However, it should be possible to convert with bits operations. 

I will come back later to ask questions about it, for the moment I just need to retrieve Dicom Images ;) 

Thanks again for your answers speed and clearness.

_________________
Nicolas Zerr
 

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu, 2011-09-22, 17:28 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 15:38
Posts: 706
Quote:
The pictures are a little dark, we should process the bitmap pixels to make them brighter.

Did you specify an appropriate VOI window (for monochrome images)?

Quote:
I did not yet succeed in putting the pixels directly from DCMTK, because there's a problem with UInt8 that needs to be converted to java bytes (which are unsigned). However, it should be possible to convert with bits operations.

This is something we already did for DICOMscope about 13 years ago. Have a look at the JNI code of DICOMscope.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon, 2011-09-26, 15:18 
Offline

Joined: Thu, 2011-09-22, 12:54
Posts: 4
Location: France
Hello, 

I did not yet try to set a VOI window, but i'll try as soon as I finished the Query/Retrieve part. 

I have two questions : 

The first is related to storescp and SCP in general. 

I built storescp as a shared library for Android, and used the dcmscu example to send move requests. It works, but the problem is that I cannot stop the server once I retrieved the study. It results in a background thread that I cannot stop properly. 

I would like to start the server each time I want to retrieve a study, but with different parameters (port, output directory). 

Is it possible to stop the storeSCP after retrieving a study, for instance using option --exec-on-eostudy ? 



I also wanted to implement a c-get request. However it does not work. Here is my code : 

-------------- 
Get.cpp 
-------------- 
Code:
//init scu and JNI stuff...

scu.setACSETimeout(5);
   scu.setPacs(jHost, jPort, jPeerAeTitle, jCallingAeTitle);

   OFList<OFString> ts;
   ts.push_back(UID_LittleEndianExplicitTransferSyntax);
   ts.push_back(UID_BigEndianExplicitTransferSyntax);
   ts.push_back(UID_LittleEndianImplicitTransferSyntax);

scu.addPresentationContext(UID_GETStudyRootQueryRetrieveInformationModel, ts);
   scu.addPresentationContext(UID_VerificationSOPClass, ts);

   OFCondition result = scu.initNetwork();
   if (result.bad())
   {
      scu.setLastError(result.text());
      scu.closeAssociation(DCMSCU_RELEASE_ASSOCIATION);
      return 1;
   }

   result = scu.negotiateAssociation();
   if (result.bad())
   {
      OFString s("Unable to negotiate association: ");
      scu.setLastError(s + result.text());
      scu.closeAssociation(DCMSCU_RELEASE_ASSOCIATION);
      return 2;
   }

   T_ASC_PresentationContextID presID = scu.findUncompressedPC(UID_GETStudyRootQueryRetrieveInformationModel);
   if (presID == 0)
   {
      scu.setLastError("There is no uncompressed presentation context for Study Root FIND");
      return 3;
   }

   OFString storageDir = env->GetStringUTFChars(jStorageDir, NULL);
   scu.setStorageDir(storageDir);

   OFString uid = env->GetStringUTFChars(jUid, NULL);
   DcmDataset *req = new DcmDataset;
   req->putAndInsertOFStringArray(DCM_QueryRetrieveLevel, "SERIES");
   LOGI("%s", uid.c_str());
   req->putAndInsertOFStringArray(DCM_SeriesInstanceUID, uid, true);

   OFList<RetrieveResponse *> responses;
   result = scu.sendCGETRequest(presID, req, &responses);
   if (result.bad())
   {
      scu.setLastError("C-GET request failed");
      return 4;
   }
   scu.closeAssociation(DCMSCU_RELEASE_ASSOCIATION);
   return 0;
}



-------
DicomSCU.cpp
The DicomSCU class inherits DcmSCU
-------

Code:
OFCondition DicomSCU::handleCGETResponse(const T_ASC_PresentationContextID presID,
      RetrieveResponse *response,
      OFBool &continueCGETSession)
{
   
   LOGI("%s", response->m_affectedSOPClassUID.c_str());
   LOGI("Failed : %d", response->m_numberOfFailedSubops);
   LOGI("Completed : %d", response->m_numberOfCompletedSubops);
   LOGI("Remaining : %d", response->m_numberOfRemainingSubops);
   return DcmSCU::handleCGETResponse(presID, response, continueCGETSession);
}


LOGI refers to Android Log. 
The output is : 

Failed : 22 
Completed : 0 
Remaining : 0 

The study I want to retrieve has effectively 22 elements, however the single C-GET response tell me it failed. 

How to solve it ? Is it due to a bad presentation context? 
Could you provide a C-GET example? 

Thanks by Advance

_________________
Nicolas Zerr
 

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon, 2011-09-26, 16:33 
Offline
OFFIS DICOM Team
OFFIS DICOM Team

Joined: Fri, 2004-11-05, 14:47
Posts: 1153
Location: Oldenburg, Germany
Hi, 

no there is no way to stop storescp. You woudl have to program that yourself (i.e. stop after association was received and terminated). Only bad hacks are possible with --exec...options, e.g. let the process exec a kill script to kill itself or the like ;) I would advice adding that in the source code yourself, as you need. 

For your DcmSCU sample application: You also have to add the storage SOP classes to the proposed presentation contexts since the same connection/association will be used for retrieval. Thus, you have to propose each Storage SOP Class from your code with the role "SCP" which is not the default. You can look into getscu.cc how it must be done -- don't worry, it's really easy, I promise 8) 

Best regards, 
Michael


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri, 2011-09-30, 11:14 
Offline
DCMTK Developer

Joined: Thu, 2009-11-26, 09:15
Posts: 88
Hi, 

DCMTK should now correctly detect that gethostbyname_r() is not available on android. Thanks for the hint. 

http://git.dcmtk.org/web?p=dcmtk.git;a= ... e17aa79feb 

Uli


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: Set output directory to DcmSCP
PostPosted: Mon, 2012-03-19, 08:05 
Offline

Joined: Fri, 2012-02-24, 05:13
Posts: 1
Hi Nicolas, 

Can you release the DCMTK on Android tutorial? 

Your reply is really appriciated.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu, 2012-04-12, 12:07 
Offline

Joined: Wed, 2012-04-11, 18:02
Posts: 1
Anyone else can explain how to build DCMTK with Android NDK? 
Thanks in advance.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous: All posts 1 day 7 days 2 weeks 1 month 3 months 6 months 1 year Sort by Author Post time Subject Ascending Descending 

 

分享到:
评论

相关推荐

    dcmtk包中storescu服务移植到wince(OMAP3530)

    DCMTK(Digital Imaging and Communications in Medicine Toolkit)是一个开源软件包,主要用于医学图像通信标准(DICOM)的应用程序开发。在“dcmtk包中storescu服务移植到wince(OMAP3530)”的项目中,我们关注的...

    compile DCMTK for Windows with CMake

    TIFF support: set "DCMTK_WITH_TIFF" to "ON" and "WITH_LIBTIFFINC" to the directory containing TIFF include files, while "WITH_LIBTIFFLIB" should point to the TIFF library location. ICU (International...

    第一个 DCMTK 程序:显示 DICOM 图像(DCMTK 3.6.4 + Qt 5.14.2 + VS2015)源码

    这是博文《第一个 DCMTK 程序:显示 DICOM 图像(DCMTK 3.6.4 + Qt 5.14.2 + VS2015)》的源码,详细内容见博客文章 https://blog.csdn.net/blackwoodcliff/article/details/109481195

    nodejs-dcmtk:基于Nodsjs Alpine和DCMTK的Docker映像

    nodejs-dcmtk 基于Nodsjs Alpine和DCMTK的Docker映像

    dcmtk:“ DICOM”工具包(“ DCMTK”)的包装

    dcmtk dcmtk的目标是包装'DICOM'工具包('DCMTK') 。 移植了医学数字成像和通信('DICOM')工具包的功能集,这是一组处理成像数据的功能。 安装 您可以使用以下方法从安装dcmtk的发行版本: install.packages( ...

    DCMTK-已编译的dcmtk

    名称:DCMTK 评级:★★★★★ 开源许可:BSD 功能: 影像处理,影像归档,影像管理,影像传输 标准:DICOM 语言:英语 客户端: 桌面 平台:跨平台 编程语言:C/C++ 官方网站:http://dicom.offis.de/

    dicom.rar_dcmtk_dcmtk3.6_dcmtk3.6.0_dicom

    3. **命令行工具**:DCMTK提供了一系列的命令行工具,如dcmdump用于查看DICOM文件内容,dcmsend用于发送DICOM数据,dcmscp作为DICOM接收器,以及dcmmkdir用于创建DICOM目录结构等。 4. **API接口**:DCMTK提供了C++...

    dcmtk-install.zip

    接下来,我们看看如何在VS2017和Qt5环境中集成和使用DCMTK: 1. **环境配置**:安装CMake,创建一个新项目,设置VS2017作为生成器,指定Qt5和DCMTK的路径。 2. **添加依赖**:在CMakeLists.txt文件中链接DCMTK库,...

    DCMTK3.6.7-Win11-VS2019-Release/Debug

    在Visual Studio 2019环境下,你可以通过以下步骤集成DCMTK: 1. 解压提供的`Dcmtk-3.6.7`压缩包。 2. 配置项目的属性页,添加DCMTK库的包含目录(头文件)和库目录(链接库)。 3. 链接所需的DCMTK库文件,这些...

    最全DCMTK攻略

    DCMTK攻略 DCMTK(DICOM Toolkit)是德国Offis公司开发的开源项目,旨在提供一个实现DICOM协议的平台,为开发者提供了一个便捷的开发环境。DCMTK提供了所有的源代码、支持库和帮助文档,支持多种操作系统,包括...

    dcmtk-3.6.6.zip

    DCMTK(DICOM ToolKit)是一个开源软件库,专门用于处理医学图像数据,符合DICOM(Digital Imaging and Communications in Medicine)标准。该标准在医疗领域广泛使用,用于存储、传输和打印医学影像数据。DCMTK ...

    自己利用DcmSCP类模拟storescp.exe工具包

    2. **研究DcmSCP类**:通过阅读DCMTK源码,了解`DcmSCP`类的成员函数和工作流程,如`onCStoreRequest()`方法,它是处理C-STORE请求的关键。 3. **创建子类**:根据需求扩展`DcmSCP`类,可能需要覆盖或添加新的功能,...

    Dcm.zip_dcm_dcmtk vs2008_img2dcm.exe DCMTK_site:www.pudn.com_显示D

    首先,"DCMTK"是DICOM(Digital Imaging and Communications in Medicine)工具包的缩写,这是一个开源软件库,主要用于医学图像处理,如读取、写入和转换DICOM格式的数据。"vs2008"指的是Visual Studio 2008,这是...

    dcmtk-3.6.0官方帮助文档

    DCMTK(Digital Imaging and Communications in Medicine Toolkit)是开源软件库,主要用于开发医学影像通信标准(DICOM)的软件。这个3.6.0版本的官方帮助文档是开发者和使用者理解DCMTK的重要资源,提供了详尽的...

    DCMTK入门指南-编译说明

    DCMTK入门指南-编译说明 DCMTK(DICOM_toolkit)是一个开源软件,使得开发者可以轻松地处理DICOM格式的医学图像。以下是 DCMTK 的编译说明: 环境准备 在编译 DCMTK 之前,需要准备以下环境: * 操作系统:WIN7 ...

    DCMTK在VC2005下的编译及使用方法

    - 在"Where to build the binary:"字段填写C:\DCMTK\dcmtk-3.5.4。 - 点击"Configure"按钮,选择"Visual Studio 8 2005",点击OK。 - 根据需要,CMake会自动搜索libxml, libpng等库的路径,你可以根据需求开启要...

    DCMTK 新手使用指南

    DCMTK 新手使用指南 DCMTK 是一个 DICOM 工具包,提供了 DICOM 协议的实现和DICOM 文件处理功能。作为新手,使用 DCMTK 可能会遇到很多疑惑之处。本文总结了 DCMTK 新手使用指南,旨在帮助大家快速上手 PACS 事业。...

    Windows Qt环境下DCMTK库

    **Windows Qt环境下的DCMTK库** DCMTK(DICOM Toolkit)是一个开源软件库,专为处理DICOM(Digital Imaging and Communications in Medicine)标准而设计。DICOM是医学成像领域广泛使用的通信协议和数据格式标准。...

    dcmtk使用手册,dcmtk使用手册,dcmtk使用手册

    dcmtk使用手册,医学领域的东东,有学习的可以下载看看,没学过,不知道好不好学

    dcmtk-3.6.0.zip

    DCMTK(DICOM ToolKit)是一个开源软件库,专门用于开发与DICOM(Digital Imaging and Communications in Medicine)标准相兼容的应用程序和组件。DICOM是医疗领域广泛使用的标准,用于存储、传输和处理医学影像数据...

Global site tag (gtag.js) - Google Analytics