Skip to content

Instantly share code, notes, and snippets.

@jvsoest
jvsoest / right-censored-to-binary.sparql
Last active January 7, 2022 10:59
SPARQL right-censored to binary
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
prefix ncit: <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#>
prefix snomedct: <http://purl.bioontology.org/ontology/SNOMEDCT/>
prefix roo: <http://www.cancerdata.org/roo/>
INSERT {
GRAPH <http://inferred-manually.local/> {
?patient roo:survival_5_years ?survival_5y.
}
@jvsoest
jvsoest / disableUSBC-PD.sh
Last active March 8, 2023 00:04
Disable USB-C PD on NUC10i5(FNH) to reduce CPU load
# 2020-11-9: Solved in recent Ubuntu updates, not needed anymore, only for historical purposes available.
#
# Script to disable USB-C PD controller with nuc10
# See: https://community.intel.com/t5/Intel-NUCs/NUC10i3-IRQ-problem/td-p/669863?profile.language=it
# https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1883511
processActive=$(pgrep -l irq/65-i2c-INT3 | wc -l)
if [ "$processActive" -gt "0" ]; then
echo "stopping USB-C PD controller"
@jvsoest
jvsoest / ct_rtstruct_retrieval.sparql
Last active January 7, 2020 15:41
SEDI retrieval of CT and RTStruct information
PREFIX sedi: <http://semantic-dicom.org/dcm#>
PREFIX seq: <http://semantic-dicom.org/seq#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
select DISTINCT ?patientID ?studyUID ?seriesUID ?modality ?manufacturer ?model ?softwareVersion ?sopInstanceUID ?sliceThickness ?contourName ?refSeriesUID
where {
# Get patient & ID
?patient rdf:type sedi:Patient.
@jvsoest
jvsoest / doiRetrieve.sh
Created December 28, 2019 16:02
DOI metadata retrieval
# retrieve as reference text
curl -LH "Accept: text/bibliography" http://dx.doi.org/10.1016/j.radonc.2014.04.008
# retrieve as bibtex
curl -LH "Accept: text/bibliography; style=bibtex" http://dx.doi.org/10.1016/j.radonc.2014.04.008
# retrieve as bibtex (url-safe)
curl -LH "Accept: application/x-bibtex" http://dx.doi.org/10.1016/j.radonc.2014.04.008
@jvsoest
jvsoest / service.py
Created January 17, 2018 20:08
Python image service
from flask import Flask, render_template, request, url_for
import os
if not os.path.exists("static"):
os.makedirs("static")
app = Flask('ImageShow', template_folder='')
@app.route('/', methods=['GET', 'POST'])
def index():
@jvsoest
jvsoest / example_sparql.sparql
Last active December 4, 2017 13:34
example_sparql
prefix roo: <http://www.cancerdata.org/roo/>
prefix ncit: <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix icd: <http://purl.bioontology.org/ontology/ICD10/>
prefix uo: <http://purl.obolibrary.org/obo/UO_>
SELECT *
WHERE {
?patient rdf:type ncit:C16960.
@jvsoest
jvsoest / fhir_dlra_query.sparql
Last active November 20, 2017 07:11
FHIR query DLRA
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix fhir: <http://hl7.org/fhir/>
SELECT ?subject ?givenName ?prefixName ?familyName ?procedure ?codeValue ?systemValue ?uriTerm ?uriLabel ?superTerm ?superLabel
WHERE {
#get the procedure
?procedure rdf:type fhir:Procedure;
fhir:Procedure.code ?pCode;
fhir:Procedure.subject ?bnode_subject.
@jvsoest
jvsoest / patient_protocol_trial_publications.sparql
Last active October 15, 2017 16:42
One query to retrieve patient information, disease and treatment characteristics, trials matching the treatment characteristics, and the link to publications linked to these trials. Hence, we can find publications related to the disease and treatment of specific patients (via the treatment protocols and clinical trials).
prefix roo: <http://www.cancerdata.org/roo/>
prefix ncit: <http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix icd: <http://purl.bioontology.org/ontology/ICD10/>
prefix uo: <http://purl.obolibrary.org/obo/UO_>
prefix dcterm: <http://purl.org/dc/terms/>
prefix ctvoc: <http://bio2rdf.org/clinicaltrials_vocabulary:>
prefix ctres: <http://bio2rdf.org/clinicaltrials_resource:>
prefix ct: <http://bio2rdf.org/clinicaltrials:>
@jvsoest
jvsoest / xnat.py
Created July 24, 2017 13:12
XNAT python
###### login to XNAT and search/get files ########
import xnat
session = xnat.connect('https://xnat.bmia.nl', user='bla')
session.projects
project = session.projects['STW_STRATEGY_HN_VELLORE']
subject = project.subjects['BMIAXNAT_S08453']
experiment = subject.experiments['BMIAXNAT_E28844']
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix icd: <http://purl.bioontology.org/ontology/ICD10/>
prefix uo: <http://purl.obolibrary.org/obo/UO_>
prefix sedi: <http://semantic-dicom.org/dcm#>
prefix seq: <http://semantic-dicom.org/seq#>
SELECT ?dicom_series ?institute ?machine ?anatomicRegionSeq
WHERE {
?patient sedi:hasStudy ?dicom_study.