ייבוא וייצוא של נתוני DICOM באמצעות Cloud Storage

בדף הזה מוסבר איך לייצא מופעי DICOM אל Cloud Storage ואיך לייבא אובייקטים של DICOM מ-Cloud Storage. מופע DICOM הוא בדרך כלל תמונה, אבל יכול להיות גם סוג אחר של נתונים קבועים, כמו דוח מובנה. אובייקט DICOM ב-Cloud Storage הוא מופע DICOM שנמצא ב-Cloud Storage. מידע נוסף זמין במאמר בנושא Cloud Storage.

הגדרת הרשאות ב-Cloud Storage

לפני שמייצאים ומייבאים נתוני DICOM אל Cloud Storage וממנו, צריך להעניק הרשאות נוספות לחשבון השירות של סוכן שירות Cloud Healthcare. מידע נוסף זמין במאמר בנושא הרשאות Cloud Storage בחנות DICOM.

ייבוא אובייקטים של DICOM

כדי לייבא כמה קבצים של מופעי DICOM למאגר DICOM, אפשר להשתמש באחת מהשיטות הבאות:

בדוגמאות הבאות מוצגות דרכים לייבא אובייקטים בפורמט DICOM מקטגוריה ב-Cloud Storage.

המסוף

כדי לייבא אובייקטים של DICOM מקטגוריה ב-Cloud Storage, מבצעים את השלבים הבאים:

  1. נכנסים לדף Datasets במסוף Google Cloud .
    מעבר לדף Datasets
  2. לוחצים על מערך הנתונים שמכיל את מאגר DICOM שאליו מייבאים אובייקטים של DICOM.
  3. ברשימת מאגרי הנתונים, בוחרים באפשרות ייבוא מתוך הרשימה פעולות של מאגר DICOM.

    מופיע הדף ייבוא למאגר DICOM.
  4. ברשימה Project, בוחרים פרויקט של Cloud Storage.
  5. ברשימה מיקום, בוחרים קטגוריה של Cloud Storage.
  6. כדי להגדיר מיקום ספציפי לייבוא קבצים:
    1. מרחיבים את אפשרויות מתקדמות.
    2. בוחרים באפשרות Override Cloud Storage Path (עקיפת הנתיב של Cloud Storage).
    3. כדי להגדיר מקור ספציפי לייבוא קבצים, מגדירים את הנתיב באמצעות המשתנים הבאים בתיבת הטקסט מיקום:
      • * – תואם לתווים שאינם מפרידים.
      • ** – תואם לתווים, כולל מפרידים. אפשר להשתמש בזה עם סיומת של שם קובץ כדי להתאים לכל הקבצים מאותו סוג.
      • ? – מתאים לתו אחד.
  7. לוחצים על ייבוא כדי לייבא אובייקטים של DICOM מהמקור שהוגדר.
  8. כדי לעקוב אחרי סטטוס הפעולה, לוחצים על הכרטיסייה פעולות. אחרי שהפעולה מסתיימת, מופיעים הסימנים הבאים:
    • בקטע Long-running operation status (סטטוס של פעולה ממושכת) מופיע סימן וי ירוק מתחת לכותרת OK.
    • בקטע סקירה כללית מופיעים סימן וי ירוק והאינדיקטור OK באותה שורה שבה מופיע מזהה הפעולה.
    אם נתקלתם בשגיאות, לוחצים על פעולות ואז על הצגת הפרטים ב-Cloud Logging.

gcloud

