Copying an image set - AWS HealthImaging

Copying an image set

Use the CopyImageSet action to copy an image set in HealthImaging. You use this asynchronous process to copy the contents of an image set into a new or existing image set. You can copy into a new image to split an image set, as well as to create a separate copy. You can also copy into an existing image set to merge two image sets together. For more information, see CopyImageSet in the AWS HealthImaging API Reference.

Note

Keep the following points in mind when copying an image set:

  • Copying an image set creates a new version in the image set history. For more information, see Listing image set versions.

  • Copying an image set is an asynchronous process. Therefore, the state (imageSetState) and status (imageSetWorkflowStatus) response elements are available to let you know what operation is happening on a locked image set. Other write operations cannot be performed on a locked image set.

  • CopyImageSet requires unique SOP Instance UIDs to succeed. Therefore, you must pick the correct SOP Instance by removing it from the unwanted image set.

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

  • Real-world DICOM imports can result in multiple image sets per DICOM Series. Consider the following points when using the CopyImageSet action:

    • Copies Instances from one image set to another

    • Copy requires both image sets to have consistent metadata

To copy an image set

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

CLI
AWS CLI

Example 1: To copy an image set without a destination.

The following copy-image-set code example makes a duplicate copy of an image set without a destination.

aws medical-imaging copy-image-set \ --datastore-id 12345678901234567890123456789012 \ --source-image-set-id ea92b0d8838c72a3f25d00d13616f87e \ --copy-image-set-information '{"sourceImageSet": {"latestVersionId": "1" } }'

Output:

{ "destinationImageSetProperties": { "latestVersionId": "2", "imageSetWorkflowStatus": "COPYING", "updatedAt": 1680042357.432, "imageSetId": "b9a06fef182a5f992842f77f8e0868e5", "imageSetState": "LOCKED", "createdAt": 1680042357.432 }, "sourceImageSetProperties": { "latestVersionId": "1", "imageSetWorkflowStatus": "COPYING_WITH_READ_ONLY_ACCESS", "updatedAt": 1680042357.432, "imageSetId": "ea92b0d8838c72a3f25d00d13616f87e", "imageSetState": "LOCKED", "createdAt": 1680027126.436 }, "datastoreId": "12345678901234567890123456789012" }

Example 2: To copy an image set with a destination.

The following copy-image-set code example makes a duplicate copy of an image set with a destination.

aws medical-imaging copy-image-set \ --datastore-id 12345678901234567890123456789012 \ --source-image-set-id ea92b0d8838c72a3f25d00d13616f87e \ --copy-image-set-information '{"sourceImageSet": {"latestVersionId": "1" }, "destinationImageSet": { "imageSetId": "b9a06fef182a5f992842f77f8e0868e5", "latestVersionId": "1"} }'

Output:

{ "destinationImageSetProperties": { "latestVersionId": "2", "imageSetWorkflowStatus": "COPYING", "updatedAt": 1680042505.135, "imageSetId": "b9a06fef182a5f992842f77f8e0868e5", "imageSetState": "LOCKED", "createdAt": 1680042357.432 }, "sourceImageSetProperties": { "latestVersionId": "1", "imageSetWorkflowStatus": "COPYING_WITH_READ_ONLY_ACCESS", "updatedAt": 1680042505.135, "imageSetId": "ea92b0d8838c72a3f25d00d13616f87e", "imageSetState": "LOCKED", "createdAt": 1680027126.436 }, "datastoreId": "12345678901234567890123456789012" }

  • For API details, see CopyImageSet in AWS CLI Command Reference.

Java
SDK for Java 2.x
public static String copyMedicalImageSet(MedicalImagingClient medicalImagingClient, String datastoreId, String imageSetId, String latestVersionId, String destinationImageSetId, String destinationVersionId) { try { CopySourceImageSetInformation copySourceImageSetInformation = CopySourceImageSetInformation.builder() .latestVersionId(latestVersionId) .build(); CopyImageSetInformation.Builder copyImageSetBuilder = CopyImageSetInformation.builder() .sourceImageSet(copySourceImageSetInformation); if (destinationImageSetId != null) { copyImageSetBuilder = copyImageSetBuilder.destinationImageSet(CopyDestinationImageSet.builder() .imageSetId(destinationImageSetId) .latestVersionId(destinationVersionId) .build()); } CopyImageSetRequest copyImageSetRequest = CopyImageSetRequest.builder() .datastoreId(datastoreId) .sourceImageSetId(imageSetId) .copyImageSetInformation(copyImageSetBuilder.build()) .build(); CopyImageSetResponse response = medicalImagingClient.copyImageSet(copyImageSetRequest); return response.destinationImageSetProperties().imageSetId(); } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } return ""; }
  • For API details, see CopyImageSet in AWS SDK for Java 2.x API Reference.

Note

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

JavaScript
SDK for JavaScript (v3)

Utility function to copy an image set.

