Cloud Storage를 사용하여 DICOM 데이터 가져오기 및 내보내기

이 페이지에서는 DICOM 인스턴스를 Cloud Storage로 내보내고 DICOM 객체를 Cloud Storage에서 가져오는 방법을 설명합니다. DICOM 인스턴스는 일반적으로 이미지이지만 구조화된 보고서와 같이 다른 유형의 영구적인 데이터일 수도 있습니다. Cloud Storage의 DICOM 객체는 Cloud Storage에 있는 DICOM 인스턴스입니다. 자세한 내용은 Cloud Storage를 참조하세요.

Cloud Storage 권한 설정

DICOM 데이터를 Cloud Storage로 내보내고 가져오기 전에 Cloud Healthcare 서비스 에이전트 서비스 계정에 추가 권한을 부여해야 합니다. 자세한 내용은 DICOM 저장소 Cloud Storage 권한을 참조하세요.

DICOM 객체 가져오기

여러 DICOM 인스턴스 파일을 DICOM 저장소로 가져오려면 다음 방법 중 하나를 사용하면 됩니다.

다음 샘플은 Cloud Storage 버킷에서 DICOM 객체를 가져오는 방법을 보여줍니다.

콘솔

Cloud Storage 버킷에서 DICOM 객체를 가져오려면 다음 단계를 완료하세요.

  1. Google Cloud 콘솔에서 데이터 세트 페이지로 이동합니다.
    데이터 세트로 이동
  2. DICOM 객체를 가져올 DICOM 저장소가 포함된 데이터 세트를 클릭합니다.
  3. 데이터 저장소 목록에서 DICOM 저장소의 작업 목록에서 가져오기를 선택합니다.

    DICOM 저장소로 가져오기 페이지가 나타납니다.
  4. 프로젝트 목록에서 Cloud Storage 프로젝트를 선택합니다.
  5. 위치 목록에서 Cloud Storage 버킷을 선택합니다.
  6. 파일을 가져올 특정 위치를 설정하려면 다음을 수행합니다.
    1. 고급 옵션을 펼칩니다.
    2. Cloud Storage 경로 재정의를 선택합니다.
    3. 파일을 가져올 특정 소스를 설정하려면 위치 텍스트 상자에 다음 변수를 사용하여 경로를 정의합니다.
      • * - 구분 기호가 아닌 일치하는 문자를 찾습니다.
      • ** - 일치하는 문자를 찾습니다(구분 기호 포함). 파일 이름 확장자와 함께 사용하여 동일한 유형의 파일을 모두 찾을 수 있습니다.
      • ? - 일치하는 1개 문자를 찾습니다.
  7. 가져오기를 클릭하여 정의된 소스에서 DICOM 객체를 가져옵니다.
  8. 작업 상태를 추적하려면 작업 탭을 클릭합니다. 작업이 완료되면 다음과 같은 표시가 나타납니다.
    • 장기 실행 작업 상태 섹션의 확인 제목 아래에 녹색 체크표시가 있습니다.
    • 개요 섹션에 작업 ID와 같은 행에 녹색 체크표시와 확인 표시기가 있습니다.
    오류가 발생하면 작업을 클릭한 다음 Cloud Logging에서 세부정보 보기를 클릭합니다.

gcloud

Cloud Storage 버킷에서 DICOM 객체를 가져오려면 gcloud healthcare dicom-stores import gcs 명령어를 사용합니다. 상위 데이터 세트의 이름, DICOM 저장소의 이름, Cloud Storage 버킷의 객체 위치를 지정합니다.

  • 버킷 내의 파일 위치는 임의적이며 다음 샘플에 지정된 형식을 정확하게 준수할 필요가 없습니다.
  • Cloud Storage에서 DICOM의 위치를 지정할 때는 와일드 카드를 사용해서 하나 이상의 디렉터리에 있는 여러 파일을 가져올 수 있습니다. 다음 와일드 카드가 지원됩니다.
    • 구분 기호가 아닌 0자 이상의 일치하는 문자를 찾으려면 *를 사용합니다. 예를 들어 gs://BUCKET/DIRECTORY/Example*.dcm을 사용하면 DIRECTORY에 있는 Example.dcm 및 Example22.dcm이 검색됩니다.
    • 0자 이상의 일치하는 문자(구분 기호 포함)를 찾으려면 **를 사용합니다. 경로의 끝에 사용해야 하며 경로에 다른 와일드 카드가 없어야 합니다. 또한 지정된 디렉터리 및 하위 디렉터리에서 파일 이름 확장자가 있는 모든 파일을 가져오는 파일 이름 확장자 (예 : .dcm)와 함께 사용할 수 있습니다. 예를 들어 gs://BUCKET/DIRECTORY/**.dcmDIRECTORY 및 하위 디렉터리에 파일명 확장자가 .dcm인 파일을 모두 가져옵니다.
    • 일치하는 1개 문자를 찾으려면 ?를 사용합니다. 예를 들어 gs://BUCKET/DIRECTORY/Example?.dcm을 사용하면 Example1.dcm이 검색되지만 Example.dcm 또는 Example01.dcm은 검색되지 않습니다.

다음 샘플은 Cloud Storage 버킷에서 DICOM 객체를 가져오는 방법을 보여줍니다.

gcloud healthcare dicom-stores import gcs DICOM_STORE_ID \
  --dataset=DATASET_ID \
  --location=LOCATION \
  --gcs-uri=gs://BUCKET/DIRECTORY/DICOM_INSTANCE.dcm

명령줄에 작업 ID가 표시됩니다.

name: projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID

작업 상태를 보려면 gcloud healthcare operations describe 명령어를 실행하고 응답에서 OPERATION_ID를 제공합니다.

gcloud healthcare operations describe OPERATION_ID \
  --location=LOCATION \
  --dataset=DATASET_ID

명령어가 완료되면 응답에 done: true가 포함됩니다.

done: true
metadata:
'@type': type.googleapis.com/google.cloud.healthcare.v1.OperationMetadata
apiMethodName: google.cloud.healthcare.v1.dicom.DicomService.ImportDicomData
counter:
  success: SUCCESSFUL_INSTANCES
  failure: FAILED_INSTANCES
createTime: "CREATE_TIME"
endTime: "END_TIME"
name: projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID
response:
'@type': "..."

API