כדי לייבא אובייקטים של DICOM מקטגוריה של Cloud Storage, משתמשים בפקודה gcloud healthcare dicom-stores import gcs. מציינים את השם של מערך הנתונים הראשי, את השם של מאגר DICOM ואת המיקום של האובייקט בקטגוריה של Cloud Storage.

  • המיקום של הקבצים ב-Bucket הוא שרירותי ולא חייב להיות זהה לפורמט שמופיע בדוגמה הבאה.
  • כשמציינים את המיקום של אובייקטים מסוג DICOM ב-Cloud Storage, אפשר להשתמש בתווים כלליים כדי לייבא כמה קבצים מספרייה אחת או יותר. יש תמיכה בתווים הכלליים לחיפוש הבאים:
    • משתמשים ב-* כדי להתאים 0 או יותר תווים שאינם מפרידים. לדוגמה, gs://BUCKET/DIRECTORY/Example*.dcm תואם ל-Example.dcm ול-Example22.dcm ב-DIRECTORY.
    • משתמשים ב-** כדי להתאים 0 תווים או יותר (כולל מפרידים). חובה להשתמש בו בסוף הנתיב, בלי תווים כלליים אחרים בנתיב. אפשר להשתמש גם בסיומת של שם קובץ (כמו ‎ .dcm), כדי לייבא את כל הקבצים עם הסיומת של שם הקובץ בספרייה שצוינה ובספריות המשנה שלה. לדוגמה, gs://BUCKET/DIRECTORY/**.dcm מייבא את כל הקבצים עם סיומת שם הקובץ ‎ .dcm ב-DIRECTORY ובספריות המשנה שלו.
    • כדי להתאים תו אחד, משתמשים ב-?. לדוגמה, gs://BUCKET/DIRECTORY/Example?.dcm תואם ל- Example1.dcm אבל לא תואם ל-Example.dcm או ל-Example01.dcm.

בדוגמה הבאה מוצגות הוראות לייבוא אובייקטים בפורמט DICOM מקטגוריה ב-Cloud Storage.

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

מזהה הפעולה מוצג בשורת הפקודה:

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

כדי לייבא אובייקטים בפורמט DICOM מקטגוריה של Cloud Storage, משתמשים בשיטה projects.locations.datasets.dicomStores.import.

  • המיקום של הקבצים בתוך הקטגוריה יכול להיות שונה, והוא לא חייב להיות זהה לפורמט שמופיע בדוגמאות הבאות.
  • כשמציינים את המיקום של אובייקטים מסוג DICOM ב-Cloud Storage, צריך להשתמש בתווים כלליים כדי לייבא כמה קבצים מספרייה אחת או יותר. יש תמיכה בתווים הכלליים לחיפוש הבאים:
    • משתמשים ב-* כדי להתאים 0 או יותר תווים שאינם מפרידים. לדוגמה, gs://BUCKET/DIRECTORY/Example*.dcm תואם ל-Example.dcm ול-Example22.dcm ב-DIRECTORY.
    • משתמשים ב-** כדי להתאים 0 תווים או יותר (כולל מפרידים). חובה להשתמש בו בסוף הנתיב, בלי תווים כלליים אחרים בנתיב. אפשר להשתמש גם בסיומת של שם קובץ (כמו ‎ .dcm), כדי לייבא את כל הקבצים עם הסיומת של שם הקובץ בספרייה שצוינה ובספריות המשנה שלה. לדוגמה, gs://BUCKET/DIRECTORY/**.dcm מייבא את כל הקבצים עם סיומת שם הקובץ ‎ .dcm ב-DIRECTORY ובספריות המשנה שלו.
    • כדי להתאים תו אחד, משתמשים ב-?. לדוגמה, gs://BUCKET/DIRECTORY/Example?.dcm תואם ל- Example1.dcm אבל לא תואם ל-Example.dcm או ל-Example01.dcm.

REST

  1. מייבאים את אובייקט ה-DICOM.

    לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

    • PROJECT_ID: מזהה הפרויקט ב- Google Cloud
    • LOCATION: המיקום של מערך הנתונים
    • DATASET_ID: מערך הנתונים הראשי של מאגר DICOM
    • DICOM_STORE_ID: מזהה מאגר DICOM
    • BUCKET/PATH/TO/FILE: הנתיב לאובייקט DICOM ב-Cloud Storage

    תוכן בקשת 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
    • LOCATION: המיקום של מערך הנתונים
    • DATASET_ID: מערך הנתונים הראשי של מאגר DICOM
    • OPERATION_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 occurred:',
      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, צריך לאחזר נתוני DICOM באמצעות Retrieve Transaction, שירות אינטרנט מבוסס RESTful כפי שהוא מיושם ב-Cloud Healthcare API.