import { CopyImageSetCommand } from "@aws-sdk/client-medical-imaging"; import { medicalImagingClient } from "../libs/medicalImagingClient.js"; /** * @param {string} datastoreId - The ID of the data store. * @param {string} imageSetId - The source image set ID. * @param {string} sourceVersionId - The source version ID. * @param {string} destinationImageSetId - The optional ID of the destination image set. * @param {string} destinationVersionId - The optional version ID of the destination image set. */ export const copyImageSet = async ( datastoreId = "xxxxxxxxxxx", imageSetId = "xxxxxxxxxxxx", sourceVersionId = "1", destinationImageSetId = "", destinationVersionId = "" ) => { const params = { datastoreId: datastoreId, sourceImageSetId: imageSetId, copyImageSetInformation: { sourceImageSet: { latestVersionId: sourceVersionId }, }, }; if (destinationImageSetId !== "" && destinationVersionId !== "") { params.copyImageSetInformation.destinationImageSet = { imageSetId: destinationImageSetId, latestVersionId: destinationVersionId, }; } const response = await medicalImagingClient.send( new CopyImageSetCommand(params) ); console.log(response); // { // '$metadata': { // httpStatusCode: 200, // requestId: 'd9b219ce-cc48-4a44-a5b2-c5c3068f1ee8', // extendedRequestId: undefined, // cfId: undefined, // attempts: 1, // totalRetryDelay: 0 // }, // datastoreId: 'xxxxxxxxxxxxxx', // destinationImageSetProperties: { // createdAt: 2023-09-27T19:46:21.824Z, // imageSetArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxxxx:datastore/xxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxxxxxx', // imageSetId: 'xxxxxxxxxxxxxxx', // imageSetState: 'LOCKED', // imageSetWorkflowStatus: 'COPYING', // latestVersionId: '1', // updatedAt: 2023-09-27T19:46:21.824Z // }, // sourceImageSetProperties: { // createdAt: 2023-09-22T14:49:26.427Z, // imageSetArn: 'arn:aws:medical-imaging:us-east-1:xxxxxxxxxxx:datastore/xxxxxxxxxxxxx/imageset/xxxxxxxxxxxxxxxx', // imageSetId: 'xxxxxxxxxxxxxxxx', // imageSetState: 'LOCKED', // imageSetWorkflowStatus: 'COPYING_WITH_READ_ONLY_ACCESS', // latestVersionId: '4', // updatedAt: 2023-09-27T19:46:21.824Z // } // } return response; };

Copy an image set without a destination.

try { await copyImageSet( "12345678901234567890123456789012", "12345678901234567890123456789012", "1" ); } catch (err) { console.error(err); }

Copy an image set with a destination.

try { await copyImageSet( "12345678901234567890123456789012", "12345678901234567890123456789012", "4", "12345678901234567890123456789012", "1" ); } catch (err) { console.error(err); }
  • For API details, see CopyImageSet in AWS SDK for JavaScript API Reference.

Note

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

Python
SDK for Python (Boto3)

Utility function to copy an image set.

class MedicalImagingWrapper: def __init__(self, health_imaging_client): self.health_imaging_client = health_imaging_client def copy_image_set( self, datastore_id, image_set_id, version_id, destination_image_set_id=None, destination_version_id=None, ): """ Copy 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 destination_image_set_id: The ID of the optional destination image set. :param destination_version_id: The ID of the optional destination image set version. :return: The copied image set ID. """ try: copy_image_set_information = { "sourceImageSet": {"latestVersionId": version_id} } if destination_image_set_id and destination_version_id: copy_image_set_information["destinationImageSet"] = { "imageSetId": destination_image_set_id, "latestVersionId": destination_version_id, } copy_results = self.health_imaging_client.copy_image_set( datastoreId=datastore_id, sourceImageSetId=image_set_id, copyImageSetInformation=copy_image_set_information, ) except ClientError as err: logger.error( "Couldn't copy image set. Here's why: %s: %s", err.response["Error"]["Code"], err.response["Error"]["Message"], ) raise else: return copy_results["destinationImageSetProperties"]["imageSetId"]

Copy an image set without a destination.

copy_image_set_information = { "sourceImageSet": {"latestVersionId": version_id} } copy_results = self.health_imaging_client.copy_image_set( datastoreId=datastore_id, sourceImageSetId=image_set_id, copyImageSetInformation=copy_image_set_information, )

Copy an image set with a destination.

copy_image_set_information = { "sourceImageSet": {"latestVersionId": version_id} } if destination_image_set_id and destination_version_id: copy_image_set_information["destinationImageSet"] = { "imageSetId": destination_image_set_id, "latestVersionId": destination_version_id, } copy_results = self.health_imaging_client.copy_image_set( datastoreId=datastore_id, sourceImageSetId=image_set_id, copyImageSetInformation=copy_image_set_information, )

The following code instantiates the MedicalImagingWrapper object.

client = boto3.client("medical-imaging") medical_imaging_wrapper = MedicalImagingWrapper(client)
  • For API details, see CopyImageSet in AWS SDK for Python (Boto3) API Reference.

Note

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