本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
建立資料存放區
使用 CreateDatastore動作建立 AWS HealthImaging 資料存放區以匯入 DICOM P10 檔案。下列功能表提供 AWS CLIAWSSDKs 的 AWS 管理主控台和 程式碼範例程序。如需詳細資訊,請參閱《AWS HealthImaging API 參考CreateDatastore》中的 。建立資料存放區時,您可以選取 AWS HealthImaging 用來轉碼和儲存無失真影像影格的預設傳輸語法。建立資料存放區之後,就無法變更此組態。
高輸送量 JPEG 2000 (HTJ2K)
HTJ2K (高輸送量 JPEG 2000) 是 HealthImaging 資料存放區的預設儲存格式。它是 JPEG 2000 標準的延伸,可大幅改善編碼和解碼效能。當您在不指定 的情況下建立資料存放區時—lossless-storage-format,HealthImaging 會自動使用 HTJ2K。如需使用 HTJ2K 建立資料存放區,請參閱以下 AWS CLI 和 SDKs 一節。
JPEG 2000 無失真
JPEG 2000 無失真編碼允許建立以 JPEG 2000 格式保留和擷取無失真影像影格而無需轉碼的資料存放區,為需要 JPEG 2000 無失真 (DICOM Transfer Syntax UID 1.2.840.10008.1.2.4.90) 的應用程式啟用更低的延遲擷取,如需更多詳細資訊支援的傳輸語法,請參閱 。如需使用 JPEG 2000 無失真格式建立資料存放區,請參閱以下 AWS CLI 和 SDKs 一節。
建立資料存放區
根據您對 AWS HealthImaging 的存取偏好設定,選擇選單。
- Bash
-
- AWS CLI使用 Bash 指令碼
-
###############################################################################
# function errecho
#
# This function outputs everything sent to it to STDERR (standard error output).
###############################################################################
function errecho() {
printf "%s\n" "$*" 1>&2
}
###############################################################################
# function imaging_create_datastore
#
# This function creates an AWS HealthImaging data store for importing DICOM P10 files.
#
# Parameters:
# -n data_store_name - The name of the data store.
#
# Returns:
# The datastore ID.
# And:
# 0 - If successful.
# 1 - If it fails.
###############################################################################
function imaging_create_datastore() {
local datastore_name response
local option OPTARG # Required to use getopts command in a function.
# bashsupport disable=BP5008
function usage() {
echo "function imaging_create_datastore"
echo "Creates an AWS HealthImaging data store for importing DICOM P10 files."
echo " -n data_store_name - The name of the data store."
echo ""
}
# Retrieve the calling parameters.
while getopts "n:h" option; do
case "${option}" in
n) datastore_name="${OPTARG}" ;;
h)
usage
return 0
;;
\?)
echo "Invalid parameter"
usage
return 1
;;
esac
done
export OPTIND=1
if [[ -z "$datastore_name" ]]; then
errecho "ERROR: You must provide a data store name with the -n parameter."
usage
return 1
fi
response=$(aws medical-imaging create-datastore \
--datastore-name "$datastore_name" \
--output text \
--query 'datastoreId')
local error_code=${?}
if [[ $error_code -ne 0 ]]; then
aws_cli_error_log $error_code
errecho "ERROR: AWS reports medical-imaging create-datastore operation failed.$response"
return 1
fi
echo "$response"
return 0
}
- CLI
-
- AWS CLI
-
範例 1:建立資料存放區
下列 create-datastore 程式碼範例會建立名為 my-datastore 的資料存放區。當您在不指定 的情況下建立資料存放區時--lossless-storage-format,AWSHealthImaging 預設為 HTJ2K (高輸送量 JPEG 2000)。
aws medical-imaging create-datastore \
--datastore-name "my-datastore"
輸出:
{
"datastoreId": "12345678901234567890123456789012",
"datastoreStatus": "CREATING"
}
範例 2:使用 JPEG 2000 無失真儲存格式建立資料存放區
使用 JPEG 2000 無失真儲存格式設定的資料存放區會以 JPEG 2000 格式轉碼並保留無失真影像影格。然後,可以在 JPEG 2000 無失真中擷取影像影格,而無需轉碼。下列create-datastore程式碼範例會建立名為 的 JPEG 2000 無失真儲存格式所設定的資料存放區my-datastore。
aws medical-imaging create-datastore \
--datastore-name "my-datastore" \
--lossless-storage-format JPEG_2000_LOSSLESS
輸出:
{
"datastoreId": "12345678901234567890123456789012",
"datastoreStatus": "CREATING"
}
如需詳細資訊,請參閱《AWS HealthImaging 開發人員指南》中的建立資料存放區。
- Java
-
- 適用於 Java 2.x 的 SDK
-
public static String createMedicalImageDatastore(MedicalImagingClient medicalImagingClient,
String datastoreName) {
try {
CreateDatastoreRequest datastoreRequest = CreateDatastoreRequest.builder()
.datastoreName(datastoreName)
.build();
CreateDatastoreResponse response = medicalImagingClient.createDatastore(datastoreRequest);
return response.datastoreId();
} catch (MedicalImagingException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
return "";
}
- JavaScript
-
- 適用於 JavaScript (v3) 的 SDK
-
import { CreateDatastoreCommand } from "@aws-sdk/client-medical-imaging";
import { medicalImagingClient } from "../libs/medicalImagingClient.js";
/**
* @param {string} datastoreName - The name of the data store to create.
*/
export const createDatastore = async (datastoreName = "DATASTORE_NAME") => {
const response = await medicalImagingClient.send(
new CreateDatastoreCommand({ datastoreName: datastoreName }),
);
console.log(response);
// {
// '$metadata': {
// httpStatusCode: 200,
// requestId: 'a71cd65f-2382-49bf-b682-f9209d8d399b',
// extendedRequestId: undefined,
// cfId: undefined,
// attempts: 1,
// totalRetryDelay: 0
// },
// datastoreId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
// datastoreStatus: 'CREATING'
// }
return response;
};
- Python
-
- 適用於 Python 的 SDK (Boto3)
-
class MedicalImagingWrapper:
def __init__(self, health_imaging_client):
self.health_imaging_client = health_imaging_client
def create_datastore(self, name):
"""
Create a data store.
:param name: The name of the data store to create.
:return: The data store ID.
"""
try:
data_store = self.health_imaging_client.create_datastore(datastoreName=name)
except ClientError as err:
logger.error(
"Couldn't create data store %s. Here's why: %s: %s",
name,
err.response["Error"]["Code"],
err.response["Error"]["Message"],
)
raise
else:
return data_store["datastoreId"]
下列程式碼會執行個體化 MedicalImagingWrapper 物件。
client = boto3.client("medical-imaging")
medical_imaging_wrapper = MedicalImagingWrapper(client)
找不到所需的內容嗎? 使用此頁面右側的提供意見回饋連結來請求程式碼範例。