Cloud Storage 버킷에서 DICOM 객체를 가져오려면 projects.locations.datasets.dicomStores.import 메서드를 사용합니다.

  • 버킷 내의 파일 위치는 달라질 수 있으며 다음 샘플에 지정된 형식과 일치하지 않아도 됩니다.
  • Cloud Storage에서 DICOM의 위치를 지정할 때는 와일드 카드를 사용해서 하나 이상의 디렉터리에 있는 여러 파일을 가져옵니다. 다음 와일드 카드가 지원됩니다.
    • 구분 기호가 아닌 0자 이상의 일치하는 문자를 찾으려면 *를 사용합니다. 예를 들어 gs://BUCKET/DIRECTORY/Example*.dcm을 사용하면 DIRECTORY에 있는 Example.dcm 및 Example22.dcm이 검색됩니다.
    • 0자 이상의 일치하는 문자(구분 기호 포함)를 찾으려면 **를 사용합니다. 경로의 끝에 사용해야 하며 경로에 다른 와일드 카드가 없어야 합니다. 또한 지정된 디렉터리 및 하위 디렉터리에서 파일 이름 확장자가 있는 모든 파일을 가져오는 파일 이름 확장자 (예 : .dcm)와 함께 사용할 수 있습니다. 예를 들어 gs://BUCKET/DIRECTORY/**.dcmDIRECTORY 및 하위 디렉터리에 파일명 확장자가 .dcm인 파일을 모두 가져옵니다.
    • 일치하는 1개 문자를 찾으려면 ?를 사용합니다. 예를 들어 gs://BUCKET/DIRECTORY/Example?.dcm을 사용하면 Example1.dcm이 검색되지만 Example.dcm 또는 Example01.dcm은 검색되지 않습니다.

REST

  1. DICOM 객체를 가져옵니다.

    요청 데이터를 사용하기 전에 다음을 바꿉니다.

    • PROJECT_ID: Google Cloud 프로젝트의 ID
    • LOCATION: 데이터 세트 위치
    • DATASET_ID: DICOM 저장소의 상위 데이터 세트
    • DICOM_STORE_ID: DICOM 저장소 ID
    • BUCKET/PATH/TO/FILE: Cloud Storage의 DICOM 객체 경로

    JSON 요청 본문:

    {
      "gcsSource": {
        "uri": "gs://BUCKET/PATH/TO/FILE.dcm"
      }
    }
    

    요청을 보내려면 다음 옵션 중 하나를 선택합니다.

    curl

    요청 본문을 request.json 파일에 저장합니다. 터미널에서 다음 명령어를 실행하여 현재 디렉터리에 이 파일을 만들거나 덮어씁니다.

    cat > request.json << 'EOF'
    {
      "gcsSource": {
        "uri": "gs://BUCKET/PATH/TO/FILE.dcm"
      }
    }
    EOF

    그런 후 다음 명령어를 실행하여 REST 요청을 전송합니다.

    curl -X POST \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -H "Content-Type: application/json" \
    -d @request.json \
    "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID:import"

    PowerShell

    요청 본문을 request.json 파일에 저장합니다. 터미널에서 다음 명령어를 실행하여 현재 디렉터리에 이 파일을 만들거나 덮어씁니다.

    @'
    {
      "gcsSource": {
        "uri": "gs://BUCKET/PATH/TO/FILE.dcm"
      }
    }
    '@  | Out-File -FilePath request.json -Encoding utf8

    그런 후 다음 명령어를 실행하여 REST 요청을 전송합니다.

    $cred = gcloud auth print-access-token
    $headers = @{ "Authorization" = "Bearer $cred" }

    Invoke-WebRequest `
    -Method POST `
    -Headers $headers `
    -ContentType: "application/json" `
    -InFile request.json `
    -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID:import" | Select-Object -Expand Content
    출력은 다음과 같습니다. 응답에는 장기 실행 작업의 식별자가 포함됩니다. 메서드 호출을 완료하는 데 상당한 시간이 걸릴 수 있는 장기 실행 작업은 반환됩니다. OPERATION_ID의 값을 확인합니다. 다음 단계에서 이 값이 필요합니다.

  2. 장기 실행 작업 상태를 가져옵니다.

    요청 데이터를 사용하기 전에 다음을 바꿉니다.

    • PROJECT_ID: Google Cloud 프로젝트의 ID
    • LOCATION: 데이터 세트 위치
    • DATASET_ID: DICOM 저장소의 상위 데이터 세트
    • OPERATION_ID: 장기 실행 작업에서 반환된 ID

    요청을 보내려면 다음 옵션 중 하나를 선택합니다.

    curl

    다음 명령어를 실행합니다.

    curl -X GET \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID"

    PowerShell

    다음 명령어를 실행합니다.

    $cred = gcloud auth print-access-token
    $headers = @{ "Authorization" = "Bearer $cred" }

    Invoke-WebRequest `
    -Method GET `
    -Headers $headers `
    -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID" | Select-Object -Expand Content
    장기 실행 작업이 아직 실행 중이면 서버는 가져오기 대기 중인 DICOM 인스턴스 수가 포함된 응답을 반환합니다. LRO가 완료되면 서버가 JSON 형식의 작업 상태가 포함된 응답을 반환합니다.

Go

import (
	"context"
	"fmt"
	"io"

	healthcare "google.golang.org/api/healthcare/v1"
)

// importDICOMInstance imports DICOM objects from GCS.
func importDICOMInstance(w io.Writer, projectID, location, datasetID, dicomStoreID, contentURI string) error {
	ctx := context.Background()

	healthcareService, err := healthcare.NewService(ctx)
	if err != nil {
		return fmt.Errorf("healthcare.NewService: %w", err)
	}

	storesService := healthcareService.Projects.Locations.Datasets.DicomStores

	req := &healthcare.ImportDicomDataRequest{
		GcsSource: &healthcare.GoogleCloudHealthcareV1DicomGcsSource{
			Uri: contentURI,
		},
	}
	name := fmt.Sprintf("projects/%s/locations/%s/datasets/%s/dicomStores/%s", projectID, location, datasetID, dicomStoreID)

	lro, err := storesService.Import(name, req).Do()
	if err != nil {
		return fmt.Errorf("Import: %w", err)
	}

	fmt.Fprintf(w, "Import to DICOM store started. Operation: %q\n", lro.Name)
	return nil
}

Java

