Howto get a patientUID from DICOM database?

Well, I’ve got the patient’s name from Dicom database. but howto get a patientUID from DICOM database?

volumeNode = Helper.getFirstNodeByClass("vtkMRMLScalarVolumeNode")
# Get series instance UID from subject hierarchy
shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)
volumeItemId = shNode.GetItemByDataNode(volumeNode)
seriesInstanceUID = shNode.GetItemUID(volumeItemId, 'DICOM')
# Get patient name (0010,0010) from the first file of the series
instUids = slicer.dicomDatabase.instancesForSeries(seriesInstanceUID)
print(slicer.dicomDatabase.instanceValue(instUids[0], '0010,0010')) # patient name

from Script repository — 3D Slicer documentation

from slicer.readthedocs.io
I use this code dicomDatabase.setVisibilityForField("Patients", "UID", True) get the ‘UID’ column.

Please don’t share patient data. You can unfocus that text with the names so it is not seen

image
sorry, but I don’t know how to delete the posted picture…

[0010,0020] should hold PatientID

Good luck !

image
不对呀, 我想要UID而不是patientID

Nope, I want UID not patientID…

[0020,000d] StudyInstanceUID
[0020,000e] SeriesInstanceUID
[0020,0010] StudyID
[0020,0011] SeriesNumber

image
:cold_sweat:

what do you expect ?

I want the UID, ,
image

I think this is the function you need Slicer/DICOMUtils.py at master · Slicer/Slicer · GitHub

So

from DICOMLib import DICOMUtils
DICOMUtils.getDatabasePatientUIDByPatientName('PatientName')
2 Likes

Thanks! @cpinter