本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
搭UpdateImageSetMetadata
配使用 AWS SDK或 CLI
下列程式碼範例會示範如何使用UpdateImageSetMetadata
。
- CLI
-
- AWS CLI
-
範例 1:若要在影像集中繼資料中插入或更新屬性
下列
update-image-set-metadata
範例會在影像集中繼資料中插入或更新屬性。aws medical-imaging update-image-set-metadata \ --datastore-id
12345678901234567890123456789012
\ --image-set-idea92b0d8838c72a3f25d00d13616f87e
\ --latest-version-id1
\ --cli-binary-formatraw-in-base64-out
\ --update-image-set-metadata-updatesfile://metadata-updates.json
metadata-updates.json
的內容{ "DICOMUpdates": { "updatableAttributes": "{\"SchemaVersion\":1.1,\"Patient\":{\"DICOM\":{\"PatientName\":\"MX^MX\"}}}" } }
輸出:
{ "latestVersionId": "2", "imageSetWorkflowStatus": "UPDATING", "updatedAt": 1680042257.908, "imageSetId": "ea92b0d8838c72a3f25d00d13616f87e", "imageSetState": "LOCKED", "createdAt": 1680027126.436, "datastoreId": "12345678901234567890123456789012" }
範例 2:若要從影像集中繼資料移除屬性
下列
update-image-set-metadata
範例會從影像集中繼資料移除屬性。aws medical-imaging update-image-set-metadata \ --datastore-id
12345678901234567890123456789012
\ --image-set-idea92b0d8838c72a3f25d00d13616f87e
\ --latest-version-id1
\ --cli-binary-formatraw-in-base64-out
\ --update-image-set-metadata-updatesfile://metadata-updates.json
metadata-updates.json
的內容{ "DICOMUpdates": { "removableAttributes": "{\"SchemaVersion\":1.1,\"Study\":{\"DICOM\":{\"StudyDescription\":\"CHEST\"}}}" } }
輸出:
{ "latestVersionId": "2", "imageSetWorkflowStatus": "UPDATING", "updatedAt": 1680042257.908, "imageSetId": "ea92b0d8838c72a3f25d00d13616f87e", "imageSetState": "LOCKED", "createdAt": 1680027126.436, "datastoreId": "12345678901234567890123456789012" }
範例 3:若要從影像集中繼資料移除執行個體
下列
update-image-set-metadata
範例會從影像集中繼資料移除執行個體。aws medical-imaging update-image-set-metadata \ --datastore-id
12345678901234567890123456789012
\ --image-set-idea92b0d8838c72a3f25d00d13616f87e
\ --latest-version-id1
\ --cli-binary-formatraw-in-base64-out
\ --update-image-set-metadata-updatesfile://metadata-updates.json
metadata-updates.json
的內容{ "DICOMUpdates": { "removableAttributes": "{\"SchemaVersion\": 1.1,\"Study\": {\"Series\": {\"1.1.1.1.1.1.12345.123456789012.123.12345678901234.1\": {\"Instances\": {\"1.1.1.1.1.1.12345.123456789012.123.12345678901234.1\": {}}}}}}" } }
輸出:
{ "latestVersionId": "2", "imageSetWorkflowStatus": "UPDATING", "updatedAt": 1680042257.908, "imageSetId": "ea92b0d8838c72a3f25d00d13616f87e", "imageSetState": "LOCKED", "createdAt": 1680027126.436, "datastoreId": "12345678901234567890123456789012" }
範例 4:將影像集回復為先前的版本
下列
update-image-set-metadata
範例顯示如何將影像集回復為先前的版本。 CopyImageSet 和 UpdateImageSetMetadata 動作會建立影像集的新版本。aws medical-imaging update-image-set-metadata \ --datastore-id
12345678901234567890123456789012
\ --image-set-id53d5fdb05ca4d46ac7ca64b06545c66e
\ --latest-version-id3
\ --cli-binary-formatraw-in-base64-out
\ --update-image-set-metadata-updates '{"revertToVersionId": "1"}
'輸出:
{ "datastoreId": "12345678901234567890123456789012", "imageSetId": "53d5fdb05ca4d46ac7ca64b06545c66e", "latestVersionId": "4", "imageSetState": "LOCKED", "imageSetWorkflowStatus": "UPDATING", "createdAt": 1680027126.436, "updatedAt": 1680042257.908 }
範例 5:若要將私有DICOM資料元素新增至執行個體
下列
update-image-set-metadata
範例會示範如何將私有元素新增至映像集內的指定執行個體。該DICOM標準允許私有數據元素用於通信無法包含在標準數據元素中的信息。您可以使用UpdateImageSetMetadata 動作建立、更新和刪除私人資料元素。aws medical-imaging update-image-set-metadata \ --datastore-id
12345678901234567890123456789012
\ --image-set-id53d5fdb05ca4d46ac7ca64b06545c66e
\ --latest-version-id1
\ --cli-binary-formatraw-in-base64-out
\ --force \ --update-image-set-metadata-updatesfile://metadata-updates.json
metadata-updates.json
的內容{ "DICOMUpdates": { "updatableAttributes": "{\"SchemaVersion\": 1.1,\"Study\": {\"Series\": {\"1.1.1.1.1.1.12345.123456789012.123.12345678901234.1\": {\"Instances\": {\"1.1.1.1.1.1.12345.123456789012.123.12345678901234.1\": {\"DICOM\": {\"001910F9\": \"97\"},\"DICOMVRs\": {\"001910F9\": \"DS\"}}}}}}}" } }
輸出:
{ "latestVersionId": "2", "imageSetWorkflowStatus": "UPDATING", "updatedAt": 1680042257.908, "imageSetId": "53d5fdb05ca4d46ac7ca64b06545c66e", "imageSetState": "LOCKED", "createdAt": 1680027126.436, "datastoreId": "12345678901234567890123456789012" }
範例 6:若要將私有DICOM資料元素更新為執行個體
下列
update-image-set-metadata
範例顯示如何更新影像集中屬於執行個體的私有資料元素的值。aws medical-imaging update-image-set-metadata \ --datastore-id
12345678901234567890123456789012
\ --image-set-id53d5fdb05ca4d46ac7ca64b06545c66e
\ --latest-version-id1
\ --cli-binary-formatraw-in-base64-out
\ --force \ --update-image-set-metadata-updatesfile://metadata-updates.json
metadata-updates.json
的內容{ "DICOMUpdates": { "updatableAttributes": "{\"SchemaVersion\": 1.1,\"Study\": {\"Series\": {\"1.1.1.1.1.1.12345.123456789012.123.12345678901234.1\": {\"Instances\": {\"1.1.1.1.1.1.12345.123456789012.123.12345678901234.1\": {\"DICOM\": {\"00091001\": \"GE_GENESIS_DD\"}}}}}}}" } }
輸出:
{ "latestVersionId": "2", "imageSetWorkflowStatus": "UPDATING", "updatedAt": 1680042257.908, "imageSetId": "53d5fdb05ca4d46ac7ca64b06545c66e", "imageSetState": "LOCKED", "createdAt": 1680027126.436, "datastoreId": "12345678901234567890123456789012" }
範例 7:若要SOPInstanceUID使用 force 參數更新 a
下列
update-image-set-metadata
範例顯示如何使用 force 參數來覆寫DICOM中繼資料條件約束來更新 a SOPInstanceUID。aws medical-imaging update-image-set-metadata \ --datastore-id
12345678901234567890123456789012
\ --image-set-id53d5fdb05ca4d46ac7ca64b06545c66e
\ --latest-version-id1
\ --cli-binary-formatraw-in-base64-out
\ --force \ --update-image-set-metadata-updatesfile://metadata-updates.json
metadata-updates.json
的內容{ "DICOMUpdates": { "updatableAttributes": "{\"SchemaVersion\":1.1,\"Study\":{\"Series\":{\"1.3.6.1.4.1.5962.99.1.3633258862.2104868982.1369432891697.3656.0\":{\"Instances\":{\"1.3.6.1.4.1.5962.99.1.3633258862.2104868982.1369432891697.3659.0\":{\"DICOM\":{\"SOPInstanceUID\":\"1.3.6.1.4.1.5962.99.1.3633258862.2104868982.1369432891697.3659.9\"}}}}}}}" } }
輸出:
{ "latestVersionId": "2", "imageSetWorkflowStatus": "UPDATING", "updatedAt": 1680042257.908, "imageSetId": "53d5fdb05ca4d46ac7ca64b06545c66e", "imageSetState": "LOCKED", "createdAt": 1680027126.436, "datastoreId": "12345678901234567890123456789012" }
如需詳細資訊,請參閱更新中的影像集中繼資料 AWS HealthImaging 開發人員指南。
-
有API關詳細資訊,請參閱 UpdateImageSetMetadata
(AWS CLI 指令參考。
-
- Java
-
- SDK對於爪哇 2.x
-
/** * Update the metadata of an AWS HealthImaging image set. * * @param medicalImagingClient - The AWS HealthImaging client object. * @param datastoreId - The datastore ID. * @param imageSetId - The image set ID. * @param versionId - The version ID. * @param metadataUpdates - A MetadataUpdates object containing the updates. * @param force - The force flag. * @throws MedicalImagingException - Base exception for all service exceptions thrown by AWS HealthImaging. */ public static void updateMedicalImageSetMetadata(MedicalImagingClient medicalImagingClient, String datastoreId, String imageSetId, String versionId, MetadataUpdates metadataUpdates, boolean force) { try { UpdateImageSetMetadataRequest updateImageSetMetadataRequest = UpdateImageSetMetadataRequest .builder() .datastoreId(datastoreId) .imageSetId(imageSetId) .latestVersionId(versionId) .updateImageSetMetadataUpdates(metadataUpdates) .force(force) .build(); UpdateImageSetMetadataResponse response = medicalImagingClient.updateImageSetMetadata(updateImageSetMetadataRequest); System.out.println("The image set metadata was updated" + response); } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); throw e; } }
使用案例 #1: 插入或更新屬性。
final String insertAttributes = """ { "SchemaVersion": 1.1, "Study": { "DICOM": { "StudyDescription": "CT CHEST" } } } """; MetadataUpdates metadataInsertUpdates = MetadataUpdates.builder() .dicomUpdates(DICOMUpdates.builder() .updatableAttributes(SdkBytes.fromByteBuffer( ByteBuffer.wrap(insertAttributes .getBytes(StandardCharsets.UTF_8)))) .build()) .build(); updateMedicalImageSetMetadata(medicalImagingClient, datastoreId, imagesetId, versionid, metadataInsertUpdates, force);
使用案例 #2: 移除屬性。
final String removeAttributes = """ { "SchemaVersion": 1.1, "Study": { "DICOM": { "StudyDescription": "CT CHEST" } } } """; MetadataUpdates metadataRemoveUpdates = MetadataUpdates.builder() .dicomUpdates(DICOMUpdates.builder() .removableAttributes(SdkBytes.fromByteBuffer( ByteBuffer.wrap(removeAttributes .getBytes(StandardCharsets.UTF_8)))) .build()) .build(); updateMedicalImageSetMetadata(medicalImagingClient, datastoreId, imagesetId, versionid, metadataRemoveUpdates, force);
使用案例 #3: 移除執行個體。
final String removeInstance = """ { "SchemaVersion": 1.1, "Study": { "Series": { "1.1.1.1.1.1.12345.123456789012.123.12345678901234.1": { "Instances": { "1.1.1.1.1.1.12345.123456789012.123.12345678901234.1": {} } } } } } """; MetadataUpdates metadataRemoveUpdates = MetadataUpdates.builder() .dicomUpdates(DICOMUpdates.builder() .removableAttributes(SdkBytes.fromByteBuffer( ByteBuffer.wrap(removeInstance .getBytes(StandardCharsets.UTF_8)))) .build()) .build(); updateMedicalImageSetMetadata(medicalImagingClient, datastoreId, imagesetId, versionid, metadataRemoveUpdates, force);
使用案例 #4: 還原為先前的版本。
// In this case, revert to previous version. String revertVersionId = Integer.toString(Integer.parseInt(versionid) - 1); MetadataUpdates metadataRemoveUpdates = MetadataUpdates.builder() .revertToVersionId(revertVersionId) .build(); updateMedicalImageSetMetadata(medicalImagingClient, datastoreId, imagesetId, versionid, metadataRemoveUpdates, force);
-
有API關詳細資訊,請參閱 UpdateImageSetMetadata(AWS SDK for Java 2.x API參考。
注意
還有更多關於 GitHub。尋找完整範例,並瞭解如何在 AWS 代碼示例存儲庫
。 -
- JavaScript
-
- SDK對於 JavaScript (3)
-
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. * @param {boolean} force - Force the update. */ export const updateImageSetMetadata = async (datastoreId = "xxxxxxxxxx", imageSetId = "xxxxxxxxxx", latestVersionId = "1", updateMetadata = '{}', force = false) => { try { const response = await medicalImagingClient.send( new UpdateImageSetMetadataCommand({ datastoreId: datastoreId, imageSetId: imageSetId, latestVersionId: latestVersionId, updateImageSetMetadataUpdates: updateMetadata, force: force, }) ); 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; } catch (err) { console.error(err); } };
使用案例 #1: 插入或更新屬性並強制更新。
const insertAttributes = JSON.stringify({ "SchemaVersion": 1.1, "Study": { "DICOM": { "StudyDescription": "CT CHEST" } } }); const updateMetadata = { "DICOMUpdates": { "updatableAttributes": new TextEncoder().encode(insertAttributes) } }; await updateImageSetMetadata(datastoreID, imageSetID, versionID, updateMetadata, true);
使用案例 #2: 移除屬性。
// Attribute key and value must match the existing attribute. const remove_attribute = JSON.stringify({ "SchemaVersion": 1.1, "Study": { "DICOM": { "StudyDescription": "CT CHEST" } } }); const updateMetadata = { "DICOMUpdates": { "removableAttributes": new TextEncoder().encode(remove_attribute) } }; await updateImageSetMetadata(datastoreID, imageSetID, versionID, updateMetadata);
使用案例 #3: 移除執行個體。
const remove_instance = JSON.stringify({ "SchemaVersion": 1.1, "Study": { "Series": { "1.1.1.1.1.1.12345.123456789012.123.12345678901234.1": { "Instances": { "1.1.1.1.1.1.12345.123456789012.123.12345678901234.1": {} } } } } }); const updateMetadata = { "DICOMUpdates": { "removableAttributes": new TextEncoder().encode(remove_instance) } }; await updateImageSetMetadata(datastoreID, imageSetID, versionID, updateMetadata);
使用案例 #4: 還原為較早的版本。
const updateMetadata = { "revertToVersionId": "1" }; await updateImageSetMetadata(datastoreID, imageSetID, versionID, updateMetadata);
-
有API關詳細資訊,請參閱 UpdateImageSetMetadata(AWS SDK for JavaScript API參考。
注意
還有更多關於 GitHub。尋找完整範例,並瞭解如何在 AWS 代碼示例存儲庫
。 -
- Python
-
- SDK對於 Python(肉毒桿菌 3)
-
class MedicalImagingWrapper: def __init__(self, health_imaging_client): self.health_imaging_client = health_imaging_client def update_image_set_metadata( self, datastore_id, image_set_id, version_id, metadata, force=False ): """ 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\"}}}"}} :param: force: Force the update. :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, force=force, ) 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
下面的代碼實例化對 MedicalImagingWrapper 象。
client = boto3.client("medical-imaging") medical_imaging_wrapper = MedicalImagingWrapper(client)
使用案例 #1: 插入或更新屬性。
attributes = """{ "SchemaVersion": 1.1, "Study": { "DICOM": { "StudyDescription": "CT CHEST" } } }""" metadata = {"DICOMUpdates": {"updatableAttributes": attributes}} self.update_image_set_metadata( data_store_id, image_set_id, version_id, metadata, force )
使用案例 #2: 移除屬性。
# Attribute key and value must match the existing attribute. attributes = """{ "SchemaVersion": 1.1, "Study": { "DICOM": { "StudyDescription": "CT CHEST" } } }""" metadata = {"DICOMUpdates": {"removableAttributes": attributes}} self.update_image_set_metadata( data_store_id, image_set_id, version_id, metadata, force )
使用案例 #3: 移除執行個體。
attributes = """{ "SchemaVersion": 1.1, "Study": { "Series": { "1.1.1.1.1.1.12345.123456789012.123.12345678901234.1": { "Instances": { "1.1.1.1.1.1.12345.123456789012.123.12345678901234.1": {} } } } } }""" metadata = {"DICOMUpdates": {"removableAttributes": attributes}} self.update_image_set_metadata( data_store_id, image_set_id, version_id, metadata, force )
使用案例 #4: 還原為較早的版本。
metadata = {"revertToVersionId": "1"} self.update_image_set_metadata( data_store_id, image_set_id, version_id, metadata, force )
-
有API關詳細資訊,請參閱 UpdateImageSetMetadata(AWS SDK對於 Python(肉毒桿 3)API參考。
注意
還有更多關於 GitHub。尋找完整範例,並瞭解如何在 AWS 代碼示例存儲庫
。 -
有關的完整列表 AWS SDK開發人員指南和代碼示例,請參閱搭 HealthImaging 配 AWS SDK 使用。本主題也包含有關入門的資訊以及舊SDK版的詳細資訊。