def plot_mriscan(fu, mriscan): netname = 'bold_net' title = 'TestCircos' outfilepath = 'boldnet' atlasobj = fu.atlasobj net = fu.nets.load(mriscan, netname) attr = fu.attrs.load(mriscan, 'bold_interWD') builder = braincircos.CircosPlotBuilder(atlasobj, title, outfilepath) builder.add_circosvalue(braincircos.CircosValue(attr)) builder.add_circosvalue(braincircos.CircosValue(attr, (0, 50))) builder.add_circosvalue(braincircos.CircosValue(attr, (0, 100))) builder.add_circoslink(braincircos.CircosLink(net)) builder.plot()
from mmdps.vis import braincircos import numpy as np atlasobj = atlas.get('brodmann_lrce') subject_list = [ 'tanenci_20170601', 'tanenci_20170706', 'tanenci_20170814', 'tanenci_20170922', 'tanenci_20171117' ] # subject_list = ['wangwei_20171107', 'wangwei_20171221', 'wangwei_20180124', 'wangwei_20180211', 'wangwei_20180520'] # subject_list = ['xiezhihao_20180416', 'xiezhihao_20180524'] for i in range(0, len(subject_list)): # load in the given subject's net net1 = netattr.Net( loadsave.load_csvmat('Y:/BOLD/%s/brodmann_lrce/bold_net/corrcoef.csv' % subject_list[i - 1]), atlasobj) # net1.data = abs(net1.data) # set a threshold mask netList = sorted(abs(net1.data.ravel())) threshold = netList[int(0.95 * len(netList))] net1.data[abs(net1.data) < threshold] = 0 builder = braincircos.CircosPlotBuilder( atlasobj, '%s %dth orig top 5%%' % (subject_list[i].replace('_', ' '), i + 1), '%s/%s %dth circos orig top 5%%.png' % (subject_list[i].split('_')[0], subject_list[i].replace('_', ' '), i + 1)) builder.add_circoslink(braincircos.CircosLink(net1, threshold=0)) builder.plot()
ChanggungPatientNets = io_utils.loadSpecificNets( mmdps_locale.ChanggungAllFullPath, atlasobj, subjectList=os.path.join(mmdps_locale.ChanggungRootPath, 'CS_subjects.txt')) ChanggungHealthyNets = io_utils.loadSpecificNets( mmdps_locale.ChanggungAllFullPath, atlasobj, subjectList=os.path.join(mmdps_locale.ChanggungRootPath, 'normal_subjects.txt')) sig_connections = stats_utils.filter_sigdiff_connections_Bonferroni( ChanggungPatientNets, ChanggungHealthyNets) sigDiffNet = netattr.Net(np.zeros((atlasobj.count, atlasobj.count)), atlasobj) for conn in sig_connections: sigDiffNet.data[conn[0], conn[1]] = 1 title = 'CS_signet' outfilepath = 'E:/Results/CS_signet/test.png' builder = braincircos.CircosPlotBuilder(atlasobj, title, outfilepath) builder.add_circoslink(braincircos.CircosLink(sigDiffNet)) builder.add_circosvalue( braincircos.CircosValue( netattr.Attr(np.random.uniform(size=atlasobj.count), atlasobj))) builder.customizeSize('0.80', '10p') builder.plot()
loadsave.load_csvmat('Y:/BOLD/%s/brodmann_lrce/bold_net/corrcoef.csv' % subject_list[0]), atlasobj) net1.data = abs(net1.data) net2 = netattr.Net( loadsave.load_csvmat('Y:/BOLD/%s/brodmann_lrce/bold_net/corrcoef.csv' % subject_list[-1]), atlasobj) net2.data = abs(net2.data) net2.data -= net1.data # set a threshold mask netList = sorted(abs(net2.data.ravel())) threshold = netList[int(0.95 * len(netList))] net2.data[abs(net2.data) < threshold] = 0 builder = braincircos.CircosPlotBuilder( atlasobj, '%s 2th minus\n%s 1th abs top5%%' % (subject_list[-1].replace('_', ' '), subject_list[0].replace('_', ' ')), 'xiezhihao/xiezhihao 21 circos abs top5.png') builder.add_circoslink(braincircos.CircosLink(net2, threshold=0)) builder.plot() exit() for i in range(1, len(subject_list)): # load in the given subject's net net1 = netattr.Net( loadsave.load_csvmat('Y:/BOLD/%s/brodmann_lrce/bold_net/corrcoef.csv' % subject_list[i - 1]), atlasobj) net1.data = abs(net1.data) net2 = netattr.Net( loadsave.load_csvmat('Y:/BOLD/%s/brodmann_lrce/bold_net/corrcoef.csv' % subject_list[i]), atlasobj) net2.data = abs(net2.data)
subject_list[-1]), atlasobj) # net2.data = abs(net2.data) net1, net2, ratio = all_neg(net1, net2) net2.data -= net1.data # net2.data = abs(net2.data) - abs(net1.data) wd2.data -= wd1.data # set a threshold mask # netList = sorted(abs(net2.data.ravel())) # threshold = netList[int(0.95*len(netList))] # net2.data[abs(net2.data) < threshold] = 0 builder = braincircos.CircosPlotBuilder( atlasobj, '%s 5th minus\n%s 1th all neg\nratio = %1.3f' % (subject_list[-1].replace( '_', ' '), subject_list[0].replace('_', ' '), ratio), '%s/%s 51 circos all neg test.png' % (subject_list[0].split('_')[0], subject_list[0].split('_')[0])) builder.add_circoslink(braincircos.CircosLink(net2, threshold=0)) builder.add_circosvalue(braincircos.CircosValue(wd2)) builder.plot() exit() for i in range(1, len(subject_list)): # load in the given subject's net net1 = netattr.Net( loadsave.load_csvmat('Y:/BOLD/%s/brodmann_lrce/bold_net/corrcoef.csv' % subject_list[i - 1]), atlasobj) net2 = netattr.Net( loadsave.load_csvmat('Y:/BOLD/%s/brodmann_lrce/bold_net/corrcoef.csv' % subject_list[i]), atlasobj)
ret1.data[mask] = 0 ret2.data[mask] = 0 return(ret1, ret2, ratio) def all_neg(net1, net2): ret1 = copy.deepcopy(net1) ret2 = copy.deepcopy(net2) mask = np.logical_not(np.logical_and(net1.data < 0, net2.data < 0)) ratio = (mask.size - np.count_nonzero(mask))/float(mask.size) ret1.data[mask] = 0 ret2.data[mask] = 0 return(ret1, ret2, ratio) atlasobj = atlas.get('brodmann_lrce') # scan_list = ['tanenci_20170601', 'tanenci_20170706', 'tanenci_20170814', 'tanenci_20170922', 'tanenci_20171117'] scan_list = ['wangwei_20171107', 'wangwei_20171221', 'wangwei_20180124', 'wangwei_20180211', 'wangwei_20180520'] # scan_list = ['xiezhihao_20180416', 'xiezhihao_20180524'] net_list = io_utils.loadAllNets('Y:/BOLD/', atlasobj, scanList = scan_list) for i in range(1, len(scan_list)): net_list[i-1], net_list[i], _ = all_pos(net_list[i-1], net_list[i]) # net_list[-1] contains the final all same sign net # net_list[-1].data[net_list[-1].data != 0] = 1 # plot this net builder = braincircos.CircosPlotBuilder(atlasobj, '%s all positive' % (scan_list[0].split('_')[0]), '%s/%s all positive.png' % (scan_list[0].split('_')[0], scan_list[0].split('_')[0])) builder.add_circoslink(braincircos.CircosLink(net_list[-1], threshold = 0)) builder.plot()