import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.healthcare.v1.CloudHealthcare;
import com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores;
import com.google.api.services.healthcare.v1.CloudHealthcareScopes;
import com.google.api.services.healthcare.v1.model.GoogleCloudHealthcareV1DicomGcsSource;
import com.google.api.services.healthcare.v1.model.ImportDicomDataRequest;
import com.google.api.services.healthcare.v1.model.Operation;
import com.google.auth.http.HttpCredentialsAdapter;
import com.google.auth.oauth2.GoogleCredentials;
import java.io.IOException;
import java.util.Collections;

public class DicomStoreImport {
  private static final String DICOM_NAME = "projects/%s/locations/%s/datasets/%s/dicomStores/%s";
  private static final JsonFactory JSON_FACTORY = new GsonFactory();
  private static final NetHttpTransport HTTP_TRANSPORT = new NetHttpTransport();

  public static void dicomStoreImport(String dicomStoreName, String gcsUri) throws IOException {
    // String dicomStoreName =
    //    String.format(
    //        DICOM_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-dicom-id");
    // String gcsUri = "gs://your-bucket-id/path/to/destination/dir"

    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();

    // Configure where the store should be imported from.
    GoogleCloudHealthcareV1DicomGcsSource gcsSource =
        new GoogleCloudHealthcareV1DicomGcsSource().setUri(gcsUri);
    ImportDicomDataRequest importRequest = new ImportDicomDataRequest().setGcsSource(gcsSource);

    // Create request and configure any parameters.
    DicomStores.CloudHealthcareImport request =
        client
            .projects()
            .locations()
            .datasets()
            .dicomStores()
            .healthcareImport(dicomStoreName, importRequest);

    // Execute the request, wait for the operation to complete, and process the results.
    try {
      Operation operation = request.execute();
      while (operation.getDone() == null || !operation.getDone()) {
        // Update the status of the operation with another request.
        Thread.sleep(500); // Pause for 500ms between requests.
        operation =
            client
                .projects()
                .locations()
                .datasets()
                .operations()
                .get(operation.getName())
                .execute();
      }
      System.out.println("DICOM store import complete." + operation.getResponse());
    } catch (Exception ex) {
      System.out.printf("Error during request execution: %s", ex.toString());
      ex.printStackTrace(System.out);
    }
  }

  private static CloudHealthcare createClient() throws IOException {
    // Use Application Default Credentials (ADC) to authenticate the requests
    // For more information see https://cloud.google.com/docs/authentication/production
    GoogleCredentials credential =
        GoogleCredentials.getApplicationDefault()
            .createScoped(Collections.singleton(CloudHealthcareScopes.CLOUD_PLATFORM));

    // Create a HttpRequestInitializer, which will provide a baseline configuration to all requests.
    HttpRequestInitializer requestInitializer =
        request -> {
          new HttpCredentialsAdapter(credential).initialize(request);
          request.setConnectTimeout(60000); // 1 minute connect timeout
          request.setReadTimeout(60000); // 1 minute read timeout
        };

    // Build the client for interacting with the service.
    return new CloudHealthcare.Builder(HTTP_TRANSPORT, JSON_FACTORY, requestInitializer)
        .setApplicationName("your-application-name")
        .build();
  }
}

Node.js

const google = require('@googleapis/healthcare');
const healthcare = google.healthcare({
  version: 'v1',
  auth: new google.auth.GoogleAuth({
    scopes: ['https://www.googleapis.com/auth/cloud-platform'],
  }),
});
const sleep = ms => {
  return new Promise(resolve => setTimeout(resolve, ms));
};

const importDicomInstance = async () => {
  // TODO(developer): uncomment these lines before running the sample
  // const cloudRegion = 'us-central1';
  // const projectId = 'adjective-noun-123';
  // const datasetId = 'my-dataset';
  // const dicomStoreId = 'my-dicom-store';
  // const gcsUri = 'my-bucket/my-directory/*.dcm'
  const name = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/dicomStores/${dicomStoreId}`;
  const request = {
    name,
    resource: {
      // The location of the DICOM instances in Cloud Storage
      gcsSource: {
        uri: `gs://${gcsUri}`,
      },
    },
  };

  const operation =
    await healthcare.projects.locations.datasets.dicomStores.import(request);
  const operationName = operation.data.name;

  const operationRequest = {name: operationName};

  // Wait fifteen seconds for the LRO to finish.
  await sleep(15000);

  // Check the LRO's status
  const operationStatus =
    await healthcare.projects.locations.datasets.operations.get(
      operationRequest
    );

  const {data} = operationStatus;

  if (data.error === undefined) {
    console.log('Successfully imported DICOM instances');
  } else {
    console.log('Encountered errors. Sample error:');
    console.log(
      'Resource on which error occured:',
      data.error.details[0]['sampleErrors'][0]['resource']
    );
    console.log(
      'Error code:',
      data.error.details[0]['sampleErrors'][0]['error']['code']
    );
    console.log(
      'Error message:',
      data.error.details[0]['sampleErrors'][0]['error']['message']
    );
  }
};

importDicomInstance();

Python

def import_dicom_instance(
    project_id, location, dataset_id, dicom_store_id, content_uri
):
    """Imports data into the DICOM store by copying it from the specified
    source.

    See https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/healthcare/api-client/v1/dicom
    before running the sample."""
    # Imports the Google API Discovery Service.
    from googleapiclient import discovery

    api_version = "v1"
    service_name = "healthcare"
    # Returns an authorized API client by discovering the Healthcare API
    # and using GOOGLE_APPLICATION_CREDENTIALS environment variable.
    client = discovery.build(service_name, api_version)

    # TODO(developer): Uncomment these lines and replace with your values.
    # project_id = 'my-project'  # replace with your GCP project ID
    # location = 'us-central1'  # replace with the parent dataset's location
    # dataset_id = 'my-dataset'  # replace with the DICOM store's parent dataset ID
    # dicom_store_id = 'my-dicom-store'  # replace with the DICOM store's ID
    # content_uri = 'my-bucket/*.dcm'  # replace with a Cloud Storage bucket and DCM files
    dicom_store_parent = "projects/{}/locations/{}/datasets/{}".format(
        project_id, location, dataset_id
    )
    dicom_store_name = f"{dicom_store_parent}/dicomStores/{dicom_store_id}"

    body = {"gcsSource": {"uri": f"gs://{content_uri}"}}

    # Escape "import()" method keyword because "import"
    # is a reserved keyword in Python
    request = (
        client.projects()
        .locations()
        .datasets()
        .dicomStores()
        .import_(name=dicom_store_name, body=body)
    )

    response = request.execute()
    print(f"Imported DICOM instance: {content_uri}")

    return response

