Skip to content

Commit

Permalink
Added all files for slim version
Browse files Browse the repository at this point in the history
  • Loading branch information
cramraj8 committed Oct 23, 2017
1 parent 8a68d4c commit e8207b1
Show file tree
Hide file tree
Showing 23 changed files with 193,317 additions and 161 deletions.
Binary file removed Brain_Integ.mat
Binary file not shown.
1 change: 1 addition & 0 deletions Brain_Integ_X.csv

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Brain_Integ_Y.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Censored,Survival0,1440,3931,4700,2110,6910,10240,3940,4240,3180,4690,4050,3840,7171,13221,14051,2180,12290,6320,8140,4140,4660,330,3800,1500,3821,9321,1810,5060,1331,9580,3570,1080,2540,1381,2681,2731,2600,830,1141,1871,1390,1591,2370,1640,450,36670,2241,2531,3911,1451,471,1451,1510,5480,1110,4630,3330,10620,4420,4540,620,410,880,8800,5430,1190,7721,2940,1480,1240,2130,2020,5230,2440,5750,1440,3680,540,4280,5110,4551,9531,2861,4521,1671,2411,710,1540,5050,3000,7370,12330,9140,7530,4800,771,370,5440,7130,4680,1420,3860,5150,1130,3830,5851,2720,2900,300,1350,3600,60,4600,3790,1051,6361,1321,4361,2280,1380,940,1110,2790,1000,820,5190,1650,2540,1470,1530,1140,7270,10480,5671,11010,491,35740,13350,11061,18281,12221,81,16310,1940,5380,8141,15681,14281,15191,14941,14261,37331,24931,22891,14581,22180,15471,27721,13541,11121,23811,14121,5731,9191,14211,12101,11391,10211,22191,9621,7360,7751,9161,1821,9551,8351,8461,8890,4381,5631,3681,3421,5441,9351,4920,6071,9681,19431,14011,7481,12791,8461,5231,5231,7061,5481,4431,5310,2051,4071,2571,2071,55461,5761,5321,4611,64230,15850,6820,14910,22860,14010,20000,370,26600,2140,3540,40680,6050,5120,28750,34701,2421,730,3490,19151,47520,46950,4560,32000,1990,2690,35711,27610,9331,8000,3150,2421,28690,5760,18860,7881,18340,7091,12771,840,1550,7220,4441,6291,6511,5821,5161,4711,4311,10121,9081,9641,7431,7961,7600,10331,7771,6561,6780,3470,8141,5220,6480,5471,25651,15670,2280,13510,11831,170,15250,20520,12510,24330,17620,40840,23790,29070,39780,28350,1110,5920,4920,6480,7270,15780,4660,9870,11200,44450,3980,22350,9841,12011,71,61,14530,7751,15880,11201,5711,4541,12941,12571,4671,5441,6861,6271,6111,8621,4161,4331,4871,6111,4551,6851,9921,11641,3260,5591,5691,7211,4491,6551,4571,6771,8681,3281,11151,6221,5671,1741,31,2030,3510,12201,41,11,5031,1141,5301,1991,7381,1941,12271,22871,29181,32531,52551,1221,1531,9081,7051,37251,1391,5260,961,6711,13991,17061,17520,71,4341,51,4941,231,13591,1841,13001,31,9641,4551,31,31,901,5331,2101,4421,12011,5851,11891,71,15401,151,7181,11301,101,41,1121,1621,10790,1131,3431,9561,501,4941,2860,19331,30,11521,10041,3721,1901,31,141,1691,4191,71,9001,10401,4781,7921,41,6151,21,31,821,5151,551,4911,5121,6511,5331,741,3201,3361,31,17211,13820,12621,13871,20781,21071,10780,12091,12171,12941,7580,9620,3881,6300,5781,13011,4381,01,01,71,2041,2431,721,701,2871,1791,2421,2311,391,71,3171,4031,3541,3331,2741,4141,2921,2301,3721,5841,1051,721,1341,771,3841,4821,4271,5881,4511,4421,4140,3721,4081,2791,4421,4971,5091,581,5021,5081,3371,3951,27021,28601,9931,9391,1661,3011,631,5960,18911,26501,5711,12451,10760,7421,7851,9921,10691,29181,22891,41131,26021,11731,8051,5671,4281,10990,2411,7151,6081,6091,2491,621,5641,8260,51661,9140,9611,15001,5661,4541,6501,5991,4861,13411,10261,7951,7871,-11,18680,8210,9541,13971,13141,4111,30,2401,11911,7141,11271,4871,7061,15531,13931,14261,1147
Expand Down
97 changes: 97 additions & 0 deletions SurvivalAnalysis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import numpy as np


