Skip to content

Commit

Permalink
Merge pull request #9 from MaastrichtU-CDS/release/0.3
Browse files Browse the repository at this point in the history
Release/0.3
  • Loading branch information
jvsoest authored Oct 6, 2023
2 parents 17f022d + c42dfea commit 155f5a4
Show file tree
Hide file tree
Showing 18 changed files with 631 additions and 80 deletions.
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,27 @@ Usage: ldcm-parse [OPTIONS] DICOM_INPUT_FOLDER
Options:
-o, --ontology-file TEXT Location of ontology file to use for override.
-fp, --file-persistent Store file path while parsing metadata.
--help Show this message and exit.
```

The output is saved in linkeddicom.ttl in the DICOM_INPUT_FOLDER. This data can be used by importing it into an RDF endpoint (such as Apache Jena or GraphDB).
**If you want to use the files afterwards to calculate DVH parameters, you need to include the -fp option.**

### Calculating DVH curves locally

Based on the previous parsing (`ldcm-parse`) you can calculate DVH curve results and store them in a JSON-LD file (per RTSTRUCT-RTDOSE combination). Currently, the combination is being calculated following the references in the DICOM file:

- RTDOSE references to RTPlan
- RTPlan references to RTStruct

A copy of this help is presented below:
```
Usage: ldcm-calc-dvh [OPTIONS] LDCM_RDF_LOCATION OUTPUT_LOCATION
Options:
--help Show this message and exit.
```

### DICOM SCP service
This tool can be used if you want to start a DICOM SCP service which supports C-STORE commands.
Expand All @@ -56,10 +73,12 @@ Usage: ldcm-scp [OPTIONS] PORT
the analysis is triggered in a separate thread.
Options:
-o, --ontology-file TEXT Location of ontology file to use for override.
-s, --sparql-endpoint TEXT SPARQL endpoint URL to post the resulting
triples towards
--help Show this message and exit.
-o, --ontology-file TEXT Location of ontology file to use for
override.
-s, --sparql-endpoint TEXT SPARQL endpoint URL to post the resulting
triples towards
-dvh, --dose-volume-histogram Compute and store DVH for all available structures.
--help Show this message and exit.
```

By default, the UUID for the DICOM association is used as filename for the created local turtle file.
Expand Down
9 changes: 8 additions & 1 deletion examples/queries/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,11 @@
The following example queries are listed below:

* **[RTSTRUCT.sparql](RTSTRUCT.sparql)** Find the structure names for all patients in various RTSTRUCT files
* **[RTSTRUCT_CT.sparql](RTSTRUCT_CT.sparql)** Similar as `RTSTRUCT.sparql` however now with the referenced CT information
* **[RTSTRUCT_CT.sparql](RTSTRUCT_CT.sparql)** Similar as `RTSTRUCT.sparql` however now with the referenced CT information
* **[RT_package.sparql](RT_package.sparql)** Query which fetches the RT Dose -> Plan -> Structure -> CT (series) reference

## Specific DVH queries
* **[dose_overview.sparql](dose_overview.sparql)** Query the general/generic dose information
* **[dvh_curve.sparql](dvh_curve.sparql)** Give a DVH curve points for a specific structure
* **[dvh_d_point.sparql](dvh_d_point.sparql)** Query a specific DVH-d point (d30)
* **[dvh_v_point.sparql](dvh_v_point.sparql)** Query a specific DVH-v point (v10)
34 changes: 34 additions & 0 deletions examples/queries/RT_package.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX ldcm: <https://johanvansoest.nl/ontologies/LinkedDicom/>

select *
where {
?rtDose rdf:type ldcm:Radiotherapy_Dose_Object;
ldcm:T300C0002 [
ldcm:has_sequence_item [
ldcm:R00081155 ?rtPlan;
];
].

?rtPlan rdf:type ldcm:Radiotherapy_Plan_Object;
ldcm:T300C0060 [
ldcm:has_sequence_item [
ldcm:R00081155 ?rtStruct;
];
].

?rtStruct rdf:type ldcm:Radiotherapy_Structure_Object;
ldcm:T30060010 [
ldcm:has_sequence_item [
ldcm:T30060012 [
ldcm:has_sequence_item [
ldcm:T30060014 [
ldcm:has_sequence_item [
ldcm:R0020000E ?ctSeries;
];
];
];
];
];
].
}
19 changes: 19 additions & 0 deletions examples/queries/dose_overview.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX schema: <https://schema.org/>
prefix ldcm-dvh: <https://johanvansoest.nl/ontologies/LinkedDicom-dvh/>
PREFIX ou: <http://purl.obolibrary.org/obo/UO_>

