####################################################################### # PREDICTION OF TEMPORAL LOBE EPILEPSY LATERALITY BASED ON PET ASYMMETRIES # # The script uses the asymmetry dataset obtained by Pustina et al. # to compute TLE laterality in new patients based on three PET variables. # # USAGE: # (Windows): # source('https://raw.githubusercontent.com/dorianps/TLEprediction/master/TLEpredict.R', echo=F) # # (Linux/Mac) # Install RCurl the first time: install.packages("RCurl") # Then run command: # library(RCurl) ; eval( expr = parse( text = getURL("https://raw.githubusercontent.com/dorianps/TLEprediction/master/TLEpredict.R", ssl.verifypeer=FALSE) )) # # Enter requested values and obtain the classification # # Author: Dorian Pustina # Date: February 3, 2015 # x= as.numeric(readline("Assymetry for PET-mesial: ")) y= as.numeric(readline("Assymetry for PET-hippo-var: ")) z= as.numeric(readline("Assymetry for PET-entire-var: ")) boots = as.numeric(readline("Number of bootstraps (i.e., 10000): ")) # number of bootstraps exclude = as.numeric(readline("Exclude cases from training (0=none, 1=Engel class III/IV, 2=non-operated, 3=1+2): ")) # exclusions imaging <- structure(list(PET_hippo = c(-0.01423, -0.0165, 0.010511, -0.011127, -0.053409, 0.009932, -0.0272, -0.010797, 0.080289, 0.01163, 0.035659, -0.0064011, -0.004556, -0.0123, 0.022165, -0.0061811, 0.031489, -0.030862, -0.058705, -0.15021, 0.0511, -0.091786, 0.071647, -0.002404, 0.080814, 0.021655, -0.014016, -0.035835, -0.05632, -0.0072124, -0.0053603, -0.0046566, 0.030146, -0.090677, 0.023569, -0.028362, 0.068646, 0.0076274, -0.0057939, -0.0036179, 0.019783, -0.019175, 0.0054053, 0.013219, 0.1029, 0.014729, 0.017446, 0.026747, -0.085262, 0.0042082, -0.013868, -0.023976, 0.062912, 0.066161, 0.1013, 0.016076, -0.067584, 0.074324), PET_entire = c(-0.025674, -0.033558, 0.024258, 0.023566, 0.0055291, 0.00095068, -0.071, 0.036176, 0.056921, 0.013154, 0.018201, -0.022361, -0.014512, 0.02942, 0.037256, -0.027969, 0.068381, -0.060948, 0.00083096, -0.18438, 0.08785, -0.041693, 0.085354, 0.0016458, 0.045182, 0.021427, -0.034682, -0.013598, -0.074541, -0.02542, 0.0084866, -0.033023, 0.083309, -0.064212, 0.028768, -0.048679, 0.069027, -0.0065073, -0.039237, -0.02409, -0.06574, -0.088034, -0.011102, 0.026579, 0.023509, 0.024969, 0.014355, 0.048811, -0.054226, 0.030456, -0.059187, -0.031194, 0.0020573, 0.061957, 0.054047, 0.019925, -0.045064, 0.060082), PET_lateral = c(-0.029781, -0.039946, 0.023992, 0.029326, 0.0045688, 0.005949, -0.074288, 0.040807, 0.066386, 0.0095061, 0.0098803, -0.028363, -0.019752, 0.039897, 0.041842, -0.028938, 0.068342, -0.063991, 0.0034947, -0.18419, 0.09655, -0.024234, 0.056784, -0.0028331, 0.037358, 0.022444, -0.042058, -0.027845, -0.085622, -0.065283, 0.010199, -0.041419, 0.087875, -0.069101, 0.025215, -0.051305, 0.074867, -0.014259, -0.042283, -0.024779, -0.045231, -0.098122, -0.015475, 0.020751, 0.016856, 0.025342, 0.01273, 0.058198, -0.056869, 0.0255, -0.065666, -0.03239, 0.00056105, 0.068663, 0.061747, 0.019126, -0.049343, 0.066209), PET_mesial = c(-0.014455, -0.021432, 0.015352, 0.0048865, -0.02363, 0.0020815, -0.036371, 0.0026924, 0.05541, 0.012675, 0.034535, -0.0050629, 0.00095766, -0.0083881, 0.021521, -0.006731, 0.046278, -0.028708, -0.035685, -0.21535, 0.037333, -0.067602, 0.05266, 0.022374, 0.053693, 0.032013, -0.0055168, -0.027567, -0.032148, -0.0172, -0.0070926, -0.01273, 0.048691, -0.074756, 0.041476, -0.033124, 0.052435, 0.0022478, -0.021719, -0.015938, -0.0018688, -0.030485, 0.0064118, 0.010647, 0.057585, 0.012689, 0.018916, 0.020662, -0.073821, 0.011038, -0.028175, -0.025136, 0.039217, 0.048035, 0.070749, 0.018742, -0.041936, 0.046548), PET_hippo_var = c(-0.15254, -0.0010076, 0.12539, -0.0022983, 0.081233, -0.065898, -0.1406, 0.05417, 0.38082, 0.11809, 0.22863, 0.19277, 0.05953, -0.10675, -0.040185, -0.050838, 0.27397, -0.021394, -0.20898, 0.21265, 0.18085, 0.10037, 0.47728, 0.15924, 0.19486, 0.12446, 0.071998, 0.0041989, -0.4435, 0.29464, -0.082656, -0.12054, 0.12107, -0.27006, 0.090666, -0.066249, 0.21231, -0.15395, -0.21161, 0.027873, 0.51658, -0.0045378, -0.03269, 0.12681, 0.096427, -0.10878, 0.050819, -0.032297, -0.29957, 0.066417, -0.031231, -0.17374, 0.27574, 0.36462, 0.53574, 0.29056, -0.30401, 0.51221), PET_entire_var = c(-0.012978, -0.093985, 0.036367, -0.15842, 0.020975, 0.015028, -0.097427, 0.2525, 0.14256, -0.020601, -0.11668, -0.21464, -0.076864, 0.21011, 0.084681, -0.19978, 0.10837, -0.19568, 0.0039431, 0.17478, 0.071462, 0.30798, 0.12741, -0.051366, 0.003842, 0.012206, -0.11331, -0.061657, -0.15498, -0.17436, 0.018537, -0.13282, 0.21366, -0.15018, -0.096617, 0.0069858, 0.20524, -0.10622, -0.23131, -0.14078, 0.23591, -0.21241, -0.12724, 0.026664, -0.084402, 0.051929, 0.038945, 0.17396, 0.0049915, 0.11795, -0.21326, -0.00097987, -0.11299, 0.062958, -0.0050324, -0.014107, -0.093667, 0.093238), PET_lateral_var = c(0.096813, 0.0047109, -0.0087175, -0.26256, -0.10146, -0.022982, 0.13598, 0.21426, 0.075632, -0.021606, -0.095277, -0.23749, -0.00042584, 0.061131, 0.049502, -0.20023, 0.0077783, -0.13673, -0.18175, 0.25734, -0.10477, 0.40358, 0.19801, 0.013144, 0.01602, 0.00079974, -0.10728, 0.053574, 0.16129, -0.5533, -0.037651, -0.027005, 0.1295, -0.16825, -0.11161, 0.13948, 0.14241, -0.054354, -0.29304, -0.12034, 0.32596, -0.047394, -0.091937, -0.016981, 0.060322, 0.011811, 0.10086, 0.089197, 0.040324, 0.08573, -0.083216, 0.068177, -0.074802, -0.10629, -0.090353, -0.036733, -0.048548, -0.012034), PET_mesial_var = c(0.034213, -0.033946, 0.1276, -0.1391, -0.0073529, 0.053783, -0.10207, 0.06427, 0.19102, 0.048901, 0.086718, 0.16727, -0.13481, -0.033948, -0.13618, -0.067015, 0.2464, -0.15744, -0.028274, -0.03148, 0.13683, 0.35867, 0.27714, -0.093497, 0.21097, 0.19372, 0.037765, -0.16088, -0.28712, 0.30357, -0.059985, -0.041764, 0.04773, -0.1223, -0.17862, -0.081261, 0.12974, -0.0052968, 0.050039, -0.1821, 0.063404, -0.10966, -0.050198, 0.10678, -0.31052, -0.10673, -0.030237, 0.054298, -0.044654, 0.085657, -0.23437, -0.12712, 0.12193, 0.30848, 0.22688, -0.013898, -0.042523, 0.12811), PET_hippo_kurt = c(-0.019739, -0.077548, 0.012155, 0.049786, 0.085059, 0.0096017, -0.040165, -0.032947, 0.049803, 0.051779, -0.049104, -0.092842, -0.038871, -0.028917, 0.033277, 0.036568, -0.022474, -7.493e-05, -0.069115, -0.2808, -0.1016, 0.20696, -0.13572, -0.084836, -0.095097, -0.0042535, -0.14872, -0.038106, 0.10234, 0.10831, -0.047052, 0.073892, -0.087879, 0.027332, 0.04985, 0.018732, -0.014214, -0.014947, 0.017147, -0.055631, 0.011427, -0.030865, -0.043208, 0.010168, -0.14829, 0.047029, -0.0019778, -0.064245, 0.094595, -0.031051, -0.073432, -0.0043681, -0.024831, -0.068776, -0.10282, -0.026412, 0.12373, -0.033824), PET_entire_kurt = c(0.032169, 0.031384, 0.024498, 0.057498, 0.037169, 0.021643, 0.072705, -0.085124, -0.037677, -0.027505, 0.02601, 0.074115, 0.05501, -0.082651, 0.045477, -0.024811, 0.036563, 0.14127, 0.0048482, -0.15875, -0.33427, 0.037051, 0.0071387, 0.090577, 0.072332, -0.031017, 0.019622, 0.010026, 0.14157, -0.073066, -0.058761, 0.063244, -0.095999, -0.017387, 0.034979, -0.02323, -0.055404, 0.055493, 0.12249, 0.023334, 0.13864, 0.3747, 0.035542, -0.043176, -0.031363, 0.022044, -0.055023, -0.00024561, -0.0098692, -0.0030999, 0.087396, 0.11981, 0.048662, -0.027759, 0.028821, -0.064073, -0.0031889, -0.12293), PET_lat_kurt = c(0.031064, -0.056832, 0.040537, 0.19595, 0.04765, -0.017121, -0.0059737, -0.044035, -0.037044, -0.036666, -0.034788, -0.052085, 0.019662, -0.044465, 0.081344, -0.059453, 0.091598, 0.10574, -0.015075, -0.23813, -0.24387, 0.17179, 0.015599, 0.22092, -0.0087868, -0.0011363, 0.010413, 0.064072, 0.07013, 0.10305, -0.042363, 0.037234, -0.031539, -0.15946, 0.01872, -0.099871, -0.026443, -0.070535, -0.035057, -0.079677, 0.20305, 0.25851, 0.051217, 0.009186, -0.0073756, -0.0057643, -0.023581, 0.089822, -0.055931, -0.062349, 0.033607, 0.061861, 0.010992, 0.066167, -0.040575, -0.036207, -0.075886, -0.092859), PET_mes_kurt = c(0.1289, 0.029064, -0.061356, 0.11958, -0.12946, 0.033193, 0.020877, -0.00066834, -0.17528, -0.021815, -0.12026, -0.010936, -0.039323, -0.077873, -0.038598, 0.048408, -0.053191, -0.10643, 0.022441, 0.042148, 0.021022, 0.19545, -0.046106, -0.13574, 0.081785, 0.065335, -0.065307, 0.0019372, -0.037984, -0.042256, -0.053153, -0.039849, -0.15185, -0.037162, 0.074478, -0.036523, -0.0033164, -0.01701, 0.059896, 0.011327, 0.057016, -0.065741, -0.0092696, 0.10698, -0.025677, 0.035587, 0.029243, -0.070118, 0.086039, -0.025686, -0.24558, 0.027703, 0.015872, -0.037155, -0.0089828, -0.10862, 0.13698, -0.12894), PET_hippo_skew = c(0.18572, 0.57374, -0.020771, -0.17287, 1, -0.58215, 0.63604, 0.30527, -1, 0.45082, -0.59339, -0.06108, -0.16224, -0.86289, 0.069048, -0.42254, -1, 0.80513, 1, 0.75009, -1, 1, 0.10192, -0.58968, -1, -1, 1, 1, -0.29859, 0.7188, -1, -0.16942, 0.019134, 1, -0.76162, 0.83931, -1, -1, 0.013588, 0.049929, -0.54001, -0.36756, -1, 0.32795, -1, -0.71502, -0.60012, -0.70407, 1, 1, 0.41144, -0.42861, -1, -1, -1, 0.19778, 1, -0.53717), PET_entire_skew = c(1, 1, -0.60466, 0.029957, -0.32493, 0.14408, 1, -1, -0.2188, -1, -0.58209, -0.053818, 1, -1, 0.15458, 0.34724, -1, 0.98909, -0.87134, 1, -0.82769, -0.20776, -0.48106, -0.75843, -0.33519, -0.77715, 0.33487, -0.30898, 1, -1, -0.49692, -0.050929, -0.41374, 1, 1, 1, -0.49769, 0.50369, 0.04072, 1, -0.10587, 1, -1, -1, 0.83209, 0.39723, 0.22969, -0.39961, 1, 0.2742, 1, 0.68335, 0.39573, -1, -0.60053, -0.63586, 1, -0.88068), PET_lat_skew = c(0.52181, 1, 0.021639, -0.078453, 0.037095, 0.31079, 1, -0.3222, 0.13476, -0.20973, 0.054262, 0.30397, 0.12556, -0.52816, -0.049772, 0.1772, -1, 1, -0.10969, 1, -0.96563, -0.37509, -0.69305, -0.53238, 0.44032, -0.34444, 1, -0.34565, 1, -0.053765, -0.51982, -0.028499, -0.48497, 1, 0.83632, 1, -0.14863, 0.48788, 1, 0.5989, -0.33714, 1, -0.18631, -0.5839, 1, 0.40013, -0.087382, -1, 0.31011, 0.89725, 1, 1, 0.20037, -1, 1, -1, 0.77831, -1), PET_mes_skew = c(0.40092, -0.23704, 0.12801, -0.065086, -0.27855, 0.21123, 1, 1, 0.12439, 1, -0.25789, -0.11495, -1, -1, -0.51348, -0.33032, 0.56338, 0.17981, 0.62237, 1, -1, 0.83588, 1, 1, -0.01326, 1, 0.55649, 0.99392, 0.36024, 0.003175, -1, 0.55311, 0.69907, 0.20113, -1, -1, -0.58698, -1, -1, -0.90052, -0.70005, -0.91178, -1, 1, -0.26355, -0.70158, 1, 0.56798, 1, 0.73306, -1, -0.27315, -0.76427, 0.21057, -0.46898, -0.3064, 1, -1), THICK_lat_Frees = c(0.047, 0.048, 0.002, 0.015, 0.017, -0.004, 0.036, 0.045, -0.057, 0.066, 0.022, 0.057, 0.04, 0.023, 0.002, 0.007, 0.035, -0.003, -0.064, 0.034, -0.018, -0.09, 0.032, -0.022, 0.117, -0.024, 0.02, 0.036, -0.117, -0.049, 0.072, 0.026, 0.026, 0.056, -0.066, 0.017, 0.007, 0.045, -0.028, -0.028, 0.181, 0.062, -0.021, 0.042, 0.056, -0.041, 0.007, 0.043, -0.027, 0.053, 0.071, 0.049, 0.103, -0.022, -0.001, -0.025, 0.03, 0.102), AMYG_vol = c(0.089067323, 0.226840035, 0.025180711, 0.003813994, 0.301950806, 0.094999443, 0.333138808, 0.107763059, 0.185850228, 0.231348609, 0.14384858, 0.309001098, 0.149807295, 0.003512009, 0.047424992, 0.413029231, 0.035605051, 0.25376176, -0.134543841, 0.074156395, 0.001297419, -0.364083446, 0.108275227, 0.086885246, 0.137931034, -0.095865633, -0.041051754, -0.050991501, -0.239456296, -0.037608757, 0.041972581, 0.257431249, -0.145730133, -0.12948841, -0.121610129, 0.141838505, 0.124169967, -0.077756762, 0.308311748, 0.159652476, 1.62773224, 0.294206332, 0.161665555, 0.040352823, 0.376444383, 0.032806622, 0.288441348, 0.116790705, -0.144229326, 0.138916284, 0.361243607, 0.146444355, 0.287459337, 0.09827568, 0.190866904, 0.11626512, 0.278404135, 0.406044939), HIPPO_vol = c(0.032387179, 0.023590312, -0.018489254, -0.090373438, -0.282885347, 0.089968403, 0.04279106, -0.08758222, 0.447072163, 0.028944962, -0.090835915, 0.058981755, 0.144344139, -0.139703422, -0.111843335, 0.074505812, 0.098575331, 0.000170588, -0.320330037, -0.434757008, -0.088789695, -0.602766914, 0.202203516, -0.021181616, 0.293126487, 0.001047334, 0.158456604, -0.493554047, -0.319882022, 0.138288733, -0.015232857, 0.099576294, -0.016180723, -0.25731592, 0.019692072, 0.171133113, 0.353145027, 0.124827513, 0.160580443, 0.077216889, 1.351284947, 0.033854675, 0.003976383, -0.062303751, 0.201811401, -0.026472431, -0.022095344, 0.200007234, -0.421657762, 0.005096554, 0.072281332, 0.014672423, 0.399580548, 0.337399214, 0.514954101, -0.020429161, -0.33826253, 0.428434676), THICK_mes_Frees = c(0.057, -0.011, 0.03, -0.034, -0.028, -0.09, -0.034, -0.133, 0.042, 0.074, 0.111, -0.026, 0.143, 0.049, 0.094, 0.248, 0.106, -0.032, 0.093, -0.086, -0.01, -0.153, -0.069, -0.125, 0.016, -0.036, 0.062, -0.13, -0.054, 0.066, -0.08, -0.14, -0.207, -0.092, 0.092, -0.005, 0.016, 0.093, 0.146, 0.09, 0.594, -0.064, -0.03, -0.015, -0.027, -0.089, 0.051, 0.061, -0.066, -0.066, -0.009, -0.011, -0.064, -0.11, 0.137, -0.115, 0.013, 0.024 ), THICK_lat_Ants = c(0.00703909, 0.019074047, -0.006570182, 0.035316987, -0.028198638, -0.025334834, -0.051340491, 0.010611405, -0.071407633, 0.007648241, -0.035770341, -0.021104717, 0.016981362, -0.035999683, -0.091581026, -0.010014706, -0.017829421, 0.011707891, -0.040551611, -0.028834133, -0.109456996, 0.069805569, 0.028945293, -0.040305072, -0.044156691, -0.04481962, -0.031122852, -0.009935915, -0.084035805, -0.023723533, 0.0104907, 0.054186451, -0.035787789, -0.020347684, -0.055377901, -0.023035416, 0.008867609, 0.016071883, 0.027030015, -0.029329, -0.026520889, 0.002353479, -0.018344035, 0.037251868, 0.016030261, -0.04417866, -0.011911554, -0.005350962, -0.050620273, -0.029338542, -0.022688379, -0.003064652, -0.039783302, -0.092889434, -0.056694391, -0.042681285, -0.012414549, -0.049922576 ), THICK_lat_Ants_var = c(-0.058038355, -0.021115928, -0.150462663, -0.026449611, -0.020916575, -0.031472172, -0.162095183, -0.065927572, 0.111302007, -0.006621336, -0.061940058, -0.086980505, -0.025325213, -0.045728974, -0.169938089, 0.096271619, -0.067109187, 0.061706573, -0.034550154, -0.131464549, -0.448270756, 0.077413933, 0.157119269, -0.108569716, -0.178204184, 0.010727346, -0.032684456, 0.036946461, -0.111104423, -0.06177975, -0.021998998, 0.045132191, -0.222263466, -0.033707652, -0.280756037, 0.057768661, 0.073112011, -0.047274943, -0.157513749, 0.041583495, -0.042079699, -0.053101957, 0.007107384, -0.034877132, 0.084985643, -0.229377511, 0.012634506, -0.110343977, -0.07907222, -0.050245855, -0.219590853, -0.025686898, -0.181386397, -0.117727019, -0.230801066, -0.073515528, 0.018629388, -0.085826292 ), THICK_lat_Ants_skew = c(-0.778275613, -1, -0.885269046, -0.324448613, 1, 0.224854408, -0.481474956, 0.566332179, 1, -1, 1, 1, 0.576193766, 0.285010839, -0.271033068, 0.156728195, -0.701931505, 0.893935101, 0.233566014, -1, -1, 0.114168773, -0.049500566, 0.113588722, -0.221856462, 1, 0.4436202, -0.486291723, -0.838457757, -0.009263801, 0.933374954, -1, 0.666549172, 1, -1, 1, 0.818179416, 0.356928865, -0.821644799, 1, -0.098321037, 0.31633294, 1, -1, -1, -1, 1, 0.542579631, -0.74709545, 1, -0.727454162, 1, 1, 0.606726282, -1, 0.202029732, 0.330408195, 0.231941603), THICK_lat_Ants_kurt = c(0.008501528, -0.036846829, -0.015685479, -0.147938851, 0.028049403, 0.033552774, 0.002024066, 0.016138362, 0.018035911, -0.021168363, -0.046404286, 0.122891665, 0.021233576, 0.01483361, -0.106125539, -0.118252288, -0.070013889, 0.119364365, 0.009410466, 0.000150747, -0.151070275, 0.101443691, -0.004863813, 0.011016053, -0.120284387, 0.038521319, 0.085499601, -0.065938336, -0.09781457, 0.16008198, -0.005218711, -0.087953234, 0.067884567, -0.024130415, -0.113083616, 0.055194965, 0.023759639, -0.001058998, 0.083495792, 0.0009956, 0.040535139, 0.082497089, 0.033867464, -0.127222451, -0.045641469, 0.052400093, 0.125018877, 0.044913395, -0.056317258, 0.054562371, 0.036359217, -0.062467432, 0.08404627, -0.03041352, 0.01351702, -0.010289347, 0.063113279, -0.038662815), THICK_mes_Ants = c(0.034083302, 0.001977194, 0.043643962, 0.017133409, 0.028452759, 0.024554546, -0.049401443, 0.02836936, -0.031796312, 0.025190062, 0.058758664, -0.017998744, 0.131611053, -0.034177957, 0.005941385, 0.092493092, -0.048029432, 0.059493957, -0.011804762, 0.020196059, 0.023916861, 0.109813181, -0.033202262, -0.066738136, 0.021809239, 0.007861104, 0.09735192, -0.041598948, -0.102269518, 0.082784914, -0.017712431, -0.038254926, 0.019414859, -0.004693358, -0.020659377, 0.084861438, -0.005486811, 0.061357751, -0.00206199, -0.000678412, 0.012719842, 0.003558221, 0.019531833, 0.002301914, 0.043646913, -0.005837593, 0.020076161, 0.014358062, -0.065524007, 0.027603917, 0.025264432, 0.003084525, 0.032472291, -0.025585685, -0.056831097, 0.018245528, 0.031550809, 0.000892449), THICK_mes_Ants_var = c(-0.027344542, -0.001186761, -0.070167018, -0.158506137, -0.036412197, -0.117252308, 0.261334483, 0.120219556, 0.20530882, -0.11980177, 0.022357644, -0.136774468, 0.11571771, -0.035987453, -0.142765292, -0.070224661, 0.034952665, 0.09103049, -0.174437376, -0.232035893, 0.106024683, 0.156548741, 0.045613782, 0.127304961, -0.218910483, 0.011738175, 0.159436127, -0.057212211, -0.038976142, 0.095816242, 0.050466017, 0.110409188, -0.065710899, 0.143352396, -0.468110348, 0.127068855, 0.012783099, 0.206185824, 0.071956196, 0.127407921, 0.197280481, 0.226170759, 0.007250481, -0.059131942, 0.049557245, -0.083869006, 0.073073075, -0.199304997, -0.080422803, 0.193480027, 0.124057263, 0.031958542, 0.183410226, 0.059575252, -0.311611033, 0.029168456, 0.090584886, 0.125541357), THICK_mes_Ants_skew = c(0.948195692, 1, -0.098507031, -1, 1, -0.210866152, 1, 0.210000701, 1, 0.088550064, -0.126365271, 1, -0.127507044, 0.109385624, -1, -0.729439533, 0.161778097, 1, 1, -1, 0.115965677, -1, -0.18962506, 1, -0.860671702, 0.197720539, -0.025770109, 0.26904349, 0.574661741, 0.883732619, 0.40307164, 0.381369463, -0.156799753, 0.019187528, -1, 0.030974113, 1, 1, 1, 0.32304806, 1, 1, 1, -0.867767804, 1, -0.812162284, 0.482622645, -1, 0.288264923, 1, 1, 0.503260472, 0.13265517, 0.352828421, 0.227615201, 0.194262058, 0.04125517, 0.648036755 ), THICK_mes_Ants_kurt = c(-0.019170904, 0.138853543, -0.031650152, -0.117709355, -0.016225013, 0.050492849, -0.05313177, 0.089694656, -0.011476199, 0.06143361, -0.026912802, 0.048015905, -0.018370901, 0.078989172, -0.107210752, -0.096321015, 0.123202042, 0.106787521, -0.072448831, 0.153394457, 0.018885923, -0.148649855, -0.071362684, -0.072480568, -0.014964588, 0.078258885, -0.045323633, 0.101511349, 0.069104288, 0.184901806, -0.02450212, -0.110671004, -0.062197539, -0.058766811, -0.021598411, -0.138066076, -0.056474306, -0.083704578, 0.081356982, -0.021762753, -0.004576725, -0.005865036, -0.019351599, 0.060216803, 0.006782131, -0.037496309, 0.068100157, -0.053973962, 0.10299181, 0.012134163, -0.068276701, 0.135558874, 0.006623711, 0.190587688, 0.097551302, 0.083384432, -0.019588809, 0.095148607 ), THICK_entire_Ants = c(0.009965908, 0.016909897, -0.002341355, 0.03493525, -0.02358713, -0.020342192, -0.050825013, 0.012032427, -0.066938322, 0.009473439, -0.024987449, -0.020648281, 0.031646232, -0.035388472, -0.079819028, -0.002914726, -0.020352847, 0.016364941, -0.037868559, -0.023368455, -0.099618138, 0.076209206, 0.021386854, -0.042902657, -0.038437083, -0.039997866, -0.020349012, -0.01382794, -0.082780883, -0.010755774, 0.00786923, 0.043364622, -0.029606948, -0.018927647, -0.052043662, -0.012589488, 0.00682701, 0.01880761, 0.024195247, -0.025573663, -0.023474215, 0.002465665, -0.014435663, 0.033453347, 0.018933454, -0.040497126, -0.008859391, -0.002759193, -0.052226854, -0.023176563, -0.017843928, -0.002703786, -0.033969441, -0.086132854, -0.056798983, -0.037433889, -0.007483394, -0.04565006 ), THICK_entire_Ants_var = c(-0.046812801, -0.023281607, -0.145109149, -0.042158978, -0.018010275, -0.032193244, -0.124420639, -0.046276005, 0.125116067, -0.01770341, -0.030623485, -0.091410591, 0.047410896, -0.042978905, -0.129367218, 0.072292961, -0.061507953, 0.073340849, -0.046594867, -0.130035638, -0.418418478, 0.126136247, 0.119894075, -0.082190358, -0.160466411, 0.016266761, 0.015212551, 0.003553256, -0.099555035, -0.001163176, -0.016108826, 0.029434427, -0.179962831, -0.019476171, -0.297182007, 0.064175851, 0.059571681, -0.027308737, -0.143042622, 0.065822823, -0.007819453, -0.018172001, 0.013852472, -0.040276733, 0.085544276, -0.213747473, 0.02879924, -0.1139031, -0.079174246, -0.004189833, -0.175168803, -0.020572631, -0.155259181, -0.091278242, -0.239580806, -0.062452422, 0.036167115, -0.06151225), THICK_entire_Ants_skew = c(-0.89253763, -1, -0.561117831, -0.422712803, 1, 0.293004172, -0.231016133, 1, 1, -1, 0.529773395, 1, 0.427235972, 0.196334251, -0.141736699, 0.084180207, -1, 1, 0.42123354, -1, -1, 0.091122398, -0.153338644, 0.477897409, -0.277859227, 1, 0.54893652, -0.425634234, -0.179500298, 0.210261796, 1, -1, 0.470330576, 0.637097521, -1, 1, 1, 0.440174906, -0.611773578, 1, 1, 0.455031817, 1, -1, -1, -1, 0.799218418, 0.339212957, -1, 1, -0.442521624, 1, 1, 1, -1, 0.467875176, 0.315052812, 1), THICK_entire_Ants_kurt = c(0.019753381, 0.009497487, -0.005677318, -0.143979287, 0.034723918, 0.025778658, 0.020010197, 0.031204711, 0.022027526, -0.00474585, 0.027300987, 0.102599834, 0.187783636, 0.02567368, -0.078248004, -0.070562703, -0.028633634, 0.106559454, 0.002371321, 0.009306341, -0.113112062, 0.025613401, -0.07194213, 0.019323475, -0.112501308, 0.069854111, 0.109097593, -0.063793087, 0.033635822, 0.222186164, -0.007710967, -0.061174068, 0.101367204, -0.019342764, -0.079263762, 0.036929285, 0.004521953, -0.007702437, 0.072729573, 0.042222608, 0.079266999, 0.073719566, 0.021691773, -0.072185875, -0.024966221, 0.030867892, 0.1255542, 0.011361666, -0.03485115, 0.061945398, 0.029611363, -0.025038007, 0.049036419, 0.041207424, 0.023130659, 0.010047098, 0.063977193, 0.002737684), DTI_FA_fx = c(-0.03248, -0.13216, -0.07953, -0.10292, -0.00836, -0.02533, 0.02733, 0.12116, -0.04895, -0.04247, 0.00632, -0.03884, 0.05349, -0.09448, -0.04926, 0.00723, 0.08361, -0.06693, -0.02353, 0.05786, -0.1332, -0.02115, -0.0131, -0.02541, 0.06587, -0.03319, -0.00878, 0.03259, -0.0024, 0.06109, 0.03824, -0.05889, 0.07139, -0.06602, 0.04438, -0.00336, -0.00856, 0.04094, 0.04091, 0.04618, -0.06975, -0.04918, -0.06109, -0.00486, 0.01175, 0.04705, -0.00741, -0.06673, -0.04076, -0.04141, -0.03316, -0.07077, 0.07947, 0.04048, 0.05456, 0.03116, -0.08557, 0.06579 ), DTI_FA_phip = c(-0.10055, -0.05749, -0.05051, 0.03857, -0.03723, -0.03841, 0.02214, -0.02186, 0.07902, -0.03896, -0.0686, -0.05196, -0.01819, -0.00216, -0.03795, -0.02376, -0.00297, -0.04735, -0.06143, -0.03607, -0.02231, -0.1071, -0.03816, 8e-04, 0.05434, -0.00251, -0.06692, -0.01425, -0.03886, -0.01737, -0.01886, -0.0485, -0.01493, -0.08215, 1e-04, -0.04014, 0.0378, 0.00322, 0.03583, -0.03084, 0.00915, 0.02242, 0.03931, -0.07612, -0.01156, -0.06961, -0.02742, -0.00068, -0.01827, 0.02387, -0.03929, -0.04062, 0.00744, 0.03804, 0.08032, -0.00109, -0.02442, 0.0748), DTI_FA_unc = c(-0.03121, -0.02669, -0.06561, -0.03016, -0.04309, -0.07139, -0.00064, -0.03003, 0.06233, -0.09586, 0.06553, -0.0378, -0.01854, -0.00533, -0.01165, 0.02205, -0.01247, -0.03695, -0.10058, -0.00464, 0.0174, -0.11191, 0.07583, -0.04472, 0.01212, -0.03174, 0.02482, -0.00787, -0.13762, 0.00513, 0.04953, 0.01836, 0.08159, -0.02602, 0.07543, -0.04039, 0.08344, 0.03766, 0.06415, 0.01322, -0.02955, -0.04058, 0.05124, -0.00437, -0.01246, 0.02484, 0.04088, 0.00253, -0.02839, -0.00147, -0.03275, -0.04128, 0.02246, 0.12326, 0.02704, 0.00629, -0.07324, 0.01585), DTI_FA_ilf = c(-0.04602, -0.01739, -0.01175, -0.00353, -0.02254, -0.02124, -0.00718, -0.00614, 0.05083, -0.04862, -0.01182, 0.00623, -0.04439, -0.01033, 0.00511, -0.01327, -0.03813, -0.0531, -0.04757, -0.01733, 0.05492, -0.06545, 0.00693, -0.05518, 0.049, -0.02048, 0.00219, -0.07336, -0.04431, -0.02336, -0.01435, -0.03171, -0.02556, -0.03208, -0.00155, -0.00024, 0.02431, 0.00123, -0.00434, -0.04627, 0.01707, -0.02082, -0.03235, -0.00717, -0.00975, -0.04313, -0.01071, 0.00089, -0.01802, -0.03913, -0.02461, -0.01438, 0.03683, -0.00027, -0.00959, -0.01093, -0.02078, -0.02329), DTI_FA_fx_var = c(-0.30633, -0.10032, -0.06954, -0.1287, 0.1431, -0.18867, 0.07091, 0.28587, 0.22924, 0.07394, -0.05135, -0.08935, 0.09459, -0.20146, -0.21939, -0.00959, 0.00691, -0.12754, 0.17915, 0.10994, -0.12293, -0.16996, -0.2423, -0.09499, 0.02597, -0.14763, -0.14674, -0.11798, -0.16359, 0.11053, 0.0898, 0.00877, -0.02429, -0.0535, 0.05236, -0.05492, 0.01014, -0.06273, 0.15428, -0.01525, -0.07832, 0.06465, 0.09924, -0.17239, -0.06904, 0.03051, -0.06231, -0.21102, -0.08512, 0.01438, 0.00773, -0.16822, 0.11345, 0.04689, 0.04615, 0.19484, -0.08114, 0.14054), DTI_FA_phip_var = c(-0.31416, -0.03829, -0.04248, -0.18344, 0.09385, 0.12763, 0.06495, -0.01365, 0.22065, -0.10723, -0.19459, -0.08524, 0.01009, 0.00255, -0.02444, -0.09229, 0.14756, -0.03077, -0.01662, -0.06503, 0.03835, -0.11068, 0.03665, -0.14369, -0.04338, -0.03936, -0.01548, -0.08825, -0.07538, -0.03213, -0.04573, 0.03713, -0.06602, 0.13059, -0.01279, 0.00638, 0.01162, -0.0576, -0.1633, -0.06859, 0.0198, 0.19683, 0.16415, -0.02786, 0.01717, -0.07365, 0.01162, -0.04647, -0.0522, -0.06633, 0.09297, -0.01083, 0.01687, 0.14787, -0.06296, -0.14916, 0.11102, 0.08741), DTI_FA_unc_var = c(-0.01136, -0.02669, 0.13502, -0.06159, -0.01572, 0.02637, -0.00869, 0.01435, 0.18749, -0.21756, -0.20482, -0.16519, -0.02876, 0.12549, -0.17283, -0.11542, 0.00015, -0.0351, 0.03207, -0.04401, -0.01164, -0.00276, -0.067, -0.18765, 0.00344, -0.02472, -0.15013, -0.05316, -0.21552, -0.0689, 0.20167, 0.12822, -0.06495, 0.17842, -0.0793, -0.00955, 0.18252, 0.11938, 0.14031, 0.11983, 0.0949, 0.09607, 0.10357, 0.15318, 0.0028, 0.14256, 0.21441, -0.11196, 0.1124, -0.05504, 0.064, 0.07663, -0.13536, 0.31965, 0.0479, 0.14153, -0.05378, 0.07813), DTI_FA_ilf_var = c(-0.09761, -0.03841, -0.11968, -0.01938, -0.04677, -0.00508, 0.04189, 0.02894, -0.05718, -0.05293, -0.01327, 0.07065, -0.12096, -0.08633, -0.02063, -0.07176, -0.01563, 0.01581, 0.04975, -0.10416, -0.11594, -0.00067, -0.16241, -0.07932, 0.10198, 0.06224, -0.05175, 0.01423, -0.09871, -0.20956, -0.00642, 0.14264, 0.05872, 0.0556, -0.04788, -0.00744, -0.09784, 0.06975, -0.12834, -0.09232, -0.02949, -0.04681, -0.23007, -0.17231, -0.08963, -0.01555, 0.11707, 0.0101, -0.0881, -0.01318, 0.02609, 0.05251, -0.2031, -0.18261, -0.19067, -0.16841, 0.06812, -0.15278), DTI_FA_fx_skew = c(-0.09918, 0.27956, 0.0585, 0.20893, 0.36436, -0.07152, 0.04937, -0.07141, 0.10636, 0.33076, 0.02066, 0.04939, 0.13914, 0.18335, 0.23636, 0.11629, -0.1744, 0.11302, 0.04731, 0.27391, 0.18378, -0.06814, -0.08826, 0.20764, 0.11108, -0.20537, 0.24269, 0.08973, -0.23735, 0.176, -0.08339, 0.29521, -0.42641, -0.0206, -0.18754, -0.05173, -0.02981, -0.07226, -0.02126, 0.08165, 0.29564, 0.17306, 0.18766, -0.19644, -0.30589, -0.0101, 0.12909, -0.19528, 0.27163, -0.02979, 0.27173, -0.11297, -0.11195, 0.04989, -0.11303, -0.09254, -0.1184, -0.02009), DTI_FA_phip_skew = c(0.17242, -0.331, -0.07892, -0.10374, 0.24626, -0.21744, -1, 1, 0.40797, 1, 1, -0.72076, -0.21224, 0.53263, 0.90566, 0.1458, -0.77432, -0.4877, -0.49634, 0.63629, 1, 0.43416, -0.01519, 0.32949, -1, 1, 0.72198, 0.47066, -0.31816, 0.37536, -0.09622, 1, 0.51551, -0.54607, -1, 1, -1, 0.13805, -1, -1, -1, 1, -1, -0.02107, -0.34408, 1, -1, -1, -0.53881, -0.04074, -0.39173, 0.37106, -0.28021, -0.53222, -0.78117, 0.27239, 0.19946, -1), DTI_FA_unc_skew = c(0.87046, 0.42987, 0.17043, 1, -1, 1, 1, 1, 0.30414, 1, -0.1647, -0.49016, -0.03263, -0.52582, -1, 0.123, 0.42824, 0.48433, 1, -0.00891, 0.08809, 0.28235, -1, 0.04496, -1, -1, -1, 0.61658, 1, -0.13024, 0.05603, 0.31148, -0.54019, 0.96132, -1, 0.95776, -0.70249, -0.19862, 0.05504, -0.15584, 1, 0.47463, 0.35834, -0.31715, 1, 0.69895, 1, 0.3147, -0.19095, 0.88521, -0.47343, 1, -1, -1, 0.2037, 1, 1, -0.51441 ), DTI_FA_ilf_skew = c(-0.2812, 0.29085, -0.26691, 0.02674, -0.10224, 0.08088, 0.01379, -0.67321, -1, 0.17387, 0.16102, -0.28767, 0.66074, 1, -1, 0.42366, -0.06291, -0.15788, -0.77773, 1, -0.07339, 1, -0.15428, 0.83853, 0.76417, 0.25358, -0.87832, -1, 1, 1, 0.66082, 1, -0.51506, 1, 0.03356, -0.39406, -0.5112, -1, -0.21703, 0.44919, -0.9157, 0.35874, -0.19623, -0.11897, -0.07683, -0.24355, -0.74698, 0.19517, 0.08612, -0.0057, 1, -0.23747, 0.01591, -0.1739, -0.07841, -0.25578, -0.15883, 0.15184), DTI_FA_fx_kurt = c(0.10603, 0.21274, 0.06352, 0.20799, 0.14254, 0.03085, 0.10291, -0.09939, -0.00353, 0.08851, -0.02116, 0.06007, -0.05091, 0.11399, 0.24004, 0.13413, -0.08457, 0.10525, -0.00478, 0.0493, 0.11749, 0.02638, 0.01929, 0.11569, 0.09066, -0.01954, 0.19276, 0.15785, -0.06057, 0.11995, -0.0408, 0.24129, -0.01812, -0.05759, -0.16855, -0.06542, -0.05425, -0.05289, -0.07898, -0.00558, 0.11926, 0.08023, -0.07027, -0.05258, -0.12773, 0.04298, 0.0978, -0.11856, 0.10559, -0.03702, 0.17619, 0.00846, -0.03231, 0.03102, -0.10757, -0.03327, -0.17003, -0.03751), DTI_FA_phip_kurt = c(0.12797, -0.07339, 0.01224, -0.02394, -0.06248, -0.06076, -0.04469, -0.02413, -0.09566, 0.00476, -0.01512, -0.08086, -0.01425, 0.06527, 0.03135, 0.02755, -0.08565, 0.04127, -0.04052, 0.09475, -0.14999, 0.00054, -0.0209, -0.04275, -0.05791, 0.08264, 0.07679, 0.06994, -0.07045, 0.04568, 0.09413, -0.01527, -0.03019, 0.04122, -0.04615, 0.00097, -0.07581, 0.0182, 0.03554, -0.01458, -0.05609, 0.04903, -0.0275, -0.02593, 0.05594, -0.02444, -0.09124, 0.00555, -0.01798, -0.0167, 0.00924, 0.00376, -0.04474, -0.05668, 0.01017, 0.08024, -0.1645, 0.00403), DTI_FA_unc_kurt = c(-0.04558, -0.00431, 0.07983, -0.13262, -0.02065, -0.01556, 0.03003, 0.02188, 0.03852, -0.01706, 0.003, -0.13132, 0.02428, 0.0033, -0.00086, -0.00781, 0.12551, 0.05728, 0.11352, 0.09523, 0.04899, -0.05353, 0.09313, 0.01852, -0.04968, -0.02376, 0.03719, -0.03498, 0.04078, -0.07362, -0.09087, 0.14398, 0.06572, 0.14001, 0.06071, 0.02014, 0.00117, -0.0743, -0.01048, -0.01489, -0.00266, 0.05073, 0.09708, -0.08261, -0.02914, -0.02211, 0.05147, 0.18411, 0.02649, -0.00212, 0.00199, -0.07529, -0.02316, -0.06629, 0.10917, -0.08023, -0.00075, 0.07364), DTI_FA_ilf_kurt = c(0.01718, -0.03127, -0.0117, -0.05445, 0.08691, 0.07148, -0.01132, 0.03681, 0.06364, 0.05866, -0.01096, 0.03174, 0.02228, 0.02301, -0.02395, -0.06317, 0.01676, -0.02099, 0.0577, 0.04333, 0.05348, -0.00623, 0.10437, -0.00042, -0.043, 0.00755, 0.03042, 0.04253, 0.11038, 0.08559, -0.01137, 0.02445, 0.05174, -0.02236, 0.06547, 0.05899, 0.0043, -0.06062, 0.05094, 0.00933, 0.1104, -0.0685, 0.0338, 0.08764, 0.02969, 0.06157, -0.03658, 0.03075, 0.04241, 0.05357, 0.03943, 0.02223, 0.03963, 0.01118, 0.04283, 0.00351, 0.03268, 0.00503), LeftRightTLE = structure(c(2L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 1L), .Label = c("left", "right"), class = "factor"), SzOutcomeClass = structure(c(1L, 1L, 1L, 1L, 5L, 1L, 3L, 1L, 5L, 2L, 5L, 1L, 2L, 1L, 4L, 5L, 5L, 4L, 1L, 1L, 5L, 1L, 5L, 5L, 1L, 5L, 5L, 1L, 5L, 5L, 2L, 2L, 3L, 1L, 1L, 1L, 3L, 5L, 2L, 4L, 1L, 1L, 5L, 1L, 5L, 1L, 1L, 5L, 5L, 5L, 1L, 1L, 5L, 5L, 1L, 5L, 5L, 5L), .Label = c("1", "2", "3", "4", "0"), class = "factor")), .Names = c("PET_hippo", "PET_entire", "PET_lateral", "PET_mesial", "PET_hippo_var", "PET_entire_var", "PET_lateral_var", "PET_mesial_var", "PET_hippo_kurt", "PET_entire_kurt", "PET_lat_kurt", "PET_mes_kurt", "PET_hippo_skew", "PET_entire_skew", "PET_lat_skew", "PET_mes_skew", "THICK_lat_Frees", "AMYG_vol", "HIPPO_vol", "THICK_mes_Frees", "THICK_lat_Ants", "THICK_lat_Ants_var", "THICK_lat_Ants_skew", "THICK_lat_Ants_kurt", "THICK_mes_Ants", "THICK_mes_Ants_var", "THICK_mes_Ants_skew", "THICK_mes_Ants_kurt", "THICK_entire_Ants", "THICK_entire_Ants_var", "THICK_entire_Ants_skew", "THICK_entire_Ants_kurt", "DTI_FA_fx", "DTI_FA_phip", "DTI_FA_unc", "DTI_FA_ilf", "DTI_FA_fx_var", "DTI_FA_phip_var", "DTI_FA_unc_var", "DTI_FA_ilf_var", "DTI_FA_fx_skew", "DTI_FA_phip_skew", "DTI_FA_unc_skew", "DTI_FA_ilf_skew", "DTI_FA_fx_kurt", "DTI_FA_phip_kurt", "DTI_FA_unc_kurt", "DTI_FA_ilf_kurt", "LeftRightTLE", "SzOutcomeClass"), row.names = c(NA, 58L), class = "data.frame") # check entered data for unusual values if (any(is.na(c(x,y,z,boots))) == T) { stop("Missing values. Please run the script again and enter all values") } if (x > 1 | y > 1 | z > 1 | x < -1 | y < -1 | z < -1) { stop("entered values are beyond [-1 1] range of asymmetries. \nPlease check the values and run the script again.") } temp=imaging$PET_mesial if (x > max(temp) | x < min(temp) ) { warning(paste("Unusual value entered: ", x, " for PET-mesial is out of existing TLE range [", round(min(temp), 3), " ", round(max(temp), 3), ']', sep='' )) } temp=imaging$PET_hippo_var if (y > max(temp) | y < min(temp) ) { warning(paste("Unusual value entered: ", y, " for PET-hippo-var is out of existing TLE range [", round(min(temp), 3), " ", round(max(temp), 3), ']', sep='' )) } temp=imaging$PET_entire_var if (z > max(temp) | z < min(temp) ) { warning(paste("Unusual value entered: ", z, " for PET-entire-var is out of existing TLE range [", round(min(temp), 3), " ", round(max(temp), 3), ']', sep='' )) } patient.data = data.frame(PET_mesial= x, # new patient data frame PET_hippo_var= y, PET_entire_var= z) # excluding patients from training if (exclude == 0) { # do nothing } else if (exclude == 1) { temp = which(imaging$SzOutcomeClass==3 | imaging$SzOutcomeClass==4) imaging = imaging[-temp, ] ; rm(temp) } else if (exclude == 2) { temp = which(imaging$SzOutcomeClass==0) imaging = imaging[-temp, ] ; rm(temp) } else if (exclude == 3) { temp = which(imaging$SzOutcomeClass==3 | imaging$SzOutcomeClass==4 | imaging$SzOutcomeClass==0) imaging = imaging[-temp, ] ; rm(temp) } else { stop("Invalid value entered for \"Exclude cases\"") } # leftrows = which(imaging$LeftRightTLE == "left") rightrows = which(imaging$LeftRightTLE == "right") # adapt training sample due to exclusions if (nrow(imaging) < 40) { # max is all but one of the smallest group, min = max smallgroup = ifelse(length(leftrows) < length(rightrows), length(leftrows), length(rightrows)) max.train = round(((smallgroup-1)/smallgroup)*100, 0) min.train = max.train # no variability on training sample, always leave/one out rm(smallgroup) } else { min.train = 52 # 52% max.train = 97 # 97% } # install necessary packages and load them if (! is.element("brglm", installed.packages()[,1])) { print("Installing missing `brglm` package") install.packages("brglm") } library(brglm) sample.vec <- function(x, ...) x[sample(length(x), ...)] correct = posterior = pat.probability = pat.category = rep(0, boots) myformula = formula(LeftRightTLE ~ PET_mesial + PET_hippo_var + PET_entire_var) cat(paste("Using ", nrow(imaging), " TLE patients for training (", length(leftrows), " left)...\n", sep='')) cat("\n") pb <- txtProgressBar(min = 0, max = boots, style = 3) for (i in 1:boots) { trainpercent = sample.vec(seq(min.train, max.train, by=3), 1) # random training sample n.left = round(length(leftrows) * trainpercent / 100) n.right = round(length(rightrows) * trainpercent / 100) left = sample(leftrows, replace=F, size=n.left) right = sample(rightrows, replace=F, size=n.right) traindata = imaging[c(left, right), ] testdata = imaging[ -c(left, right), ] temp = suppressWarnings( brglm(myformula, data=traindata, family=binomial ) ) temp2 = predict(temp, newdata=testdata, type="response") success = (temp2>0.5 & testdata$LeftRightTLE == "right") | (temp2<0.5 & testdata$LeftRightTLE == "left") correct[i] = sum(success) / nrow(testdata) * 100 posterior[i] = mean(c(1-temp2[testdata$LeftRightTLE=="left"], temp2[testdata$LeftRightTLE=="right"])) temp3 = predict(temp, newdata=patient.data, type="response") pat.category[i] = ifelse(temp3>0.5, "right", "left") pat.probability[i] = temp3 setTxtProgressBar(pb, i) } close(pb) pat.category = as.factor(pat.category) # summary(pat.category) / boots * 100 # uncomment this line for raw categorization values LTLEcorrect = sum( (pat.category=="left")*round(correct) ) RTLEcorrect = sum( (pat.category=="right")*round(correct) ) cat(paste("Patient Classification (", boots, " bootstraps):\n", sep='')) print(paste('left TLE: ', round( LTLEcorrect / (LTLEcorrect + RTLEcorrect) * 100, 2), "%", sep='') ) print(paste('right TLE: ', round( RTLEcorrect / (LTLEcorrect + RTLEcorrect) * 100, 2), "%", sep='') ) cat("Average Posterior Probability (0=left, 1=right):\n") print(round(weighted.mean(pat.probability, posterior),3 ) ) cat("95% CI of posterior probability (0.5=chance):\n") print(round(quantile(pat.probability, probs=c(0.025, 0.975)), 3)) ######################################################################