DICOM 저장소에서 단일 인스턴스 또는 연구를 검색하려면 Cloud Healthcare API에 구현된 거래 검색 RESTful 웹 서비스를 사용하여 DICOM 데이터를 검색할 수 있습니다.

DICOM 객체를 가져올 스토리지 클래스 지정(미리보기)

기본적으로 projects.locations.datasets.dicomStores.import 메서드는 Standard Storage 클래스를 사용하여 DICOM 객체를 DICOM 저장소로 가져옵니다. Cloud Storage에서 DICOM 객체를 가져올 때 스토리지 클래스를 설정할 수 있습니다. 자세한 내용은 DICOM 스토리지 클래스 변경을 참조하세요.

다음 샘플은 Cloud Storage에서 DICOM 객체를 가져올 때 스토리지 클래스를 지정하는 방법을 보여줍니다.

REST

projects.locations.datasets.dicomStores.import 메서드를 사용합니다.

  1. DICOM 객체를 가져옵니다.

    요청 데이터를 사용하기 전에 다음을 바꿉니다.

    • PROJECT_ID: Google Cloud 프로젝트의 ID
    • LOCATION: 데이터 세트 위치
    • DATASET_ID: DICOM 저장소의 상위 데이터 세트
    • DICOM_STORE_ID: DICOM 저장소 ID
    • BUCKET/PATH/TO/FILE: Cloud Storage의 DICOM 객체 경로
    • STORAGE_CLASS: STANDARD, NEARLINE, COLDLINE, ARCHIVE의 DICOM 스토어에 있는 DICOM 객체의 스토리지 클래스

    JSON 요청 본문:

    {
      "gcsSource": {
        "uri": "gs://BUCKET/PATH/TO/FILE.dcm"
      },
      "blob_storage_settings": {
        "blob_storage_class": "STORAGE_CLASS"
      }
    }
    

    요청을 보내려면 다음 옵션 중 하나를 선택합니다.

    curl

    요청 본문을 request.json 파일에 저장합니다. 터미널에서 다음 명령어를 실행하여 현재 디렉터리에 이 파일을 만들거나 덮어씁니다.

    cat > request.json << 'EOF'
    {
      "gcsSource": {
        "uri": "gs://BUCKET/PATH/TO/FILE.dcm"
      },
      "blob_storage_settings": {
        "blob_storage_class": "STORAGE_CLASS"
      }
    }
    EOF

    그런 후 다음 명령어를 실행하여 REST 요청을 전송합니다.

    curl -X POST \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -H "Content-Type: application/json" \
    -d @request.json \
    "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID:import"

    PowerShell

    요청 본문을 request.json 파일에 저장합니다. 터미널에서 다음 명령어를 실행하여 현재 디렉터리에 이 파일을 만들거나 덮어씁니다.

    @'
    {
      "gcsSource": {
        "uri": "gs://BUCKET/PATH/TO/FILE.dcm"
      },
      "blob_storage_settings": {
        "blob_storage_class": "STORAGE_CLASS"
      }
    }
    '@  | Out-File -FilePath request.json -Encoding utf8

    그런 후 다음 명령어를 실행하여 REST 요청을 전송합니다.

    $cred = gcloud auth print-access-token
    $headers = @{ "Authorization" = "Bearer $cred" }

    Invoke-WebRequest `
    -Method POST `
    -Headers $headers `
    -ContentType: "application/json" `
    -InFile request.json `
    -Uri "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID:import" | Select-Object -Expand Content
    출력은 다음과 같습니다. 응답에는 장기 실행 작업의 식별자가 포함됩니다. 메서드 호출을 완료하는 데 상당한 시간이 걸릴 수 있는 장기 실행 작업은 반환됩니다. OPERATION_ID의 값을 확인합니다. 다음 단계에서 이 값이 필요합니다.

  2. 장기 실행 작업 상태를 가져옵니다.

    요청 데이터를 사용하기 전에 다음을 바꿉니다.

    • PROJECT_ID: Google Cloud 프로젝트의 ID
    • LOCATION: 데이터 세트 위치
    • DATASET_ID: DICOM 저장소의 상위 데이터 세트
    • OPERATION_ID: 장기 실행 작업에서 반환된 ID

    요청을 보내려면 다음 옵션 중 하나를 선택합니다.

    curl

    다음 명령어를 실행합니다.

    curl -X GET \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID"

    PowerShell

    다음 명령어를 실행합니다.

    $cred = gcloud auth print-access-token
    $headers = @{ "Authorization" = "Bearer $cred" }

    Invoke-WebRequest `
    -Method GET `
    -Headers $headers `
    -Uri "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID" | Select-Object -Expand Content
    장기 실행 작업이 아직 실행 중이면 서버는 가져오기 대기 중인 DICOM 인스턴스 수가 포함된 응답을 반환합니다. LRO가 완료되면 서버가 JSON 형식의 작업 상태가 포함된 응답을 반환합니다.

DICOM 가져오기 요청 문제 해결

DICOM 가져오기 요청 중에 오류가 발생하면 오류가 Cloud Logging에 기록됩니다. 자세한 내용은 Cloud Logging에서 오류 로그 보기를 참조하세요.

DICOM 인스턴스 내보내기

다음 샘플은 DICOM 인스턴스를 Cloud Storage 버킷으로 내보내는 방법을 보여줍니다. DICOM 저장소에서 DICOM 인스턴스를 내보낼 때는 저장소에 있는 모든 인스턴스를 내보냅니다.

콘솔

