DICOM medical image processing: Learning and analyzing worklist Based on DCMTK Toolkit

Source: Internet
Author: User
Background:

The dicom3.0 Protocol describes the worklist section. In short, worklist can be seen as a "Communication Protocol" for radiology devices to automatically read patient information from the hospital RIS system. It can refer to the patient database stored in the RIS system, it mainly includes the basic information of the patient (such as age, gender, height, weight, birth date, and so on), which is consistent with most fields in metainfo in the information header of the DCM file. Therefore, automatic worklist acquisition from the RIS system is a necessary part of hospital informatization. The following is a brief description of several images, which describe the role of worklist.

Worklist instance learning:

After simply understanding the worklist的, we use the tool package of dcmtk.pdf (wlmscpfs.exeand findscu.exe) to simulate this scenario, so as to learn more deeply about the worklist function.

Worklist is simply regarded as a kind of "communication", so there are naturally two ends of communication, temporarily called "server" and "client ". In this case, we use wlmscpfs.exeto serve the worklistcommunication service, that is, wait for external users to use findscu.exe as the server to initiate worklist access.

First, we will briefly introduce the instructions and usage of the toolkit. Wlmscpfs.exe is similar to a command in the DOS era. You can set parameters for different purposes. Use the win + r key to open the operating system running window. Enter cmd and enter the command prompt line window. Then go to the bin folder compiled by DCMTK (my local address is c: \ Program Files (x86) \ DCMTK \ bin1_directory, and enter wlmscpfs.exe directly to view the instructions on the command tool.

> Cd c: \ Program Files (x86) \ DCMTK \ bin

> Wlmscpfs.exe

(Note: To save trouble, you can add the bin folder path to the Windows environment variable. If so, you can use the tools in bin in any directory)

The wlmscpfs.exe tool must provide at least one port parameter, that is, the local port number for enabling the worklist service. You also need to enter the address of the worklist database file for the client to query and access. Below we officially open the worklist server program, as to open the whole process, you can recommend csdn a blogger boutique article (http://blog.csdn.net/pachleng/article/details/5800513), blog gives the specific operation steps, this instance is used to supplement and update the DCMTK forum. You can give it a try.

Step 1: create directories at all levels

Taking my computer as an example, I created a dcmworklist folder on drive D, and created two subfolders wlistdb and wlistqry.

Step 2: Prepare the worklist database file and enable the worklist Server service.

Copy the database file of worklist to the wlistdb directory. For more information, see cold brother's blog. Remember to create the offis subdirectory. As for the worklist database files are usually given in the source code of the DCMTK library, the default directory is dcmtk-3.6.0 \ dcmtk-3.6.0 \ dcmwlm \ datawlistdb (I am using version 3.6.0 ). However, files in the source code are usually. Dump files with the extension, which is a common text file. You can double-click notepad or notepad ++ to open the file ). By using dump2dcm.exe in the dcmtktool package, you can convert the. dump file to the. WL file. The converted. WL file is the worklist database file.

> Dcmp2dcm.exe. \ dcmtk-3.6.0 \ dcmtk-3.6.0 \ dcmwlm \ data \ wklistdb \ wlist1.dump D: \ dcmworklist \ wlistdb \ offis \ wlist. WL

> ......

With the worklistdata warehouse file, we can open the worklistservice, and use the tool wlmscpfs.exe mentioned in the previous article (SCP in the tool name can be seen that this should be enabled by the server ).

> Wlmscpfs.exe-D-DFR-dfp d: \ dcmworklist \ wlistdb 104 (Note:-D is the debugging switch enabled to help us observe the running process of the tool)

> ......

Step 3: Prepare the query file and enable worklist query.

The server is ready. Here is the worklist query service. The utility is findscu.exe (from the SCU in the tool name, you can also guess that this is a client ). The DCMTK source package also provides us with a query file to query worklist, the default directory is dcmtk-3.6.0 \ dcmtk-3.6.0 \ dcmwlm \ data \ tables to convert. Dump to. WL file.

> Dcmp2dcm.exe. \ dcmtk-3.6.0 \ dcmtk-3.6.0 \ dcmwlm \ data \ wklistqrt \ wlistqry1.dump D: \ dcmworklist \ wlistqry. WL

Then we use findscu to initiate a query request,

> Findscu.exe-D 127.0.0.1 104 D: \ dcmworklist \ wlistqry. WL-AEC offis

The AEC indicates the name of the requested or called application, that is, the offis sub-folder in the wlistdb folder.

By taking the last three steps, we simply use the wlmscpf.exeand findscu.exe toolkit of dcmtkw.gov.cn and the corresponding wklistdb database files and wklistqry Database Query files to simulate the entire process of enabling and querying the worklist service. Is it very easy to get started.

Actual result analysis:

When wlmscpfs.exeand findscu.exe toolkit is used, the-D debugging mode is enabled for tracking the entire communication process. In addition, we use the redirection technology to output the debugging information of wlmscpfs.exeand findscu.exe toolkit to the TXT file, so that we can compare and view it later. The debugging information of the two toolkit is opened with notopad ++. For a comparative analysis, see:

The communication process between wlmscpfs.exeand findscu.exe can be clearly seen from the tracing information. This process is detailed in service class specifications and network communication support for message exchange of dicom3.0, the text document generated by the above redirection is the best example of learning dicom3.0 Part 4 and Part 8. Because dcmtkis an open source, we can analyze the source code of wlmscpfs.exeand findscu.exe. For detailed analysis, see the next section.

Wlmscpfs.exeand findscu.exe toolkit source code analysis:
  Wlmscpfs.exe Findscu.exe
C/S Worklist Server Worklist Client
Source code file Wlmscpfs. CC
Wlcefs. CC
Wlmactmg. CC
Findscu. CC
Internal functions 1) connecttodatasource (); // enable the connection
2) wlmactivitymanager ();
// The function uses wsastartup () to start the Windows Socket service.
3) startprovidingservice ();
// Start the worklist Management Service, which is located in the wlmactmg. CC file. The function calls (a) (B) two functions internally.
(A) asc_initializenetwork () function
The asc_initializenetwork function calls the TCP function dul_initializenetwork encapsulated by the DICOM protocol. (This function contains the socket, setsockopt, bind, and listen functions that are common in socket programming)
(B) waitforassociation (); Function
The waitforassociation function calls the DICOM encapsulation TCP/IP function receivetransportconnectiontcp (this function uses the Select Port mode internally, and common select and accept functions in socket programming will appear)
4) disconnectfromdatasource ();
// Disconnect a function.
1) wsastartup (); // initialize the socket Service
2) dcmfindscu: initializenetwork ();
// The function calls the asc_initializenetwork function.
3) dcmfindscu: descrimquery ();
// Similarly, this function encapsulates many protocol operation functions starting with DUl. DUL is the abbreviation of DICOM upper layer.
4) wsacleanup ();

