问题
I'm using dcm4chee as PACS server and I'm trying to retrieve a study based on a patient name.
The relevant code is:
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')
I got a success signal:
C-FIND query status: 0x0000
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?
回答1:
I fully agree to what Amit Joshi said, but I would like to add that even when you perform a C-MOVE with the identifiers found in C-FIND, you will not be able to obtain the pixel data from the Status. The Status only conveys the status of the C-FIND/C-MOVE operation, not the data being transferred.
For C-MOVE (which is much more commonly supported than C-GET), the Move-SCP will open a C-STORE connection to the move destination AE and transfer the images through that connection. That is, C-MOVE only transfers status information about the image transfer, not the images themselves.
回答2:
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.
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, 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.
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.
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.
Please refer this excellent article to learn more about how Q/R works.
Simple real-life example:
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.
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.. the example is bad and does not match exactly. But, I hope you understand that there are two different actions involved.
来源:https://stackoverflow.com/questions/55075964/pydicom-dataset-send-c-find-return-success-but-status-pixel-array-has-error-tex