DICOM 인스턴스를 Cloud Storage로 내보내려면 다음 단계를 완료합니다.

  1. Google Cloud 콘솔에서 데이터 세트 페이지로 이동합니다.
    데이터 세트로 이동
  2. DICOM 인스턴스를 내보낼 DICOM 저장소가 포함된 데이터 세트를 클릭합니다.
  3. 데이터 저장소 목록에 있는 DICOM 저장소의 작업 목록에서 내보내기를 선택합니다.
  4. 표시되는 DICOM 저장소 내보내기 페이지에서 Google Cloud Storage 버킷을 선택합니다.
  5. 프로젝트 목록에서 Cloud Storage 프로젝트를 선택합니다.
  6. 위치 목록에서 Cloud Storage 버킷을 선택합니다.
  7. DICOM 내보내기 설정에서 DICOM 인스턴스를 내보내기 위해 사용되는 파일 유형을 선택합니다. 사용할 수 있는 유형은 다음과 같습니다.
    • DICOM 파일(.dcm)
    • octet 스트림
    • 이미지(.jpg,.png)
  8. 추가 전송 문법을 정의하려면 전송 문법 목록에서 문법을 선택합니다.
  9. 내보내기를 클릭하여 DICOM 인스턴스를 Cloud Storage의 정의된 위치로 내보냅니다.
  10. 작업 상태를 추적하려면 작업 탭을 클릭합니다. 작업이 완료되면 다음과 같은 표시가 나타납니다.
    • 장기 실행 작업 상태 섹션의 확인 제목 아래에 녹색 체크표시가 있습니다.
    • 개요 섹션에 작업 ID와 같은 행에 녹색 체크표시와 확인 표시기가 있습니다.
    오류가 발생하면 작업을 클릭한 다음 Cloud Logging에서 세부정보 보기를 클릭합니다.

gcloud

DICOM 인스턴스를 Cloud Storage 버킷으로 내보내려면 gcloud healthcare dicom-stores export gcs 명령어를 사용합니다.

  • 상위 데이터 세트의 이름, DICOM 저장소의 이름, 대상 Cloud Storage 버킷을 제공합니다.
  • Cloud Healthcare API가 각 객체에 대해 .dcm 파일을 하나 만들기 때문에 객체 대신 Cloud Storage 버킷 또는 디렉터리에 기록합니다.
  • 명령어가 존재하지 않는 디렉터리를 지정하면 디렉터리가 생성됩니다.

다음 샘플은 gcloud healthcare dicom-stores export gcs 명령어를 보여줍니다.

gcloud healthcare dicom-stores export gcs DICOM_STORE_ID \
  --dataset=DATASET_ID \
  --location=LOCATION \
  --gcs-uri-prefix=gs://BUCKET/DIRECTORY

명령줄에 작업 ID가 표시됩니다.

name: projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID

작업 상태를 보려면 gcloud healthcare operations describe 명령어를 실행하고 응답에서 OPERATION_ID를 제공합니다.

gcloud healthcare operations describe OPERATION_ID \
  --location=LOCATION \
  --dataset=DATASET_ID

명령어가 완료되면 응답에 done: true가 포함됩니다.

done: true
metadata:
'@type': type.googleapis.com/google.cloud.healthcare.v1.OperationMetadata
apiMethodName: google.cloud.healthcare.v1.dicom.DicomService.ExportDicomData
counter:
  success: SUCCESSFUL_INSTANCES
  failure: FAILED_INSTANCES
createTime: "CREATE_TIME"
endTime: "END_TIME"
name: projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID
response:
'@type': "..."

API

DICOM 인스턴스를 Cloud Storage 버킷으로 내보내려면 projects.locations.datasets.dicomStores.export 메서드를 사용합니다.

  • Cloud Healthcare API가 각 DICOM 객체에 대해 .dcm 파일을 하나 만들기 때문에 객체 대신 Cloud Storage 버킷 또는 디렉터리에 기록합니다.
  • 명령어가 존재하지 않는 디렉터리를 지정하면 디렉터리가 생성됩니다.

curl

DICOM 인스턴스를 내보내려면 POST 요청을 수행하고 다음 정보를 제공하세요.

  • 상위 데이터 세트의 이름 및 위치
  • DICOM 저장소의 이름
  • 대상 Cloud Storage 버킷입니다.

다음 샘플은 curl을 사용하는 POST 요청을 보여줍니다.

curl -X POST \
    -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
    -H "Content-Type: application/json; charset=utf-8" \
    --data "{
      'gcsDestination': {
        'uriPrefix': 'gs://BUCKET/DIRECTORY'
      }
    }" "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID:export"

요청이 성공하면 서버가 JSON 형식으로 응답을 반환합니다.

{
  "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID"
}

응답에 작업 이름이 포함됩니다. 작업 상태를 추적하려면 작업 get 메서드를 사용합니다.

curl -X GET \
    -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
    "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID"

요청이 성공하면 서버는 JSON 형식의 작업 상태가 포함된 응답을 반환합니다.

{
  "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.healthcare.v1.OperationMetadata",
    "apiMethodName": "google.cloud.healthcare.v1.dicom.DicomService.ExportDicomData",
    "createTime": "CREATE_TIME",
    "endTime": "END_TIME",
    "logsUrl": "https://console.cloud.google.com/logs/query/CLOUD_LOGGING_URL",
    "counter":{
       "success": SUCCESSFUL_INSTANCES
       "failure": FAILED_INSTANCES
    }
  },
  "done": true,
  "response": {
    "@type": "..."
  }
}

PowerShell

DICOM 인스턴스를 내보내려면 POST 요청을 수행하고 다음 정보를 제공하세요.

  • 상위 데이터 세트의 이름 및 위치
  • DICOM 저장소의 이름
  • 대상 Cloud Storage 버킷입니다.

다음 샘플은 Windows PowerShell을 사용한 POST 요청을 보여줍니다.

$cred = gcloud auth application-default print-access-token
$headers = @{ Authorization = "Bearer $cred" }

Invoke-WebRequest `
  -Method Post `
  -Headers $headers `
  -ContentType: "application/json; charset=utf-8" `
  -Body "{
    'gcsDestination': {
      'uriPrefix': 'gs://BUCKET/DIRECTORY'
    }
  }" `
  -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID:export" | Select-Object -Expand Content

요청이 성공하면 서버가 JSON 형식으로 응답을 반환합니다.

{
  "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID"
}

응답에 작업 이름이 포함됩니다. 작업 상태를 추적하려면 작업 get 메서드를 사용합니다.

$cred = gcloud auth application-default print-access-token
$headers = @{ Authorization = "Bearer $cred" }

