I'm new to pydicom so more likely than not I'm doing something wrong. I have a script that will iterate over a list of series instance UIDs and issue a SERIES-level C-FIND against a DICOM SCP. Every so often (but quite often) I get an error on the screen stating:
I can't pinpoint from which series it's coming, and I have tried a few that should be triggering this but when I issue just one C-FIND I don't get that warning.
def cfind(self, series_uid):
# debug_logger()
ae = AE()
ae.ae_title = self.calling_ae
ae.add_requested_context(StudyRootQueryRetrieveInformationModelFind)
# Associate with the peer AE at IP 127.0.0.1 and port 11112
logging.getLogger().setLevel(logging.FATAL)
assoc = ae.associate(self.ip, self.port, ae_title=self.called_ae)
if assoc.is_established:
# Send the C-FIND request
# Create our Identifier (query) dataset
ds = Dataset()
ds.add_new(0x0020000E, 'UI', series_uid)
ds.add_new(0x0020000D, 'UI', '')
ds.QueryRetrieveLevel = 'SERIES'
ds.add_new(0x00100010, 'PN', '') # Patient Name
ds.add_new(0x00100020, 'LO', '') # MRN
ds.add_new(0x00080060, 'CS', '') # Modality
ds.add_new(0x00080050, 'SH', '') # Acc#
ds.add_new(0x00081030, 'LO', '') # Study description
ds.add_new(0x0008103E, 'LO', '') # Series description
responses = assoc.send_c_find(ds, StudyRootQueryRetrieveInformationModelFind)
dicom_result = None
for (status, identifier) in responses:
if status and status.Status in [0xff00, 0xff01]:
try:
logging.info("MRN:\t\t\t" + identifier.PatientID)
logging.info("PatientName:\t" + str(identifier.PatientName))
logging.info("Study desc:\t\t" + identifier.StudyDescription)
logging.info("Series desc:\t\t" + identifier.SeriesDescription)
logging.info("Acc#:\t\t\t" + identifier.AccessionNumber)
logging.info("Study Ins UID:\t\t\t" + identifier.StudyInstanceUID)
logging.info("Series Ins UID:\t\t\t" + identifier.SeriesInstanceUID)
dicom_result = DicomResult(MRN=identifier.PatientID,
PatientName=identifier.PatientName,
SeriesDescription=identifier.SeriesDescription,
StudyDescription=identifier.StudyDescription,
AccessionNumber=identifier.AccessionNumber,
SeriesInstanceUID=identifier.SeriesInstanceUID,
StudyInstanceUID=identifier.StudyInstanceUID)
break
except AttributeError as ae:
logging.error('C-FIND query status: 0x{0:04X}'.format(status.Status))
logging.error(f"Got error when trying to extract elements from C-FIND response: {ae} - SUID: {study_uid}")
elif status and status.Status in [0x0000]:
# Final response with no particular data. PHS PACS responds with this at the end of a C-FIND.
break
else:
raise ValueError('Connection timed out, was aborted or received invalid response.\nStatus: 0x{0:04X}'.format(status.Status))
# Release the association
assoc.release()
logging.getLogger().setLevel(logging.INFO)
return dicom_result
else:
logging.getLogger().setLevel(logging.INFO)
raise ValueError(f'Association rejected, aborted or never connected - parameters {self.__str__()}')
I don't see any errors or data missing, but that just warnings sent out to stdout/stderr (not sure which - didn't check).