From the above analysis, we can basically see that the worklist communication is based on the current TCP/IP protocol, which can be said to be a secondary encapsulation of the Protocol. Similar to the basic process of socket programming, the analysis toolkit and the learning toolkit will be of great help.

Worklist database file or query file (*. WL) generation: 1) question raised:

As described in Leng GE's blog, we can easily use DCMTK's toolkit to learn worklist operations. However, some people may be curious about the actual imitation process.Why?Do you want to put the wklist. WL and wklistqry. WL files in different directories?Why?Files with the same. WL extension can be stored on the server as the worklist database file, and the other is the query file of the customer ticket? If you want to initiate your own query, that is, the C-FIND request, weHow to manually generateWklistqry. WL file?

In response to the above questions, in the DCMTK Forum has also been mentioned, see (http://forum.dcmtk.org/viewtopic.php? F=1&t=1475&hilit=wlmscpfs.exe % 23p5016 ). Use the ultraedit tool to open the wklist. WL and wklistqry. WL files at the same time. The comparison is as follows:

We can see that wklist is used as the worklist client database file. WL stores the patient's real information in the form that complies with the dicom3.0 standard field, and the wklistqry that the client initiates the query request. the WL file contains only simple empty fields to be queried, that is, the value fields of each field are empty. The dump2dcm.exe toolkit is used to convert the. dump file to the wklistqry. WL file (dump can be considered as a common text file and can be directly edited using notepad and other tools ). As shown in:

For example, the patient ID in the wlist-2.dump file used as the test is 123456, and the (123456) field in the generated wlist-2.wl file is also.

2) actual test:

We can understand the description of the dump2dcm.exe toolkit ,.WL is actually a DCM file., But this type of file does not contain real pixel information. Generally, only the information header is included. It mainly refers to the patient's information. Therefore, to use the DCMTK library function to directly obtain the. WL file is actually the process of manually constructing the DCM file. For more information, see. The specific code is as follows:

 