Invoke-WebRequest `
  -Method Get `
  -Headers $headers `
  -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID" | Select-Object -Expand Content

요청이 성공하면 서버는 JSON 형식의 작업 상태가 포함된 응답을 반환합니다.

{
  "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.healthcare.v1.OperationMetadata",
    "apiMethodName": "google.cloud.healthcare.v1.dicom.DicomService.ExportDicomData",
    "createTime": "CREATE_TIME",
    "endTime": "END_TIME",
    "logsUrl": "https://console.cloud.google.com/logs/query/CLOUD_LOGGING_URL",
    "counter":{
       "success": SUCCESSFUL_INSTANCES
       "failure": FAILED_INSTANCES
    },
  },
  "done": true,
  "response": {
    "@type": "..."
  }
}

Go

import (
	"context"
	"fmt"
	"io"

	healthcare "google.golang.org/api/healthcare/v1"
)

// exportDICOMInstance exports DICOM objects to GCS.
func exportDICOMInstance(w io.Writer, projectID, location, datasetID, dicomStoreID, destination string) error {
	ctx := context.Background()

	healthcareService, err := healthcare.NewService(ctx)
	if err != nil {
		return fmt.Errorf("healthcare.NewService: %w", err)
	}

	storesService := healthcareService.Projects.Locations.Datasets.DicomStores

	req := &healthcare.ExportDicomDataRequest{
		GcsDestination: &healthcare.GoogleCloudHealthcareV1DicomGcsDestination{
			UriPrefix: destination, // "gs://my-bucket/path/to/prefix/"
		},
	}
	name := fmt.Sprintf("projects/%s/locations/%s/datasets/%s/dicomStores/%s", projectID, location, datasetID, dicomStoreID)

	lro, err := storesService.Export(name, req).Do()
	if err != nil {
		return fmt.Errorf("Export: %w", err)
	}

	fmt.Fprintf(w, "Export to DICOM store started. Operation: %q\n", lro.Name)
	return nil
}

Java

import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.healthcare.v1.CloudHealthcare;
import com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.DicomStores;
import com.google.api.services.healthcare.v1.CloudHealthcareScopes;
import com.google.api.services.healthcare.v1.model.ExportDicomDataRequest;
import com.google.api.services.healthcare.v1.model.GoogleCloudHealthcareV1DicomGcsDestination;
import com.google.api.services.healthcare.v1.model.Operation;
import com.google.auth.http.HttpCredentialsAdapter;
import com.google.auth.oauth2.GoogleCredentials;
import java.io.IOException;
import java.util.Collections;

public class DicomStoreExport {
  private static final String DICOM_NAME = "projects/%s/locations/%s/datasets/%s/dicomStores/%s";
  private static final JsonFactory JSON_FACTORY = new GsonFactory();
  private static final NetHttpTransport HTTP_TRANSPORT = new NetHttpTransport();

  public static void dicomStoreExport(String dicomStoreName, String gcsUri) throws IOException {
    // String dicomStoreName =
    //    String.format(
    //        DICOM_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-dicom-id");
    // String gcsUri = "gs://your-bucket-id/path/to/destination/dir"

    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();

    // Configure where the store will be exported too.
    GoogleCloudHealthcareV1DicomGcsDestination gcsDestination =
        new GoogleCloudHealthcareV1DicomGcsDestination().setUriPrefix(gcsUri);
    ExportDicomDataRequest exportRequest =
        new ExportDicomDataRequest().setGcsDestination(gcsDestination);

    // Create request and configure any parameters.
    DicomStores.Export request =
        client
            .projects()
            .locations()
            .datasets()
            .dicomStores()
            .export(dicomStoreName, exportRequest);

    // Execute the request, wait for the operation to complete, and process the results.
    try {
      Operation operation = request.execute();
      while (operation.getDone() == null || !operation.getDone()) {
        // Update the status of the operation with another request.
        Thread.sleep(500); // Pause for 500ms between requests.
        operation =
            client
                .projects()
                .locations()
                .datasets()
                .operations()
                .get(operation.getName())
                .execute();
      }
      System.out.println("DICOM store export complete." + operation.getResponse());
    } catch (Exception ex) {
      System.out.printf("Error during request execution: %s", ex.toString());
      ex.printStackTrace(System.out);
    }
  }

  private static CloudHealthcare createClient() throws IOException {
    // Use Application Default Credentials (ADC) to authenticate the requests
    // For more information see https://cloud.google.com/docs/authentication/production
    GoogleCredentials credential =
        GoogleCredentials.getApplicationDefault()
            .createScoped(Collections.singleton(CloudHealthcareScopes.CLOUD_PLATFORM));

    // Create a HttpRequestInitializer, which will provide a baseline configuration to all requests.
    HttpRequestInitializer requestInitializer =
        request -> {
          new HttpCredentialsAdapter(credential).initialize(request);
          request.setConnectTimeout(60000); // 1 minute connect timeout
          request.setReadTimeout(60000); // 1 minute read timeout
        };

    // Build the client for interacting with the service.
    return new CloudHealthcare.Builder(HTTP_TRANSPORT, JSON_FACTORY, requestInitializer)
        .setApplicationName("your-application-name")
        .build();
  }
}

Node.js

const google = require('@googleapis/healthcare');
const healthcare = google.healthcare({
  version: 'v1',
  auth: new google.auth.GoogleAuth({
    scopes: ['https://www.googleapis.com/auth/cloud-platform'],
  }),
});

const exportDicomInstanceGcs = async () => {
  // TODO(developer): uncomment these lines before running the sample
  // const cloudRegion = 'us-central1';
  // const projectId = 'adjective-noun-123';
  // const datasetId = 'my-dataset';
  // const dicomStoreId = 'my-dicom-store';
  // const gcsUri = 'my-bucket/my-directory'
  const name = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/dicomStores/${dicomStoreId}`;
  const request = {
    name,
    resource: {
      gcsDestination: {
        // The destination location of the DICOM instances in Cloud Storage
        uriPrefix: `gs://${gcsUri}`,
        // The format to use for the output files, per the MIME types supported in the DICOM spec
        mimeType: 'application/dicom',
      },
    },
  };

  await healthcare.projects.locations.datasets.dicomStores.export(request);
  console.log(`Exported DICOM instances to ${gcsUri}`);
};

exportDicomInstanceGcs();

Python

