更新影像集中繼資料 - AWS HealthImaging

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

更新影像集中繼資料

使用此UpdateImageSetMetadata動作更新 AWS 中的映像集中繼資料 HealthImaging。您可以使用此非同步程序來新增、更新和移除影像集中繼資料屬性,這些屬性是在匯入期間建立的 DICOM 標準化元素的表現形式。您也可以使用此UpdateImageSetMetadata動作移除系列和 SOP 執行個體,以使映像集與外部系統保持同步,並將影像集中繼資料去除識別化。如需詳細資訊,請UpdateImageSetMetadata參閱 AWS HealthImaging API 參考中的。

注意

真實世界的 DICOM 匯入需要更新、新增和移除影像集中繼資料中的屬性。更新影像集中繼資料時,請記住以下幾點:

  • 更新影像集中繼資料會在影像集歷程記錄中建立新版本。如需詳細資訊,請參閱 列出圖像集版本

  • 更新影像集中繼資料是一項非同步程序。因此 imageSetStateimageSetWorkflowStatus回應元素可用來提供鎖定影像集的個別狀態和狀態。您無法對鎖定的影像集執行其他寫入作業。

  • DICOM 元素條件約束會套用至中繼資料更新。如需詳細資訊,請參閱 DICOM 中繼資料限制

  • 如果影像集中繼資料更新動作不成功,請呼叫並檢閱message回應元素。

下圖表示正在更新中的圖像集元數據 HealthImaging。

顯示更新影像集中繼資料的圖表 HealthImaging。
更新影像集詮釋資料

根據您對 AWS 的存取偏好選擇索引標籤 HealthImaging。

CLI
AWS CLI

在影像集中繼資料中插入或更新屬性的步驟

下列update-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

metadata-updates.json 的內容

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

注意:updatableAttributes是一個以 Base64 編碼的 JSON 字符串。以下是未編碼的 JSON 字符串。

{」SchemaVersion「: 1.1," 病人」: {"迪克姆」: {」PatientName「:" MX^MX "}}

輸出:

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

從影像集中繼資料移除屬性的步驟

下列update-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

metadata-updates.json 的內容

{ "DICOMUpdates": { "removableAttributes": "e1NjaGVtYVZlcnNpb246MS4xLFN0dWR5OntESUNPTTp7U3R1ZHlEZXNjcmlwdGlvbjpDSEVTVH19fQo=" } }

注意:removableAttributes是一個以 Base64 編碼的 JSON 字符串。以下是未編碼的 JSON 字符串。鍵和值必須與要刪除的屬性匹配。

{」SchemaVersion「:1.1,「研究」:{「迪克姆」:{」StudyDescription「:「胸部」}}

輸出:

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

若要從影像集中繼資料移除執行個體

下列update-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

metadata-updates.json 的內容

{ "DICOMUpdates": { "removableAttributes": "eezEuMS4xLjEuMS4xLjEyMzQ1LjEyMzQ1Njc4OTAxMi4xMjMuMTIzNDU2Nzg5MDEyMzQuMTp7SW5zdGFuY2VzOnsxLjEuMS4xLjEuMS4xMjM0NS4xMjM0NTY3ODkwMTIuMTIzLjEyMzQ1Njc4OTAxMjM0LjE6e319fX19fQo=" } }

注意:removableAttributes是一個以 Base64 編碼的 JSON 字符串。以下是未編碼的 JSON 字符串。

{"1.1.1.1.1.1.12345.1234567890123.12345678901234.1": {" 執行個體」: {"執行個體」: {"1.1.1.1.1.1.1.12345.123456789034.1": {}}}

輸出:

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

如需詳細資訊,請參閱AWS HealthImaging 開發人員指南中的更新影像集中繼資料。

Java
適用於 Java 2.x 的 SDK
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(); UpdateImageSetMetadataResponse response = medicalImagingClient.updateImageSetMetadata(updateImageSetMetadataRequest); System.out.println("The image set metadata was updated" + response); } catch (MedicalImagingException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } }

使用案例 #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);

使用案例 #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);

使用案例 #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);
注意

還有更多關於 GitHub。尋找完整範例,並了解如何在AWS 設定和執行程式碼範例儲存庫

JavaScript
適用於 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; };

使用案例 #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);

使用案例 #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);
注意

還有更多關於 GitHub。尋找完整範例,並了解如何在AWS 設定和執行程式碼範例儲存庫

Python
適用於 Python (Boto3) 的 SDK
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 ): """ 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

下面的代碼實例化對 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 )

使用案例 #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 )

使用案例 #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 )
  • 如需 API 的詳細資訊,請參閱AWS 開發套件UpdateImageSetMetadata中的 Python (博托 3) API 參考。

注意

還有更多關於 GitHub。尋找完整範例,並了解如何在AWS 設定和執行程式碼範例儲存庫