-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcontrast_index.sql
More file actions
43 lines (38 loc) · 1.74 KB
/
Copy pathcontrast_index.sql
File metadata and controls
43 lines (38 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# table-description:
# This table contains one row per DICOM series that has contrast agent information.
# It captures contrast bolus metadata from CT, MR, PT, XA, and RF imaging modalities,
# including the agent name, ingredient, and administration route. Only series with
# at least one non-null contrast attribute are included. This table can be joined
# with the main idc_index table using the SeriesInstanceUID column.
WITH contrast_data AS (
SELECT
SeriesInstanceUID,
ARRAY_AGG(DISTINCT ContrastBolusAgent IGNORE NULLS ORDER BY ContrastBolusAgent) AS ContrastBolusAgent,
ARRAY_AGG(DISTINCT ContrastBolusIngredient IGNORE NULLS ORDER BY ContrastBolusIngredient) AS ContrastBolusIngredient,
ARRAY_AGG(DISTINCT ContrastBolusRoute IGNORE NULLS ORDER BY ContrastBolusRoute) AS ContrastBolusRoute
FROM `bigquery-public-data.idc_v24.dicom_all`
WHERE Modality IN ('CT', 'MR', 'PT', 'XA', 'RF')
GROUP BY SeriesInstanceUID
)
SELECT
# description:
# DICOM SeriesInstanceUID identifier of the imaging series
SeriesInstanceUID,
# description:
# distinct contrast agent names used in the series as defined in DICOM ContrastBolusAgent attribute
ContrastBolusAgent,
# description:
# distinct contrast agent ingredients used in the series as defined in DICOM ContrastBolusIngredient attribute
ContrastBolusIngredient,
# description:
# distinct contrast administration routes used in the series as defined in DICOM ContrastBolusRoute attribute
ContrastBolusRoute
FROM contrast_data
WHERE
ARRAY_LENGTH(ContrastBolusAgent) > 0
OR ARRAY_LENGTH(ContrastBolusIngredient) > 0
OR ARRAY_LENGTH(ContrastBolusRoute) > 0
ORDER BY
ContrastBolusAgent[SAFE_OFFSET(0)],
ContrastBolusIngredient[SAFE_OFFSET(0)],
ContrastBolusRoute[SAFE_OFFSET(0)]