# Include <stdio. h> # include <tchar. h> # include "DCMTK/config/osconfig. H "# include" DCMTK/dcmdata/dctk. H "# include" DCMTK/dcmdata/dcpxitem. H "# include" DCMTK/dcmjpeg/djdecode. H "# include" DCMTK/dcmjpeg/djencode. H "# include" DCMTK/dcmjpeg/djcodece. H "# include" DCMTK/dcmjpeg/djrplol. H "using namespace STD; int main () {char uid [100]; dcmfileformat fileformat; dcmdataset * dataset = fileformat. getdataset (); /*************************************** * ******** the following statements can be used to generate a worklist database file, that is, * DCM files without Image Information ******************************* * ****************/dataset-> putandinsertstring (dcm_sopclassuid, dependencies); dataset-> putandinsertstring (dcm_sopinstanceuid, uid, identifier); dataset-> putandinsertstring (dcm_patientname, "doe ^ John"); ofcondition status = fileformat. saveFile ("d :\\ dcmworklist \ worklist \ test. WL ", exs_littleendianexplicit); If (status. bad () cerr <"error: cannot write DICOM file (" <status. text () <")" <Endl; return 0 ;}

Since the worklist database files required by the server and the Query files required by the client are both. WL files, the only difference is that there is a value field and no one. Therefore, using the above code, we can generate a worklist database file or a worklist Query file.

3) test results:

Using the findscu.exe toolkit, we can find the-K option, that is, when the wklistqry. WL file is provided, a limited query field can also be specified, for example

> Findscu 127.0.0.1 104-v-K 0010,0020 = "123456"-AEC offis wlistqry. WL

If the-K 123456, = "" restriction option is not added, the query results are the same as the redirection results in the previous article. After a qualified field is added, we can only query patient data that meets the patientid field of 123456 in the database. The specific results are as follows:

From this, we can see that the service end gives us the patient information with patientid of 123456, and the returned information is wlistqry. in the WL file, the query results are limited by the-K 123456, = "" restriction, the feedback on the server side shows that two patients have a matched worklist database file, as shown in the yellow area.

Conjecture:Since we can use DCMTK to freely generate the client. WL queries the file, and-K 123456, 123456 = "" is a supplement to the query file, so if we directly write to wlistqry. the value range of the (,) Field in WL, and directly use the modified Query file to get the same result? Here, you can use your own code to fill the value range of 123456 and fields

# Include <stdio. h> # include <tchar. h> # include "DCMTK/config/osconfig. H "# include" DCMTK/dcmdata/dctk. H "# include" DCMTK/dcmdata/dcpxitem. H "# include" DCMTK/dcmjpeg/djdecode. H "# include" DCMTK/dcmjpeg/djencode. H "# include" DCMTK/dcmjpeg/djcodece. H "# include" DCMTK/dcmjpeg/djrplol. H "using namespace STD; int main () {char uid [100]; dcmfileformat fileformat; dcmdataset * dataset = fileformat. getdataset (); /*************************************** * ******* [guess 1 ]: * use the following statement to generate a worklist Query file * that is, * The DCM file with empty field data is ******************************* * ***************/dataset-> putandinsertstring (dcm_sopclassuid, dataset); dataset-> putandinsertstring (dcm_sopinstanceuid, uid, identifier); dataset-> putandinsertstring (identifier, "identifier"); dataset-> putandinsertstring (identifier, ""); dataset-> putandinsertstring (dcm_patientname, ""); dataset-> putandinsertstring (dcm_patientid, "123456"); dataset-> putandinsertstring (inputs ,""); dataset-> putandinsertstring (dcm_patientsex, ""); ofcondition status = fileformat. saveFile ("d :\\ dcmworklist \ worklist \ testqry. WL ", exs_littleendianexplicit); If (status. bad () cerr <"error: cannot write DICOM file (" <status. text () <")" <Endl; return 0 ;}


Then use

> The findscu 127.0.0.1 104-v-AEC offis testqry. WL command directly initiates a query.

Shows the query result feedback:

Proves our conjecture,The value of the relevant fields written in wlistqry.wlis the same as the-k xxxx and XXXX limitation options added in the findscu.exe command..

Now we have introduced in detail how to simulate the worklist dual-end service, how to enable the server service, and how to initiate a client query. The key is how to use the DCMTK library function to generate a custom query end. the WL file is used to test the supplemental settings of instances.

(End)

 

[Email protected]

Time: 2014-08-23

DICOM medical image processing: Learning and analyzing worklist Based on DCMTK Toolkit

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.