In [1]:
import pandas
In [2]:
%cd D:\kmc400-braviz\tracula_group
In [3]:
import glob
from os import path
In [8]:
files = glob.glob("*.csv")
In [9]:
valid_ids=[ 8, 9, 15, 25, 29, 31, 35, 44, 51, 53, 54, 56, 64, 65, 69, 75, 83, 90, 93, 95, 107, 108, 113, 119, 121, 123, 124, 125, 128, 129, 134, 138, 141, 143, 144, 145, 149, 151, 153, 154, 156, 157, 161, 165, 172, 173, 175, 176, 177, 182, 185, 186, 195, 197, 198, 201, 202, 205, 208, 210, 212, 216, 219, 221, 225, 227, 230, 231, 232, 235, 237, 253, 256, 261, 263, 264, 266, 277, 288, 292, 293, 300, 301, 304, 307, 310, 313, 314, 319, 320, 322, 327, 331, 332, 333, 344, 346, 348, 353, 355, 356, 357, 358, 364, 369, 371, 374, 381, 390, 396, 399, 402, 409, 413, 416, 417, 423, 424, 426, 427, 429, 431, 432, 440, 452, 456, 458, 464, 469, 472, 478, 480, 483, 484, 485, 491, 496, 499, 504, 517, 526, 532, 535, 536, 537, 542, 544, 545, 547, 548, 549, 552, 566, 568, 576, 577, 579, 580, 592, 593, 595, 598, 599, 600, 602, 610, 611, 615, 616, 619, 623, 625, 630, 631, 645, 650, 651, 662, 665, 670, 675, 678, 684, 686, 689, 691, 694, 696, 712, 715, 734, 739, 752, 754, 761, 765, 769, 783, 784, 786, 789, 790, 791, 795, 804, 806, 815, 818, 821, 829, 840, 841, 848, 850, 861, 863, 868, 869, 874, 876, 877, 878, 879, 884, 891, 892, 893, 894, 898, 905, 906, 912, 913, 914, 918, 928, 934, 935, 939, 940, 942, 953, 954, 966, 971, 982, 984, 992, 994, 996, 1005, 1006, 1021, 1026, 1039, 1049, 1076, 1077, 1212, 1213, 1218, 1221, 1224, 1227, 1232, 1234, 1237, 1239, 1242, 1244, 1247, 1249, 1251, 1253, 1260, 1262, 1265, 1267, 1268, 1269, 1271, 1278, 1283, 1291, 1304, 1318, 1320, 1322, 1326, 1333, 1336, 1337, 1338, 1340, 1357, ]
In [10]:
missing = {}
tables={}
In [12]:
for f0 in files:
table = pandas.read_table(f0,index_col=0)
missing[f0]=set(valid_ids)-set(table.index)
table2 = table.loc[valid_ids]
tables[f0]=table2
In [15]:
tables['lh.ccg_PP_avg33_mni_bbr.csv']
Out[15]:
In [16]:
missing
Out[16]:
In [73]:
tracula_names={
"lh.cst_AS": "Left corticospinal tract",
"rh.cst_AS": "Right corticospinal tract",
"lh.ilf_AS": "Left inferior longitudinal fasciculus",
"rh.ilf_AS": "Right inferior longitudinal fasciculus",
"lh.unc_AS": "Left uncinate fasciculus",
"rh.unc_AS": "Right uncinate fasciculus",
"fmajor_PP": "Corpus callosum-forceps major",
"fminor_PP": "Corpus callosum-forceps minor",
"lh.atr_PP": "Left anterior thalamic radiations",
"rh.atr_PP": "Right anterior thalamic radiations",
"lh.ccg_PP": "Left cingulum-cingulate gyrus endings",
"rh.ccg_PP": "Right cingulum-cingulate gyrus endings",
"lh.cab_PP": "Left cingulum-angular bundle",
"rh.cab_PP": "Right cingulum-angular bundle",
"lh.slfp_PP": "Left superior longitudinal fasciculus-parietal endings",
"rh.slfp_PP": "Right superior longitudinal fasciculus-parietal endings",
"lh.slft_PP": "Left superior longitudinal fasciculus-temporal endings",
"rh.slft_PP": "Right superior longitudinal fasciculus-temporal endings",
}
In [74]:
k=tables.keys()[0]
In [75]:
pretty_names = dict((k,tracula_names[k[:-18]]) for k in tables.keys())
In [76]:
pretty_names
Out[76]:
In [77]:
pretty_tables=[]
In [78]:
for k,v in tables.items():
cols = v.columns
n=pretty_names[k].replace(" ","_")
cols2=["TRAC_"+n+"_"+c for c in cols]
table2=v[:]
table2.columns = cols2
pretty_tables.append(table2)
In [79]:
big_table=pretty_tables[0].join(pretty_tables[1:])
In [80]:
big_table.sort(axis=1,inplace=True)
In [81]:
big_table.to_excel("tracula.xlsx")
In [ ]: