Creating a data store - AWS HealthImaging

Creating a data store

Use the CreateDatastore action to create an AWS HealthImaging data store for importing DICOM P10 files. The following menus provide a procedure for the AWS Management Console and code examples for the AWS CLI and AWS SDKs. For more information, see CreateDatastore in the AWS HealthImaging API Reference. When you create a data store, you can select the default transfer syntax that AWS HealthImaging used to transcode and store lossless image frames. This configuration cannot be changed after the data store is created.

High Throughput JPEG 2000 (HTJ2K)

HTJ2K (High Throughput JPEG 2000) is the default storage format for HealthImaging datastores. It is an extension of the JPEG 2000 standard that offers significantly improved encoding and decoding performance. When you create a datastore without specifying a —lossless-storage-format, HealthImaging automatically uses HTJ2K.

aws medical-imaging create-datastore \ --datastore-name "my-datastore"
Native JPEG 2000 Lossless

Native JPEG 2000 Lossless encoding allows creation of datastores that persist and retrieve lossless image frames in JPEG 2000 format without transcoding, enabling lower latency retrieval for applications that require JPEG 2000 Lossless (DICOM Transfer Syntax UID 1.2.840.10008.1.2.4.90) see Supported transfer syntaxes for more details.

Creating a JPEG 2000 Lossless Datastore

To create a datastore that supports JPEG 2000 Lossless:

aws medical-imaging create-datastore \ --datastore-name "my-datastore" \ --lossless-storage-format JPEG_2000_LOSSLESS
Important
  • Do not name data stores with protected health information (PHI), personally identifiable information (PII), or other confidential or sensitive information.

  • The AWS Console supports creation of data stores with default settings. Use the AWS CLI or AWS SDK to create a data store with an optional —lossless-storage-format specified.

To create a data store

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

  1. Open the HealthImaging console Create data store page.

  2. Under Details, for Data store name, enter a name for your data store.

  3. Under Data encryption, choose an AWS KMS key for encrypting your resources. For more information, see Data protection in AWS HealthImaging.

  4. Under Tags - optional, you can add tags to your data store when you create it. For more information, see Tagging a resource.

  5. Choose Create data store.

Bash
AWS CLI with Bash script
############################################################################### # 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 }
Note

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

CLI
AWS CLI

To create a data store

The following create-datastore code example creates a data store with the name my-datastore. When you create a datastore without specifying a --lossless-storage-format, AWS HealthImaging defaults to HTJ2K (High Throughput JPEG 2000).

aws medical-imaging create-datastore \ --datastore-name "my-datastore"

Output:

{ "datastoreId": "12345678901234567890123456789012", "datastoreStatus": "CREATING" }

Java
SDK for Java 2.x
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 ""; }
  • For API details, see CreateDatastore 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)
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; };
  • For API details, see CreateDatastore 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)
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"]

The following code instantiates the MedicalImagingWrapper object.

client = boto3.client("medical-imaging") medical_imaging_wrapper = MedicalImagingWrapper(client)
  • For API details, see CreateDatastore 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.

Example availability

Can't find what you need? Request a code example using the Provide feedback link on the right sidebar of this page.