class SurvivalAnalysis(object):
""" This class contains methods used in survival analysis.
"""

def c_index(self, risk, T, C):
"""Calculate concordance index to evaluate model prediction.
C-index calulates the fraction of all pairs of subjects whose predicted
survival times are correctly ordered among all subjects that can actually
be ordered, i.e. both of them are uncensored or the uncensored time of
one is smaller than the censored survival time of the other.
Parameters
----------
risk: numpy.ndarray
m sized array of predicted risk (do not confuse with predicted survival time)
T: numpy.ndarray
m sized vector of time of death or last follow up
C: numpy.ndarray
m sized vector of censored status (do not confuse with observed status)
Returns
-------
A value between 0 and 1 indicating concordance index.
"""
n_orderable = 0.0
score = 0.0
for i in range(len(T)):
for j in range(i+1,len(T)):
if(C[i] == 0 and C[j] == 0):
n_orderable = n_orderable + 1
if(T[i] > T[j]):
if(risk[j] > risk[i]):
score = score + 1
elif(T[j] > T[i]):
if(risk[i] > risk[j]):
score = score + 1
else:
if(risk[i] == risk[j]):
score = score + 1
elif(C[i] == 1 and C[j] == 0):
if(T[i] >= T[j]):
n_orderable = n_orderable + 1
if(T[i] > T[j]):
if(risk[j] > risk[i]):
score = score + 1
elif(C[j] == 1 and C[i] == 0):
if(T[j] >= T[i]):
n_orderable = n_orderable + 1
if(T[j] > T[i]):
if(risk[i] > risk[j]):
score = score + 1

#print score to screen
return score / n_orderable

def calc_at_risk(self, X, T, O):
"""Calculate the at risk group of all patients.
For every patient i, this function returns the index of the first
patient who died after i, after sorting the patients w.r.t. time of death.
Refer to the definition of Cox proportional hazards log likelihood for
details: https://goo.gl/k4TsEM
Parameters
----------
X: numpy.ndarray
m*n matrix of input data
T: numpy.ndarray
m sized vector of time of death
O: numpy.ndarray
m sized vector of observed status (1 - censoring status)
Returns
-------
X: numpy.ndarray
m*n matrix of input data sorted w.r.t time of death
T: numpy.ndarray
m sized sorted vector of time of death
O: numpy.ndarray
m sized vector of observed status sorted w.r.t time of death
at_risk: numpy.ndarray
m sized vector of starting index of risk groups
"""
tmp = list(T)
T = np.asarray(tmp).astype('float64')
order = np.argsort(T)
sorted_T = T[order]
at_risk = np.asarray([list(sorted_T).index(x) for x in sorted_T]).astype('int32')
T = np.asarray(sorted_T)
O = O[order]
X = X[order]

return X, T, O, at_risk
2 changes: 2 additions & 0 deletions ckpt_dir/checkpoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
model_checkpoint_path: "model.ckpt-0"
all_model_checkpoint_paths: "model.ckpt-0"
Binary file not shown.
Binary file not shown.
117,427 changes: 117,427 additions & 0 deletions ckpt_dir/graph.pbtxt

Large diffs are not rendered by default.

Binary file added ckpt_dir/model.ckpt-0.data-00000-of-00001
Binary file not shown.
Binary file added ckpt_dir/model.ckpt-0.index
Binary file not shown.
Binary file added ckpt_dir/model.ckpt-0.meta
Binary file not shown.
Loading

0 comments on commit e8207b1

Please sign in to comment.