fo-dicom - How can I download dcm images from PACS and save them?

别等时光非礼了梦想. 提交于 2020-01-24 22:55:08

问题


I'm trying to download dcm image from PACS server, but this is generating an empty dcm file.

Following is the code:

public void VisoresPacsController(string ipAddress, string aeTitle, string accessId, int port)
{
    /*
    this.ipAddress = ipAddress;
    this.aeTitle = aeTitle;
    this.accessId = accessId;
    this.port = port;
    visores.Add(new VisorCommandLine("Radiant", ""));
    ///new DicomCStoreRequest.
    */
    DicomClient client = new DicomClient();
    var query = DicomCFindRequest.CreateImageQuery("1.2.250.1.31.2.723.19980722.113224.11597", "1.2.250.1.31.3.723.19980722.113224.11597");
    client.AddRequest(query);
    query.OnResponseReceived = onResponse;
    client.Send("70.38.12.40", 4242, false, "THS", "ORTHANC");
}

public void onResponse(DicomCFindRequest req, DicomCFindResponse res)
{
    DicomDataset dataset = res.Dataset;
    dataset.Add(DicomTag.SOPClassUID, "1.2.250.1.31.4.723.19980722.113224.11597");
    //dataset.Add(DicomTag.StudyInstanceUID, GenerateUid());
    //dataset.Add(DicomTag.SeriesInstanceUID, GenerateUid());
    //dataset.Add(DicomTag.SOPInstanceUID, GenerateUid());
    DicomFile dicomFile = new DicomFile(dataset);
    dicomFile.Save(@"C:\Users\Developer 13\Desktop\dicomfile.dcm");
}

My code


回答1:


Well the word "download" is bit odd here. The proper word is Query-Retrieve.

This is two step operation, first part is Query (CFind) that you are already doing.

You can compare this with database query. Suppose you have a table with path of file and name. Your program do not know the path. So you run a query on database something like SELECT Name, Path FROM FilesTable. Database returns you the data. This is what happen with CFind and this is what you are getting in onResponse(DicomCFindRequest req, DicomCFindResponse res). The data in the res is one record returned by database. This is NOT actual file..

Now the next part is to download this file from the path you just received. So, you do some file operation like File.Copy(srcPath, destPath) or may be HTTP/FTP download. In DICOM, this could be achieved in two ways - CGet and CMove. CMove is more popular for many reasons.

As in my example, if you already know the path and name of file, you can bypass database query. Similarly, you can bypass CFind and directly do CMove if you know the identifiers in advance. Refer this post.

This paragraph will be bit complicated and may have some variations in workflow with different implementations. To do CMove, there must exist a CStoreSCP. You (CMoveSCU) will send CMove command to PACS (CMoveSCP) with AE Title of CStoreSCP where you want to receive instances. That means either you should also develop your own CStoreSCP or you should involve some other. CMoveSCP will read the AE Title you sent and will match it with its configurations. That means your CStoreSCP must be configured on PACS in advance. From configurations, it will take IP address and Port where it will establish NEW association. This is called Role Switching. CMoveSCP now also works as CStoreSCU. Acting as a CStoreSCU, PACS will then push instances to your CStoreSCP. This way, you actually get the images/instances.

I am not fo-dicom developer (@AndersGustafsson is expert in that tool. I guess he is also contributing to the project); but I am sure this must be simple looking at the efforts you have already put. When I was new to DICOM, I rarely had a problem with syntax. Most of the time, I had a problem with concept and terminology. I tried to explain it here with the best way I can. Hope this helps you.

Refer artilcles from Rony:
http://dicomiseasy.blogspot.in/2012/01/dicom-queryretrieve-part-i.html
http://dicomiseasy.blogspot.in/2012/02/c-move.html

Edit 1:

I found some sample code at the link posted by @AndersGustafsson in his answer.

var cmove = new DicomCMoveRequest("DEST-AE", studyInstanceUid);
var client = new DicomClient();
client.AddRequest(cmove);
client.Send("127.0.0.1", 11112, false, "SCU-AE", "SCP-AE");             // Alt 1
await client.SendAsync("127.0.0.1", 11112, false, "SCU-AE", "SCP-AE");  // Alt 2



回答2:


C-FIND is not used to get the entire DICOM file, it is used to filter out e.g. the images belonging to a specific study and series. If the study and series instance UIDs specified in the CreateImageQuery call are available with images at the PACS, the PACS will respond with C-FIND responses where the dataset contains the SOP Instance UID of each image identified.

You will then need to make a C-GET or C-MOVE to obtain the actual image from the PACS.

For more info on how to use the various network calls, see the README page of the fo-dicom Github repository, or examine the network unit tests in the repository.



来源:https://stackoverflow.com/questions/44318168/fo-dicom-how-can-i-download-dcm-images-from-pacs-and-save-them

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!