ציון סוג אחסון לייבוא אובייקטים בפורמט DICOM (תצוגה מקדימה)

כברירת מחדל, השיטה projects.locations.datasets.dicomStores.import מייבאת אובייקט DICOM למאגר DICOM עם סוג אחסון רגיל. אתם יכולים להגדיר את סוג האחסון (storage class) כשאתם מייבאים אובייקטים של DICOM מ-Cloud Storage. מידע נוסף מופיע במאמר בנושא שינוי סוג האחסון של DICOM.

בדוגמאות הבאות מוצגות דרכים לציין את סוג האחסון כשמייבאים אובייקטים בפורמט DICOM מ-Cloud Storage.

REST

משתמשים בשיטה projects.locations.datasets.dicomStores.import.

  1. מייבאים את אובייקט ה-DICOM.

    לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

    • PROJECT_ID: מזהה הפרויקט ב- Google Cloud
    • LOCATION: המיקום של מערך הנתונים
    • DATASET_ID: מערך הנתונים הראשי של מאגר DICOM
    • DICOM_STORE_ID: מזהה מאגר DICOM
    • BUCKET/PATH/TO/FILE: הנתיב לאובייקט DICOM ב-Cloud Storage
    • STORAGE_CLASS: מחלקת האחסון של אובייקט DICOM בחנות DICOM מ-STANDARD,‏ NEARLINE,‏ COLDLINE ו-ARCHIVE

    תוכן בקשת 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
    • LOCATION: המיקום של מערך הנתונים
    • DATASET_ID: מערך הנתונים הראשי של מאגר DICOM
    • OPERATION_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. נכנסים לדף Datasets במסוף Google Cloud .
    מעבר לדף Datasets
  2. לוחצים על מערך הנתונים שמכיל את מאגר DICOM שממנו מייצאים מופעי DICOM.
  3. ברשימת מאגרי הנתונים, בוחרים באפשרות ייצוא מתוך הרשימה פעולות של מאגר DICOM.
  4. בדף Export DICOM Store שמופיע, בוחרים באפשרות Google Cloud Storage Bucket.
  5. ברשימה Project, בוחרים פרויקט של Cloud Storage.
  6. ברשימה מיקום, בוחרים קטגוריה של Cloud Storage.
  7. בקטע DICOM Export Settings (הגדרות ייצוא DICOM), בוחרים את סוג הקובץ שמשמש לייצוא של מופעי DICOM. אלה הסוגים שזמינים:
    • קובץ DICOM ‏ (.dcm)
    • octet-stream
    • תמונה (.jpg, .png)
  8. כדי להגדיר תחביר העברה נוסף, בוחרים את התחביר מהרשימה Transfer Syntax.
  9. לוחצים על ייצוא כדי לייצא את מופעי DICOM למיקום שהוגדר ב-Cloud Storage.
  10. כדי לעקוב אחרי סטטוס הפעולה, לוחצים על הכרטיסייה פעולות. אחרי שהפעולה מסתיימת, מופיעים הסימנים הבאים:
    • בקטע Long-running operation status (סטטוס של פעולה ממושכת) מופיע סימן וי ירוק מתחת לכותרת OK.
    • בקטע סקירה כללית מופיעים סימן וי ירוק והאינדיקטור OK באותה שורה שבה מופיע מזהה הפעולה.
    אם נתקלתם בשגיאות, לוחצים על פעולות ואז על הצגת הפרטים ב-Cloud Logging.

gcloud

