翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
画像セットのピクセルデータの取得
画像フレームは、2D 医療画像を構成する画像セット内にあるピクセルデータです。GetImageFrame
アクションを使用して、HealthImaging の特定のイメージセットの HTJ2K-encodedされたイメージフレームを取得します。 画像セット次のメニューは、 AWS CLI および AWS SDKs。詳細については、「AWS HealthImaging API リファレンス」の「GetImageFrame
」を参照してください。
GetImageFrame
アクションを使用するときは、次の点に注意してください。
-
インポート中、HealthImaging は一部の転送構文のエンコードを保持しますが、デフォルトでは他の転送構文を HTJ2K ロスレスに変換します。したがって、イメージフレームは、イメージビューワーで表示する前にデコードする必要があります。詳細については、「サポートされる転送構文」および「HTJ2K デコーディングライブラリ」を参照してください。
-
HealthImaging に保存されているインスタンスで、転送構文の MPEG ファミリー (MPEG2, MPEG-4 AVC/H.264、HEVC/H.265 を含む) でエンコードされた 1 つ以上のイメージフレームがある場合、 GetImageFrame
アクションは保存された転送構文でビデオオブジェクトを返します。
-
GetImageFrame
アクションは、デフォルトでインスタンスのストアド転送構文でイメージフレームを返します。詳細については、「サポートされる転送構文」を参照してください。
-
DICOMウェブサービスの GetDICOMInstanceFrames
HealthImaging 表現である を使用して、DICOMウェブ互換ビューワーとアプリケーションの DICOMweb インスタンスフレーム (multipart
リクエスト) を取得することもできます。詳細については、「HealthImaging からの DICOM インスタンスフレームの取得」を参照してください。
画像セットのピクセルデータを取得するには
AWS HealthImaging のアクセス設定に基づいてメニューを選択します。
AWS Management Consoleには画像ビューアが組み込まれていないため、画像フレームをプログラムでデコードしてアクセスする必要があります。
画像フレームのデコードと表示の詳細については、HTJ2K デコーディングライブラリを参照してください。
- C++
-
- SDK for C++
-
//! Routine which downloads an AWS HealthImaging image frame.
/*!
\param dataStoreID: The HealthImaging data store ID.
\param imageSetID: The image set ID.
\param frameID: The image frame ID.
\param jphFile: File to store the downloaded frame.
\param clientConfig: Aws client configuration.
\return bool: Function succeeded.
*/
bool AwsDoc::Medical_Imaging::getImageFrame(const Aws::String &dataStoreID,
const Aws::String &imageSetID,
const Aws::String &frameID,
const Aws::String &jphFile,
const Aws::Client::ClientConfiguration &clientConfig) {
Aws::MedicalImaging::MedicalImagingClient client(clientConfig);
Aws::MedicalImaging::Model::GetImageFrameRequest request;
request.SetDatastoreId(dataStoreID);
request.SetImageSetId(imageSetID);
Aws::MedicalImaging::Model::ImageFrameInformation imageFrameInformation;
imageFrameInformation.SetImageFrameId(frameID);
request.SetImageFrameInformation(imageFrameInformation);
Aws::MedicalImaging::Model::GetImageFrameOutcome outcome = client.GetImageFrame(
request);
if (outcome.IsSuccess()) {
std::cout << "Successfully retrieved image frame." << std::endl;
auto &buffer = outcome.GetResult().GetImageFrameBlob();
std::ofstream outfile(jphFile, std::ios::binary);
outfile << buffer.rdbuf();
}
else {
std::cout << "Error retrieving image frame." << outcome.GetError().GetMessage()
<< std::endl;
}
return outcome.IsSuccess();
}
GitHub には、その他のリソースもあります。AWS コード例リポジトリ で全く同じ例を見つけて、設定と実行の方法を確認してください。
- CLI
-
- AWS CLI
-
画像セットのピクセルデータを取得するには
次の get-image-frame
コード例では、画像フレームを取得しています。
aws medical-imaging get-image-frame \
--datastore-id "12345678901234567890123456789012"
\
--image-set-id "98765412345612345678907890789012"
\
--image-frame-information imageFrameId=3abf5d5d7ae72f80a0ec81b2c0de3ef4
\
imageframe.jph
注:このコード例には出力は含まれていません。GetImageFrame という操作は、ピクセルデータのストリームを imageframe.jph ファイルに返すからです。画像フレームのデコードと表示については、「HTJ2K デコードライブラリ」を参照してください。
詳細については、「AWS HealthImaging Developer Guide」の「Getting image set pixel data」を参照してください。
- Java
-
- SDK for Java 2.x
-
public static void getMedicalImageSetFrame(MedicalImagingClient medicalImagingClient,
String destinationPath,
String datastoreId,
String imagesetId,
String imageFrameId) {
try {
GetImageFrameRequest getImageSetMetadataRequest = GetImageFrameRequest.builder()
.datastoreId(datastoreId)
.imageSetId(imagesetId)
.imageFrameInformation(ImageFrameInformation.builder()
.imageFrameId(imageFrameId)
.build())
.build();
medicalImagingClient.getImageFrame(getImageSetMetadataRequest,
FileSystems.getDefault().getPath(destinationPath));
System.out.println("Image frame downloaded to " + destinationPath);
} catch (MedicalImagingException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
GitHub には、その他のリソースもあります。AWS コード例リポジトリ で全く同じ例を見つけて、設定と実行の方法を確認してください。
- JavaScript
-
- SDK for JavaScript (v3)
-
import { GetImageFrameCommand } from "@aws-sdk/client-medical-imaging";
import { medicalImagingClient } from "../libs/medicalImagingClient.js";
/**
* @param {string} imageFrameFileName - The name of the file for the HTJ2K-encoded image frame.
* @param {string} datastoreID - The data store's ID.
* @param {string} imageSetID - The image set's ID.
* @param {string} imageFrameID - The image frame's ID.
*/
export const getImageFrame = async (
imageFrameFileName = "image.jph",
datastoreID = "DATASTORE_ID",
imageSetID = "IMAGE_SET_ID",
imageFrameID = "IMAGE_FRAME_ID",
) => {
const response = await medicalImagingClient.send(
new GetImageFrameCommand({
datastoreId: datastoreID,
imageSetId: imageSetID,
imageFrameInformation: { imageFrameId: imageFrameID },
}),
);
const buffer = await response.imageFrameBlob.transformToByteArray();
writeFileSync(imageFrameFileName, buffer);
console.log(response);
// {
// '$metadata': {
// httpStatusCode: 200,
// requestId: 'e4ab42a5-25a3-4377-873f-374ecf4380e1',
// extendedRequestId: undefined,
// cfId: undefined,
// attempts: 1,
// totalRetryDelay: 0
// },
// contentType: 'application/octet-stream',
// imageFrameBlob: <ref *1> IncomingMessage {}
// }
return response;
};
GitHub には、その他のリソースもあります。AWS コード例リポジトリ で全く同じ例を見つけて、設定と実行の方法を確認してください。
- Python
-
- SDK for Python (Boto3)
-
class MedicalImagingWrapper:
def __init__(self, health_imaging_client):
self.health_imaging_client = health_imaging_client
def get_pixel_data(
self, file_path_to_write, datastore_id, image_set_id, image_frame_id
):
"""
Get an image frame's pixel data.
:param file_path_to_write: The path to write the image frame's HTJ2K encoded pixel data.
:param datastore_id: The ID of the data store.
:param image_set_id: The ID of the image set.
:param image_frame_id: The ID of the image frame.
"""
try:
image_frame = self.health_imaging_client.get_image_frame(
datastoreId=datastore_id,
imageSetId=image_set_id,
imageFrameInformation={"imageFrameId": image_frame_id},
)
with open(file_path_to_write, "wb") as f:
for chunk in image_frame["imageFrameBlob"].iter_chunks():
if chunk:
f.write(chunk)
except ClientError as err:
logger.error(
"Couldn't get image frame. Here's why: %s: %s",
err.response["Error"]["Code"],
err.response["Error"]["Message"],
)
raise
次のコードは MedicalImagingWrapper オブジェクトをインスタンス化します。
client = boto3.client("medical-imaging")
medical_imaging_wrapper = MedicalImagingWrapper(client)
GitHub には、その他のリソースもあります。AWS コード例リポジトリ で全く同じ例を見つけて、設定と実行の方法を確認してください。
必要なものが見つからなかった場合。このページの右側サイドバーにあるフィードバックを提供するリンクを使用して、コード例をリクエストします。