fo-dicom-如何从PACS下载dcm图像并保存? [英] fo-dicom - How can I download dcm images from PACS and save them?

查看:1204
本文介绍了fo-dicom-如何从PACS下载dcm图像并保存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从PACS服务器下载dcm图像,但这会生成一个空的dcm文件.

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

以下是代码:

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");
}

我的代码

推荐答案

用下载"一词表示;这里有点奇怪.正确的词是查询检索".

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

这是两步操作,第一部分是您已经在执行的查询(CFind).

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

您可以将此与数据库查询进行比较.假设您有一个包含文件和名称路径的表.您的程序不知道路径.因此,您对数据库进行查询,例如SELECT Name, Path FROM FilesTable.数据库返回您的数据. CFind就是这种情况,这就是您在onResponse(DicomCFindRequest req, DicomCFindResponse res)中所得到的. res中的数据是数据库返回的一条记录. 这不是实际文件..

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..

现在,下一部分是从您刚刚收到的路径下载该文件.因此,您可以执行某些文件操作,例如File.Copy(srcPath, destPath)或通过HTTP/FTP下载.在DICOM中,这可以通过两种方式实现-CGet和CMove. CMove之所以受欢迎,有很多原因.

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.

在我的示例中,如果您已经知道文件的路径和名称,则可以绕过数据库查询.同样,如果您事先知道标识符,则可以绕过CFind并直接执行CMove.请参阅帖子.

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.

此段会有点复杂,并且在工作流程方面可能会因采用不同的实现方式而有所不同.要进行CMove,必须存在一个CStoreSCP.您(CMoveSCU)将向您想要接收实例的CStoreSCP的AE标题将CMove命令发送到PACS(CMoveSCP).这意味着您还应该开发自己的CStoreSCP或参与其他项目. CMoveSCP将读取您发送的AE标题,并将其与其配置进行匹配.这意味着您必须预先在PACS上配置CStoreSCP.从配置中,它将使用IP地址和端口来建立NEW关联.这称为角色切换. CMoveSCP现在也可以用作CStoreSCU. PACS充当CStoreSCU,然后将实例推送到您的CStoreSCP.这样,您实际上可以获得图像/实例.

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.

我不是fo-dicom开发人员(@AndersGustafsson是该工具的专家.我想他也为该项目做出了贡献);但是我相信,从您已经付出的努力来看,这一定很简单.当我刚接触DICOM时,我很少遇到语法问题.大多数时候,我在概念和术语上都有疑问.我试图以最好的方式在这里进行解释.希望对您有帮助.

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.

请参阅Rony的关节炎文章:
http://dicomiseasy.blogspot.in/2012/01/dicom-queryretrieve-part-i.html
http://dicomiseasy.blogspot.in/2012/02/c-move. html

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

我在@AndersGustafsson在他的答案中发布的链接中找到了一些示例代码.

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

这篇关于fo-dicom-如何从PACS下载dcm图像并保存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