כדי לייצא מופעי DICOM לקטגוריה של Cloud Storage, משתמשים בפקודה gcloud healthcare dicom-stores export gcs.

  • צריך לציין את השם של מערך הנתונים הראשי, את השם של מאגר DICOM ואת קטגוריית Cloud Storage ליעד.
  • כדאי לכתוב לקטגוריה או לספרייה ב-Cloud Storage ולא לאובייקט, כי Cloud Healthcare API יוצר קובץ .dcm אחד לכל אובייקט.
  • אם הפקודה מציינת ספרייה שלא קיימת, הספרייה נוצרת.

בדוגמה הבאה אפשר לראות את הפקודה 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

מזהה הפעולה מוצג בשורת הפקודה:

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 Storage ולא לאובייקט, כי Cloud Healthcare API יוצר קובץ .dcm אחד לכל אובייקט DICOM.
  • אם הפקודה מציינת ספרייה שלא קיימת, הספרייה נוצרת.

curl

כדי לייצא מופעי DICOM, שולחים בקשת POST ומספקים את הפרטים הבאים:

  • השם והמיקום של מערך נתוני האב
  • השם של מאגר DICOM
  • קטגוריית היעד של Cloud Storage

בדוגמה הבאה מוצגת בקשת POST באמצעות curl.

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"
}

התשובה מכילה שם פעולה. כדי לעקוב אחרי סטטוס הפעולה, משתמשים ב-Operation get method:

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

בדוגמה הבאה מוצגת בקשת POST באמצעות Windows PowerShell.

$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"
}

התשובה מכילה שם פעולה. כדי לעקוב אחרי סטטוס הפעולה, משתמשים ב-Operation get method:

$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 או מטא נתונים באמצעות קובץ מסנן.

הגדרת קובץ מסנן

  • כל שורה בקובץ המסנן מגדירה את המחקר, הסדרה או המופע, ומשתמשת בפורמט /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
  • שתי סדרות נפרדות עם מזהי UID של מופע הסדרה 123.456 ו-567.890 במחקר 1.666.333.111
  • שלוש מכונות נפרדות עם מזהי מכונה 111, 222 ו-333 במחקר 1.888.999.222 ובסדרה 123.456

יצירת קובץ סינון באמצעות BigQuery

כדי ליצור קובץ מסנן באמצעות BigQuery, קודם צריך לייצא את המטא-נתונים של מאגר DICOM ל-BigQuery. במטא-נתונים המיוצאים מוצגים מזהי ה-UID של המחקר, הסדרה והמופע של נתוני DICOM במאגר DICOM.

אחרי שמייצאים את המטא-נתונים, מבצעים את השלבים הבאים:

  1. מריצים שאילתה כדי לקבל את מזהי ה-UID של המחקר, הסדרה והמופעים שרוצים להוסיף לקובץ המסנן.

    לדוגמה, השאילתה הבאה מראה איך לשרשר את מזהי ה-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. עורכים את הקובץ המיוצא לפי הצורך, וכוללים אותו בבקשה לשינוי סוג האחסון של כמה אובייקטים מסוג DICOM.

יצירה ידנית של קובץ מסנן

כדי ליצור קובץ מסנן באופן ידני:

  1. יוצרים קובץ מסנן שמכיל את אובייקטי ה-DICOM שרוצים לסנן.
  2. מעלים את קובץ המסנן ל-Cloud Storage. הוראות מפורטות זמינות במאמר העלאת אובייקטים ממערכת קבצים.

העברה בקובץ המסנן

אחרי שיוצרים קובץ מסנן, קוראים לפעולת הייצוא של 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: מספר המזהה שהוחזר מהתגובה הקודמת
  • 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

בדוגמה הבאה מוצגת בקשת POST באמצעות curl.

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 של Operation:

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

בדוגמה הבאה מוצגת בקשת POST באמצעות Windows PowerShell.

$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 של Operation:

$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.

אם כל הפעולה מחזירה שגיאה, אפשר לעיין במאמר בנושא פתרון בעיות בפעולות ארוכות טווח.