Skip to content

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
Anders-Holst committed Oct 18, 2021
0 parents commit 841aa4e
Show file tree
Hide file tree
Showing 19 changed files with 7,819 additions and 0 deletions.
23 changes: 23 additions & 0 deletions LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Copyright (C) 2018-2021 RISE Research Institute of Sweden AB

MIT License

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

35 changes: 35 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
This repository contains the code used for data analysis in the BONSAI
project (Financed by the Swedish funding agency Vinnova, 2018 - 2020).

The objective of the project was to explore methods for causal
inference for finding causal links between child cancer treatment and
late effects. The idea is to use a constraint based causal inference
method adapted for small data sets (most medical data sets are small
from a machine learning perspective), to distinguish whether a late
effect is caused by personal predisposition, the primary cancer
diagnosis, or one of the treatments for the cancer.

This repository contains two parts. One part contains the code for
arranging the data from several registers (person info, control person
info, diagnosis, treatments, in-patient care registry, out-patient
care registry, death registry, and drug prescription, into a common
file with all information about a patient or control person on one
line each. The other part contains the analysis and visualization code
based on that common file.

The actual data is not included here, since it contains sensitive
personal information and is therefore not publicly available.

All the code is "research project quality", not production quality,
which means that it is patchy, inconsistent, unclearn, not well
documented, and thus not easy to use by someone else. Neverthelsee, it
is included here for transparency of the methods used in the project.

For questions about the code and how to use reuse snippets of it in
other projects, contact Anders Holst: anders.holst@ri.se

For questions about availability of data, contact Helena Linge:
helena.linge@med.lu.se

For suggestion for future research collaboration around these issues,
you can contact any of the above.
67 changes: 67 additions & 0 deletions dataanalysis/Color.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
"""
Copyright (C) 2018-2021 RISE Research Institute of Sweden AB
File: Color.py
Author: anders.holst@ri.se
"""

import numpy as np

def colorgamma(x):
if x < 0.0031308:
return x*12.92
else:
return 1.055 * np.power(x, 0.416667) - 0.055

def invcolorgamma(x):
if x < 0.04045:
return x / 12.92
else:
return np.power((x + 0.055)/1.055, 2.4)

def rgb_color(r, g, b):
return tuple(list(map(colorgamma, [r,g,b])))

# mimics color.scm with 6color, bluebased, and smooth
def hsl_color(h, s, l):
hramp = [0, 1/12, 1/6, 1/3, 2/3, 7/9, 1]
iramp = [(2.410996, 0.16, 0, 0, 1), (0.862552, 0.79, 0, 1, 1),
(-0.252442, 0.63, 0, 1, 0), (-1.981885, 0.84, 1, 1, 0),
(1.786451, 0.21, 1, 0, 0), (1.571190, 0.37, 1, 0, 1),
(2.410996, 0.16, 0, 0, 1)]
i = 0
while h > hramp[i+1]:
i += 1
p = (h - hramp[i])/(hramp[i+1] - hramp[i])
(a, br, r, g, b) = tuple(map(lambda x1, x2: p*(x2 - x1) + x1, iramp[i], iramp[i+1]))
ll0 = (l + 1.0)*0.5
ll = (np.exp(a*ll0) - 1.0)/(np.exp(a) - 1.0) if not a==0 else ll0
if ll < br:
t1 = s * ll / br
t2 = ll0 * (1.0 - s)
else:
t1 = s * (1.0 - ll) / (1.0 - br)
t2 = ll0 * (1.0 - s) + s * (ll - br) / (1.0 - br)
return rgb_color(r*t1+t2, g*t1+t2, b*t1+t2)

def gencolor(light=0.0, starthue=0.0, startsat=1.0, unsat=False):
h = starthue
s = startsat
if unsat:
ss = s*s
l = light
gs1 = (3.0 - np.sqrt(5))/2.0
gs2 = gs1/np.sqrt(3)
while True:
yield hsl_color(h, s, l)
h -= gs1
if h < 0.0:
h += 1.0
if unsat:
ss -= gs2
if ss <= 0:
ss += 1.0
s = np.sqrt(ss)

Loading

0 comments on commit 841aa4e

Please # to comment.