def export_dicom_instance(project_id, location, dataset_id, dicom_store_id, uri_prefix):
    """Export data to a Google Cloud Storage bucket by copying
    it from the DICOM store.

    See https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/healthcare/api-client/v1/dicom
    before running the sample."""
    # Imports the Google API Discovery Service.
    from googleapiclient import discovery

    api_version = "v1"
    service_name = "healthcare"
    # Returns an authorized API client by discovering the Healthcare API
    # and using GOOGLE_APPLICATION_CREDENTIALS environment variable.
    client = discovery.build(service_name, api_version)

    # TODO(developer): Uncomment these lines and replace with your values.
    # project_id = 'my-project'  # replace with your GCP project ID
    # location = 'us-central1'  # replace with the parent dataset's location
    # dataset_id = 'my-dataset'  # replace with the DICOM store's parent dataset ID
    # dicom_store_id = 'my-dicom-store'  # replace with the DICOM store's ID
    # uri_prefix = 'my-bucket'  # replace with a Cloud Storage bucket
    dicom_store_parent = "projects/{}/locations/{}/datasets/{}".format(
        project_id, location, dataset_id
    )
    dicom_store_name = f"{dicom_store_parent}/dicomStores/{dicom_store_id}"

    body = {"gcsDestination": {"uriPrefix": f"gs://{uri_prefix}"}}

    request = (
        client.projects()
        .locations()
        .datasets()
        .dicomStores()
        .export(name=dicom_store_name, body=body)
    )

    response = request.execute()
    print(f"Exported DICOM instances to bucket: gs://{uri_prefix}")

    return response

필터를 사용하여 DICOM 인스턴스 내보내기

기본적으로 DICOM 파일을 Cloud Storage로 내보내면 DICOM 저장소의 모든 DICOM 파일이 내보내집니다. 마찬가지로 DICOM 메타데이터를 BigQuery로 내보내면 DICOM 저장소의 모든 DICOM 데이터 메타데이터가 내보내집니다.

필터 파일을 사용하여 DICOM 데이터 또는 메타데이터의 하위 집합을 내보낼 수 있습니다.

필터 파일 구성

필터 파일을 사용하여 Cloud Storage 또는 BigQuery로 내보낼 DICOM 파일 목록을 정의할 수 있습니다.

필터 파일의 각 줄은 학습, 시리즈 또는 인스턴스를 정의하고 /studies/STUDY_INSTANCE_UID/series/SERIES_INSTANCE_UID/instances/INSTANCE_UID 형식을 사용합니다.

선을 잘라 필터가 작동하는 수준을 지정할 수 있습니다. 예를 들어 /studies/STUDY_INSTANCE_UID를 지정하여 전체 학습을 내보내거나 /studies/STUDY_INSTANCE_UID/series/SERIES_INSTANCE_UID를 지정하여 전체 시리즈를 내보낼 수 있습니다.

다음 필터 파일을 예로 들어 봅시다.

/studies/1.123.456.789
/studies/1.666.333.111/series/123.456
/studies/1.666.333.111/series/567.890
/studies/1.888.999.222/series/123.456/instances/111
/studies/1.888.999.222/series/123.456/instances/222
/studies/1.888.999.222/series/123.456/instances/333

이 필터 파일을 사용하면 다음 필터링이 수행됩니다.

  • 학습 인스턴스 UID가 1.123.456.789인 전체 학습
  • 학습 1.666.333.111에서 시리즈 인스턴스 UID가 123.456567.890인 개별 시리즈 2개
  • 학습 1.888.999.222 및 시리즈 123.456에서 인스턴스 ID가 111, 222, 333인 개별 인스턴스 3개

BigQuery를 사용하여 필터 파일 만들기

BigQuery를 사용하여 필터 파일을 만들려면 DICOM 스토어의 메타데이터를 BigQuery로 내보내야 합니다. 내보낸 메타데이터에는 DICOM 스토어에 있는 DICOM 데이터의 학습, 시리즈, 인스턴스 UID가 표시됩니다.

내보낸 후 다음 단계를 완료하세요.

  1. 필수 학습, 시리즈, 인스턴스 UID를 쿼리합니다.

    예를 들어 DICOM 메타데이터를 BigQuery로 내보낸 후 다음 쿼리를 실행하여 필터 파일 형식 요구사항에 맞게 학습, 시리즈, 인스턴스 UID를 연결합니다.

    SELECT CONCAT
        ('/studies/', StudyInstanceUID, '/series/', SeriesInstanceUID, '/instances/', SOPInstanceUID)
    FROM
        [PROJECT_ID:BIGQUERY_DATASET.BIGQUERY_TABLE]
    
  2. 선택사항: 쿼리가 최대 응답 크기를 초과하는 큰 결과 집합을 반환하는 경우 BigQuery의 새 대상 테이블에 쿼리 결과를 저장합니다.

  3. 쿼리 결과를 파일에 저장하고 Cloud Storage로 내보냅니다. 2단계에서 새 대상 테이블에 쿼리 결과를 저장한 경우 테이블 데이터 내보내기를 참조하여 테이블 콘텐츠를 Cloud Storage로 내보냅니다.

  4. 내보낸 파일을 필요에 따라 수정하고 필터 파일로 사용합니다. Cloud Storage에서 필터 파일의 위치는 내보내기 작업에 필요합니다.

수동으로 필터 파일 만들기

커스텀 콘텐츠로 필터 파일을 만들고 Cloud Storage 버킷에 업로드하려면 다음 단계를 완료하세요.

  1. 로컬 머신에서 스토리지 클래스를 변경해야 하는 인스턴스 목록이 포함된 필터 파일을 만듭니다. 필터 파일 구성 섹션에 설명된 형식을 사용합니다.

  2. 필터 텍스트 파일을 Cloud Storage 위치에 업로드합니다.

    gsutil cp PATH_TO_FILTER_FILE/FILTER_FILE_NAME.txt gs://BUCKET/DIRECTORY
    

    다음을 바꿉니다.

    • PATH_TO_FILTER_FILE: 로컬 머신의 필터 파일 경로
    • FILTER_FILE_NAME: 필터 파일의 이름
    • BUCKET/DIRECTORY: Cloud Storage 위치 경로

    예를 들면 다음과 같습니다.

    gsutil cp my-local-folder/archive-filters.txt gs://my-bucket/my-directory
    

필터 파일 전달

필터 파일을 만든 후 DICOM 내보내기 작업을 호출하고 REST API를 사용하여 필터 파일을 전달합니다. 다음 샘플은 필터를 사용하여 DICOM 데이터를 내보내는 방법을 보여줍니다.

gcloud

필터를 사용하여 DICOM 메타데이터를 Cloud Storage로 내보내려면 gcloud beta healthcare dicom-stores export gcs 명령어를 사용합니다.

