Note
DICOM metadata is distinct from
clientMetadata
, which is the metadata associated with individual data units. See our tutorial onclientMetadata
for more information.
DICOM related metadata is accessed by specifying the dataset using the <project_hash>. It contains the patient ID, series ID, and study ID that link the unlabeled DICOM data to the labeled data that is exported from Encord.
Reading series metadata
The following code reads and prints the patient ID (patient_id
), series ID (series_uid
) and study ID (study_uid
) of all label rows in the specified project.
Note
#Import dependencies
from encord import EncordUserClient
# Authenticate with Encord using the path to your private key
client = EncordUserClient.create_with_ssh_private_key(
ssh_private_key_path="<private_key_path>"
)
# Specify the project for which you want to read the patient and series IDs
project = client.get_project("<project_hash>")
# Fetch the label and frame information for this project
label_rows = project.list_label_rows_v2()
for label_row in label_rows:
# Initialize labels
label_row.initialise_labels()
# Print Patient ID, Series ID, and Study ID
print (label_row.metadata)
patient_id='example_fmri_140207' study_uid='1.2.840.113619.6.283.47340.8065.13236498290.27' series_uid='1.2.840.113619.2.28.3100000.21673.1390073.97'
Reading frame metadata
The following code reads and prints frame specific DICOM metadata including the DICOM instance ID (dicom_instance_uid
), the multiframe frame number (multiframe_frame_number
), the file URI (file_uri
) and the height as well as width of the frame, as can be seen in the sample output provided.
#Import dependencies
from encord import EncordUserClient
# Authenticate with Encord using the path to your private key
client = EncordUserClient.create_with_ssh_private_key(
ssh_private_key_path="<private_key_path>"
)
# Specify the project for which you want to read the patient and series IDs
project = client.get_project("<project_hash>")
# Fetch the label and frame information for this project
label_rows = project.list_label_rows_v2()
for label_row in label_rows:
# Initialize labels
label_row.initialise_labels()
# Print Frame specific DICOM metadata
for v in label_row.get_frame_views():
print(v.metadata)
dicom_instance_uid='1.5.740.183619.283.6905.311000.16119.13000477777.716' multiframe_frame_number=None file_uri='my-storage-location/iaDJxNNrMubabutFPcP9oszw2shmeHm2/5e8880c2-9177-4cf6-b298-ebd3d1d31eb8' width=256 height=256