本頁說明如何將 DICOM 執行個體匯出至 Cloud Storage,以及從 Cloud Storage 匯入 DICOM 物件。DICOM 執行個體通常是圖片,但也可以是其他類型的永久資料,例如結構化報告。Cloud Storage 中的 DICOM 物件是位於 Cloud Storage 中的 DICOM 執行個體。詳情請參閱 Cloud Storage。
設定 Cloud Storage 權限
如要將 DICOM 資料匯出及匯入 Cloud Storage,您必須先授予 Cloud Healthcare Service Agent 服務帳戶額外權限。詳情請參閱「DICOM 儲存庫 Cloud Storage 權限」。
匯入 DICOM 物件
如要將多個 DICOM 執行個體檔案匯入 DICOM 儲存庫,可以使用下列任一方法:
- 使用 Cloud Healthcare API 實作的 Store Transaction RESTful 網路服務,從本機電腦直接將資料儲存在 DICOM 儲存空間。
- 將 DICOM 資料上傳至 Cloud Storage 值區,然後使用單一匯入作業將檔案匯入 DICOM 儲存庫,如本節所述。
下列範例說明如何從 Cloud Storage 值區匯入 DICOM 物件。
控制台
如要從 Cloud Storage 值區匯入 DICOM 物件,請完成下列步驟:
- 在 Google Cloud 控制台中,前往「資料集」頁面。
前往「資料集」 - 按一下包含 DICOM 儲存庫的資料集,您要將 DICOM 物件匯入該儲存庫。
- 在資料儲存庫清單中,從 DICOM 儲存庫的「Actions」(動作) 清單中選擇「Import」(匯入)。
系統會顯示「Import to DICOM store」(匯入 DICOM 儲存庫) 頁面。 - 在「Project」(專案) 清單中,選取 Cloud Storage 專案。
- 在「Location」(位置) 清單中,選取 Cloud Storage bucket。
- 如要設定匯入檔案的特定位置,請按照下列步驟操作:
- 展開「進階選項」。
- 選取「覆寫 Cloud Storage 路徑」。
- 如要設定匯入檔案的特定來源,請在「位置」文字方塊中使用下列變數定義路徑:
*
:比對非分隔符字元。**
- 比對字元,包括分隔符。 這項功能可搭配副檔名使用,比對所有相同類型的檔案。?
- 比對 1 個字元。
- 按一下「匯入」,從定義的來源匯入 DICOM 物件。
- 如要追蹤作業狀態,請按一下「Operations」(作業) 分頁標籤。作業完成後,會顯示下列指標:
- 「長時間執行的作業狀態」部分在「OK」標題下方顯示綠色勾號。
- 「總覽」部分會顯示綠色勾號和「OK」指標,與作業 ID 位於同一列。
gcloud
如要從 Cloud Storage 值區匯入 DICOM 物件,請使用 gcloud healthcare dicom-stores import gcs
指令。指定父項資料集名稱、DICOM 儲存庫名稱,以及 Cloud Storage bucket 中的物件位置。
- bucket 中的檔案位置是任意的,不一定要完全符合下列範例中指定的格式。
- 在 Cloud Storage 中指定 DICOM 物件的位置時,可以使用萬用字元從一或多個目錄匯入多個檔案。
支援的萬用字元如下:
- 使用
*
可比對 0 個以上的非分隔符字元。舉例來說,gs://BUCKET/DIRECTORY/Example*.dcm
會與 DIRECTORY 中的 Example.dcm 和 Example22.dcm 相符。 - 使用
**
來比對 0 個以上的字元 (包括分隔符)。必須用於路徑結尾,且路徑中不得有其他萬用字元。也可以搭配檔案副檔名 (例如 .dcm) 使用,匯入指定目錄及其子目錄中副檔名為該副檔名的所有檔案。舉例來說,gs://BUCKET/DIRECTORY/**.dcm
會匯入 DIRECTORY 及其子目錄中副檔名為「.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/**.dcm
會匯入 DIRECTORY 及其子目錄中副檔名為「.dcm」的所有檔案。 - 使用「
?
」比對 1 個字元。舉例來說,gs://BUCKET/DIRECTORY/Example?.dcm
會與 Example1.dcm 相符,但與 Example.dcm 或 Example01.dcm 不相符。
- 使用
REST
匯入 DICOM 物件。 <0x0A
使用任何要求資料之前,請先替換以下項目:
PROJECT_ID
:您的 Google Cloud 專案 IDLOCATION
:資料集位置DATASET_ID
:DICOM 儲存庫的父項資料集DICOM_STORE_ID
:DICOM 儲存庫 IDBUCKET/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取得長時間執行作業的狀態。 <0x0
使用任何要求資料之前,請先替換以下項目:
- 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
Go
Java
Node.js
Python
如要從 DICOM 存放區擷取單一執行個體或研究,請使用 Cloud Healthcare API 實作的 Retrieve Transaction RESTful Web 服務,擷取 DICOM 資料。
指定儲存空間級別來匯入 DICOM 物件 (預先發布版)
根據預設,projects.locations.datasets.dicomStores.import
方法會將 DICOM 物件匯入 DICOM 儲存庫,並使用標準儲存空間類別。從 Cloud Storage 匯入 DICOM 物件時,可以設定儲存空間類別。詳情請參閱「變更 DICOM 儲存空間級別」。
下列範例說明從 Cloud Storage 匯入 DICOM 物件時,如何指定儲存空間類別。
REST
請使用 projects.locations.datasets.dicomStores.import
方法。
匯入 DICOM 物件。 <0x
使用任何要求資料之前,請先替換以下項目:
PROJECT_ID
:您的 Google Cloud 專案 IDLOCATION
:資料集位置DATASET_ID
:DICOM 儲存庫的父項資料集DICOM_STORE_ID
:DICOM 儲存庫 IDBUCKET/PATH/TO/FILE
:Cloud Storage 中 DICOM 物件的路徑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取得長時間執行作業的狀態。 <0x0A
使用任何要求資料之前,請先替換以下項目:
- 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 匯入要求問題
如果 DICOM 匯入要求發生錯誤,系統會將錯誤記錄到 Cloud Logging。詳情請參閱「查看 Cloud Logging 中的錯誤記錄檔」。
匯出 DICOM 執行個體
下列範例說明如何將 DICOM 執行個體匯出至 Cloud Storage bucket。從 DICOM 儲存庫匯出 DICOM 執行個體時,系統會匯出儲存庫中的所有執行個體。
控制台
如要將 DICOM 執行個體匯出至 Cloud Storage,請完成下列步驟:
- 在 Google Cloud 控制台中,前往「資料集」頁面。
前往「資料集」 - 按一下包含 DICOM 儲存庫的資料集,您要從該儲存庫匯出 DICOM 執行個體。
- 在資料儲存庫清單中,從 DICOM 儲存庫的「動作」清單中選擇「匯出」。
- 在隨即顯示的「Export DICOM Store」(匯出 DICOM 儲存庫) 頁面中,選取「Google Cloud Storage Bucket」(Google Cloud Storage 值區)。
- 在「Project」(專案) 清單中,選取 Cloud Storage 專案。
- 在「Location」(位置) 清單中,選取 Cloud Storage bucket。
- 在「DICOM Export Settings」(DICOM 匯出設定) 中,選取用於匯出 DICOM 執行個體的檔案類型。可用的類型如下:
- DICOM 檔案 (
.dcm
) - octet-stream
- 圖片 (
.jpg
、.png
)
- DICOM 檔案 (
- 如要定義其他傳輸語法,請從「傳輸語法」清單中選擇語法。
- 按一下「匯出」,將 DICOM 執行個體匯出至 Cloud Storage 中定義的位置。
- 如要追蹤作業狀態,請按一下「Operations」(作業) 分頁標籤。作業完成後,會顯示下列指標:
- 「長時間執行的作業狀態」部分在「OK」標題下方顯示綠色勾號。
- 「總覽」部分會顯示綠色勾號和「OK」指標,與作業 ID 位於同一列。
gcloud
如要將 DICOM 執行個體匯出至 Cloud Storage 值區,請使用 gcloud healthcare dicom-stores export gcs
指令。
- 提供父項資料集名稱、DICOM 存放區名稱和目的地 Cloud Storage bucket。
- 請寫入 Cloud Storage bucket 或目錄,而非物件,因為 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
指令列會顯示作業 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 Storage bucket 或目錄,而非物件,因為 Cloud Healthcare API 會為每個 DICOM 物件建立一個
.dcm
檔案。 - 如果指令指定的目錄不存在,系統會建立該目錄。
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
Java
Node.js
Python
使用篩選器匯出 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 在研究
1.666.333.111
中分別為123.456
和567.890
- 研究
1.888.999.222
和系列123.456
中有三個執行個體,執行個體 ID 分別為111
、222
和333
使用 BigQuery 建立篩選器檔案
如要使用 BigQuery 建立篩選器檔案,請先將 DICOM 儲存庫的中繼資料匯出至 BigQuery。匯出的中繼資料會顯示 DICOM 儲存庫中 DICOM 資料的研究、系列和執行個體 UID。
匯出中繼資料後,請完成下列步驟:
執行查詢,傳回要新增至篩選器檔案的研究、系列和執行個體 UID。
舉例來說,下列查詢顯示如何串連研究、系列和例項 UID,以符合篩選器檔案格式規定:
SELECT CONCAT ('/studies/', StudyInstanceUID, '/series/', SeriesInstanceUID, '/instances/', SOPInstanceUID) FROM [PROJECT_ID:BIGQUERY_DATASET.BIGQUERY_TABLE]
選用:如果查詢傳回的結果集過大,超出回應大小上限,請將查詢結果儲存至 BigQuery 中的新目的地資料表。
將查詢結果儲存至檔案,然後匯出至 Cloud Storage。如果您在步驟 2 中將查詢結果儲存至新的目的地資料表,請參閱「匯出資料表資料」一文,瞭解如何將資料表內容匯出至 Cloud Storage。
視需要編輯匯出的檔案,並將其納入變更多個 DICOM 物件儲存空間類別的要求中。
手動建立篩選器檔案
如要手動建立篩選器檔案,請執行下列操作:
- 建立篩選器檔案,內含要篩選的 DICOM 物件。
- 將篩選器檔案上傳至 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 儲存庫的 ID
- DATASET_ID:DICOM 儲存庫父項資料集的名稱
- LOCATION:DICOM 儲存庫父項資料集的位置
- DESTINATION_BUCKET/DIRECTORY:目的地 Cloud Storage bucket
- 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" }
回應會包含作業名稱。使用 Operation 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" }
回應會包含作業名稱。使用 Operation 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 中的錯誤記錄檔」。
如果整個作業傳回錯誤,請參閱「排解長期執行的作業問題」。