gcloud beta healthcare dicom-stores export gcs DICOM_STORE_ID \
  --dataset=DATASET_ID \
  --location=LOCATION \
  --gcs-uri-prefix=gs://DESTINATION_BUCKET/DIRECTORY \
  --filter-config-gcs-uri=gs://BUCKET/DIRECTORY/FILTER_FILE

다음을 바꿉니다.

  • DICOM_STORE_ID: DICOM 저장소의 식별자입니다.
  • DATASET_ID: DICOM 저장소의 상위 데이터 세트 이름입니다.
  • LOCATION: DICOM 저장소의 상위 데이터 세트 위치입니다.
  • DESTINATION_BUCKET/DIRECTORY: 대상 Cloud Storage 버킷입니다.
  • BUCKET/DIRECTORY/FILTER_FILE: Cloud Storage 버킷에서 필터 파일의 위치입니다.

출력은 다음과 같습니다.

Request issued for: [DICOM_STORE_ID]
Waiting for operation [projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID] to complete...done.
name: projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID

작업 상태를 보려면 gcloud healthcare operations describe 명령어를 실행하고 응답에서 OPERATION_ID를 제공합니다.

gcloud healthcare operations describe OPERATION_ID \
  --location=LOCATION \
  --dataset=DATASET_ID

다음을 바꿉니다.

  • OPERATION_ID: 이전 응답에서 반환된 ID 번호입니다.
  • DATASET_ID: DICOM 저장소의 상위 데이터 세트 이름입니다.
  • LOCATION: DICOM 저장소의 상위 데이터 세트 위치입니다.

출력은 다음과 같습니다.

done: true
metadata:
'@type': type.googleapis.com/google.cloud.healthcare.v1beta1.OperationMetadata
apiMethodName: google.cloud.healthcare.v1beta1.dicom.DicomService.ExportDicomData
counter:
  success: SUCCESSFUL_INSTANCES
  failure: FAILED_INSTANCES
createTime: 'CREATE_TIME'
endTime: 'END_TIME'
logsUrl: 'https://console.cloud.google.com/logs/query/CLOUD_LOGGING_URL'
name: projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID
response:
'@type': '...'

API

필터를 사용하여 DICOM 데이터를 내보내려면 projects.locations.datasets.dicomStores.export 메서드를 사용합니다.

curl

필터 파일을 사용하여 DICOM 데이터를 내보내려면 POST 요청을 수행하고 다음 정보를 제공합니다.

  • 상위 데이터 세트의 이름 및 위치
  • DICOM 저장소의 이름
  • 대상 Cloud Storage 버킷입니다.
  • Cloud Storage 버킷에서 필터 파일 위치

다음 샘플은 curl을 사용하는 POST 요청을 보여줍니다.

curl -X POST \
    -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
    -H "Content-Type: application/json; charset=utf-8" \
    --data "{
      'gcsDestination': {
        'uriPrefix': 'gs://BUCKET/DIRECTORY'
      },
      'filterConfig': {
        'resourcePathsGcsUri': 'gs://BUCKET/DIRECTORY/FILTER_FILE'
      }
    }" "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID:export"

요청이 성공하면 서버는 다음과 같은 JSON 형식의 응답을 반환합니다.

{
  "name": "projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/operations/OPERATION_ID"
}

응답에 작업 이름이 포함됩니다. 작업 get 메서드를 사용하여 작업 상태를 추적합니다.

curl -X GET \
    -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
    "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/operations/OPERATION_NAME"

요청이 성공하면 서버는 다음과 같은 JSON 형식의 응답을 반환합니다.

{
  "name": "projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.healthcare.v1beta1.OperationMetadata",
    "apiMethodName": "google.cloud.healthcare.v1beta1.dicom.DicomService.ExportDicomData",
    "createTime": "CREATE_TIME",
    "endTime": "END_TIME"
  },
  "done": true,
  "response": {
    "@type": "..."
  }
}

PowerShell

필터 파일을 사용하여 DICOM 데이터를 내보내려면 POST 요청을 수행하고 다음 정보를 제공합니다.

  • 상위 데이터 세트의 이름 및 위치
  • DICOM 저장소의 이름
  • 대상 Cloud Storage 버킷입니다.
  • Cloud Storage 버킷에서 필터 파일 위치

다음 샘플은 Windows PowerShell을 사용한 POST 요청을 보여줍니다.

$cred = gcloud auth application-default print-access-token
$headers = @{ Authorization = "Bearer $cred" }

Invoke-WebRequest `
  -Method Post `
  -Headers $headers `
  -ContentType: "application/json; charset=utf-8" `
  -Body "{
    'gcsDestination': {
      'uriPrefix': 'gs://BUCKET/DIRECTORY'
    },
    'filterConfig': {
      'resourcePathsGcsUri': 'gs://BUCKET/DIRECTORY/FILTER_FILE'
  }" `
  -Uri "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID:export" | Select-Object -Expand Content

요청이 성공하면 서버는 다음과 같은 JSON 형식의 응답을 반환합니다.

{
  "name": "projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/operations/OPERATION_ID"
}

응답에 작업 이름이 포함됩니다. 작업 get 메서드를 사용하여 작업 상태를 추적합니다.

$cred = gcloud auth application-default print-access-token
$headers = @{ Authorization = "Bearer $cred" }

Invoke-WebRequest `
  -Method Get `
  -Headers $headers `
  -Uri "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/operations/OPERATION_NAME" | Select-Object -Expand Content

요청이 성공하면 서버는 JSON 형식의 작업 상태가 포함된 다음 응답을 반환합니다.

{
  "name": "projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.healthcare.v1beta1.OperationMetadata",
    "apiMethodName": "google.cloud.healthcare.v1beta1.dicom.DicomService.ExportDicomData",
    "createTime": "CREATE_TIME",
    "endTime": "END_TIME"
  },
  "done": true,
  "response": {
    "@type": "..."
  }
}

DICOM 내보내기 요청 문제 해결

DICOM 내보내기 요청 중에 오류가 발생하면 오류가 Cloud Logging에 기록됩니다. 자세한 내용은 Cloud Logging에서 오류 로그 보기를 참조하세요.

전체 작업이 오류를 반환하는 경우 장기 실행 작업 문제 해결을 참조하세요.