select ?calculation_job ?softwareUsed ?dateTime ?structureName ?sRGB ?minDose ?meanDose ?maxDose ?volumeCC
where {
?calculation_job rdf:type ldcm-dvh:CalculationResult;
ldcm-dvh:containsStructureDose ?structureDose;
schema:SoftwareApplication ?softwareUsed;
schema:dateCreated ?dateTime.

?structureDose ldcm-dvh:structureName ?structureName;
<https://www.wikidata.org/wiki/Q284140> ?sRGB;
ldcm-dvh:min [ schema:value ?minDose; ];
ldcm-dvh:mean [ schema:value ?meanDose; ];
ldcm-dvh:max [ schema:value ?maxDose; ];
ldcm-dvh:volume [ schema:value ?volumeCC; rdf:type ou:0000097; ];
}
19 changes: 19 additions & 0 deletions examples/queries/dvh_curve.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX schema: <https://schema.org/>
prefix ldcm-dvh: <https://johanvansoest.nl/ontologies/LinkedDicom-dvh/>
PREFIX ou: <http://purl.obolibrary.org/obo/UO_>

select *
where {
?calculation_job rdf:type ldcm-dvh:CalculationResult;
ldcm-dvh:containsStructureDose ?structureDose.

?structureDose ldcm-dvh:structureName "Lung_L";
<https://www.wikidata.org/wiki/Q284140> ?sRGB;
ldcm-dvh:dvh_curve ?curve.
?curve ldcm-dvh:dvh_point [
ldcm-dvh:dvh_d_point ?d_value;
ldcm-dvh:dvh_v_point ?v_value;
];
}
ORDER BY ?d_value
24 changes: 24 additions & 0 deletions examples/queries/dvh_d_point.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX schema: <https://schema.org/>
prefix ldcm-dvh: <https://johanvansoest.nl/ontologies/LinkedDicom-dvh/>
PREFIX ou: <http://purl.obolibrary.org/obo/UO_>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

select ?calculation_job (xsd:int(round(avg(?v_value))) as ?v)
where {
BIND(xsd:double(30) AS ?d_point).
BIND(xsd:double(0.01) AS ?tolerance).
BIND("Heart" AS ?structureName)

?calculation_job rdf:type ldcm-dvh:CalculationResult;
ldcm-dvh:containsStructureDose ?structureDose.

?structureDose ldcm-dvh:structureName ?structureName;
ldcm-dvh:dvh_curve ?curve.
?curve ldcm-dvh:dvh_point [
ldcm-dvh:dvh_d_point ?d_value;
ldcm-dvh:dvh_v_point ?v_value;
];
filter ((?d_value > (?d_point - ?tolerance)) && (?d_value < (?d_point + ?tolerance)))
}
GROUP BY ?calculation_job
24 changes: 24 additions & 0 deletions examples/queries/dvh_v_point.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX schema: <https://schema.org/>
prefix ldcm-dvh: <https://johanvansoest.nl/ontologies/LinkedDicom-dvh/>
PREFIX ou: <http://purl.obolibrary.org/obo/UO_>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

select ?calculation_job ((round(avg(?d_value*10))/10) as ?d)
where {
BIND(xsd:double(10) AS ?v_point).
BIND(xsd:double(0.1) AS ?tolerance).
BIND("Heart" AS ?structureName)

?calculation_job rdf:type ldcm-dvh:CalculationResult;
ldcm-dvh:containsStructureDose ?structureDose.

?structureDose ldcm-dvh:structureName ?structureName;
ldcm-dvh:dvh_curve ?curve.
?curve ldcm-dvh:dvh_point [
ldcm-dvh:dvh_d_point ?d_value;
ldcm-dvh:dvh_v_point ?v_value;
];
filter ((?v_value > (?v_point - ?tolerance)) && (?v_value < (?v_point + ?tolerance)))
}
GROUP BY ?calculation_job
Loading

0 comments on commit 155f5a4

Please sign in to comment.