本文介绍了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_arraybut 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.

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

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中包含错误文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 18:17