Updating image set metadata - AWS HealthImaging

Updating image set metadata

You use the UpdateImageSetMetadata action to update image set metadata in AWS HealthImaging. You can use this asynchronous process to add, update, and remove image set metadata attributes, which are manifestations of DICOM normalization elements that are created during import. Using the UpdateImageSetMetadata action, you can also remove Series and SOP Instances to keep image sets in sync with external systems and to de-identify image set metadata. For more information, see UpdateImageSetMetadata in the AWS HealthImaging API Reference.

Real-world DICOM imports require updating, adding, and removing attributes from the image set metadata.


Updating image set metadata creates a new version in the image set history. For more information, see Listing image set versions.

Updating image set metadata is an asynchronous process. Therefore, state (imageSetState) and status (imageSetStatus) fields are available to let you know what operation is happening on a locked image set. You cannot perform other write operations on a locked image set.

DICOM element constraints are applied to metadata updates. For more information, see DICOM metadata constraints.

If an image set metadata update action is not successful, call GetImageSet and review the message property. For more information, see Getting image set properties.

The following diagram represents image set metadata being updated in HealthImaging.

Diagram showing what updating image set metadata looks like in HealthImaging.
To update image set metadata

Choose a tab based on your access preference to AWS HealthImaging.


To update image set metadata

The following update-image-set-metadata code example updates image set metadata.

aws medical-imaging update-image-set-metadata \ --datastore-id 12345678901234567890123456789012 \ --image-set-id ea92b0d8838c72a3f25d00d13616f87e \ --latest-version-id 1 \ --update-image-set-metadata-updates file://metadata-updates.json

Contents of metadata-updates.json

{ "DICOMUpdates": { "updatableAttributes": "eyJTY2hlbWFWZXJzaW9uIjoxLjEsIlBhdGllbnQiOnsiRElDT00iOnsiUGF0aWVudE5hbWUiOiJNWF5NWCJ9fX0=" } }

Note: updatableAttributes is a Base64 encoded JSON string. Here is the unencoded JSON string.



{ "latestVersionId": "5", "imageSetWorkflowStatus": "UPDATING", "updatedAt": 1680042257.908, "imageSetId": "ea92b0d8838c72a3f25d00d13616f87e", "imageSetState": "LOCKED", "createdAt": 1680027126.436, "datastoreId": "12345678901234567890123456789012" }

For more information, see Updating image set metadata in the AWS HealthImaging Developers Guide.

SDK for Java 2.x
public static void updateMedicalImageSetMetadata(MedicalImagingClient medicalImagingClient, String datastoreId, String imagesetId, String versionId, MetadataUpdates metadataUpdates) { try { UpdateImageSetMetadataRequest updateImageSetMetadataRequest = UpdateImageSetMetadataRequest .builder() .datastoreId(datastoreId) .imageSetId(imagesetId) .latestVersionId(versionId) .updateImageSetMetadataUpdates(metadataUpdates) .build(); medicalImagingClient.updateImageSetMetadata(updateImageSetMetadataRequest); System.out.println("The image set metadata was updated"); } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } }

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

SDK for JavaScript (v3)
import {UpdateImageSetMetadataCommand} from "@aws-sdk/client-medical-imaging"; import {medicalImagingClient} from "../libs/medicalImagingClient.js"; /** * @param {string} datastoreId - The ID of the HealthImaging data store. * @param {string} imageSetId - The ID of the HealthImaging image set. * @param {string} latestVersionId - The ID of the HealthImaging image set version. * @param {{}} updateMetadata - The metadata to update. */ export const updateImageSetMetadata = async (datastoreId = "xxxxxxxxxx", imageSetId = "xxxxxxxxxx", latestVersionId = "1", updateMetadata = '{}') => { const response = await medicalImagingClient.send( new UpdateImageSetMetadataCommand({ datastoreId: datastoreId, imageSetId: imageSetId, latestVersionId: latestVersionId, updateImageSetMetadataUpdates: updateMetadata }) ); console.log(response); // { // '$metadata': { // httpStatusCode: 200, // requestId: '7966e869-e311-4bff-92ec-56a61d3003ea', // extendedRequestId: undefined, // cfId: undefined, // attempts: 1, // totalRetryDelay: 0 // }, // createdAt: 2023-09-22T14:49:26.427Z, // datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', // imageSetId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', // imageSetState: 'LOCKED', // imageSetWorkflowStatus: 'UPDATING', // latestVersionId: '4', // updatedAt: 2023-09-27T19:41:43.494Z // } return response; };

Encode the metadata.

const updatableAttributes = JSON.stringify({ "SchemaVersion": 1.1, "Patient": { "DICOM": { "PatientName": "Garcia^Gloria" } } }) const updateMetadata = { "DICOMUpdates": { "updatableAttributes": new TextEncoder().encode(updatableAttributes) } }; await updateImageSetMetadata("12345678901234567890123456789012", "12345678901234567890123456789012", "1", updateMetadata);

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

SDK for Python (Boto3)
def update_image_set_metadata( self, datastore_id, image_set_id, version_id, metadata ): """ Update the metadata of an image set. :param datastore_id: The ID of the data store. :param image_set_id: The ID of the image set. :param version_id: The ID of the image set version. :param metadata: The image set metadata as a dictionary. For example {"DICOMUpdates": {"updatableAttributes": "{\"SchemaVersion\":1.1,\"Patient\":{\"DICOM\":{\"PatientName\":\"Garcia^Gloria\"}}}"}} :return: The updated image set metadata. """ try: updated_metadata = self.health_imaging_client.update_image_set_metadata( imageSetId=image_set_id, datastoreId=datastore_id, latestVersionId=version_id, updateImageSetMetadataUpdates=metadata, ) except ClientError as err: logger.error( "Couldn't update image set metadata. Here's why: %s: %s", err.response["Error"]["Code"], err.response["Error"]["Message"], ) raise else: return updated_metadata

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.