pydicom数据集:send_c_find返回成功,但status.pixel_array中包含错误文本 [英] pydicom Dataset: send_c_find return success but status.pixel_array has error text in it

查看:115
本文介绍了pydicom数据集:send_c_find返回成功,但status.pixel_array中包含错误文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将dcm4chee用作PACS服务器,并试图根据患者姓名检索研究.

I'm using dcm4chee as PACS server and I'm trying to retrieve a study based on a patient name.

相关代码为:

ae = AE()
ae.add_requested_context(PatientRootQueryRetrieveInformationModelFind)
ae.add_requested_context(VerificationSOPClass)
assoc = ae.associate(config['pacs_remotehost']['ip'], config['pacs_remotehost']['ports']['DICOM'],ae_title='DCM4CHEE')

if assoc.is_established:
    ds = Dataset()
    ds.PatientName = '*************' #name erased 
    ds.QueryRetrieveLevel = 'PATIENT'
    ds.StudyInstanceUID = ''
    responses = assoc.send_c_find(ds, query_model='P')
    for (status, identifier) in responses:
        if status:
           print('C-FIND query status: 0x{0:04x}'.format(status.Status))

           # If the status is 'Pending' then `identifier` is the C-FIND response
           if status.Status in (0xFF00, 0xFF01):
               print(identifier)
        else:
           print('Connection timed out, was aborted or received invalid response')

# Release the association
    assoc.release()
else:
    print('Association rejected, aborted or never connected')

我收到了成功信号:

C-FIND查询状态:0x0000

C-FIND query status: 0x0000

但是当我想访问像素数据时,我输入status.pixel_array但是它包含以下错误,而不是Numpy数组:

But when I want to access the pixel data so I type status.pixel_array but instead of a Numpy array, it contains the following error:

    File "<ipython-input-2-c65fb50a50a6>", line 1, in <module>
    status.pixel_array File "/usr/local/lib/python2.7/site-packages/pydicom/dataset.py", line 552, in __getattr__
    return super(Dataset, self).__getattribute__(name)
  File "/usr/local/lib/python2.7/site-packages/pydicom/dataset.py", line 949, in pixel_array
    self.convert_pixel_data()
  File "/usr/local/lib/python2.7/site-packages/pydicom/dataset.py", line 816, in convert_pixel_data
    transfer_syntax = self.file_meta.TransferSyntaxUID
  File "/usr/local/lib/python2.7/site-packages/pydicom/dataset.py", line 552, in __getattr__
    return super(Dataset, self).__getattribute__(name)
AttributeError: 'Dataset' object has no attribute 'file_meta'

有人知道我为什么会收到此错误而不是图像吗?

Does anyone know why I get this error and not the images?

推荐答案

我不太了解您要做什么(也不知道所涉及的技术),但是我认为您的理解是错误的.

I do not quite understood what you are trying to do (and do not know the technology in question), but I think your understanding is incorrect.

您正在做患者C级查找.您正在获得响应(匹配条目),然后最终获得成功响应.好.

You are doing PATIENT level C-FIND. You are getting responses (matching entries) and then finally SUCCESS response. Good.

然后,您正在尝试访问那些响应中的像素数据元素吗?-没有道理.

Then, you are trying to access pixel data element in those responses? - does not make sense.

C-FIND,不提供实际的实例/图像.它只是为您提供SCP上存在的条目,它们符合您的搜索条件,并最终获得成功响应.如果找不到匹配的条目,则仅返回最终的SUCCESS响应.

C-FIND, do not give you actual instance/image. It just gives you the entries those exist on SCP those match your search criteria and finally a SUCCESS response. If no matching entries found, only final SUCCESS response is returned.

因此,您希望针对这些条目的像素数据不存在于其中.您还必须根据在C-FIND响应中收到的标识符执行C-MOVE(或C-GET).我已经在此处中对此进行了详细说明.

So, you want pixel data against those entries, it does not present in there. You further have to do C-MOVE (or C-GET) based on identifiers you received in your C-FIND Response. I have explained this in details here.

此段会有点复杂,并且在工作流程方面可能会因采用不同的实现方式而有所不同.要进行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.

那样,您实际上将获得实例.有了实例后,就可以访问这些实例中的像素数据.

That way, you will actually get the instances. When you have the instances, you can access pixel data in those instances.

请参考这篇优秀文章,以学习有关Q/R的工作方式的更多信息.

Please refer this excellent article to learn more about how Q/R works.

一个简单的真实示例:

您有一个数据库表,其中包含个人ID和其个人资料照片的URL.您想要将该个人资料照片加载到您的网页中.

You have a database table which contains person id and URL to his profile photo. You want to load that profile photo in your web page.

因此,您首先触发SQL查询(DICOM中为C-FIND)并获取记录.然后,从记录中读取URL.使用此URL,您将开始从服务器下载照片的新操作(DICOM中的C-MOVE).下载完照片后,您可以将其加载到网页中.

So, you first fire a SQL query (C-FIND in DICOM) and get the records. Then, from records you read the URL. With this URL, you start new action of downloading photo from server (C-MOVE in DICOM). Once you have the photo downloaded, you can load it in your web page.

Yaaa ..该示例是错误的,并不完全匹配.但是,我希望您了解其中涉及两个不同的动作.

Yaaa.. the example is bad and does not match exactly. But, I hope you understand that there are two different actions involved.

这篇关于pydicom数据集:send_c_find返回成功,但status.pixel_array中包含错误文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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