def plot_mriscan_weak(fu, mriscan, netname): print(mriscan) net = fu.nets.load(mriscan, netname) netfilepath = fu.nets.loadfilepath(mriscan, netname) netfiledir = os.path.dirname(netfilepath) atlasobj = fu.atlasobj attrdata = np.mean(net.data, axis=0) attr = netattr.Attr(attrdata, atlasobj) outfilepath = os.path.join(netfiledir, netname + '_circos_weak') title = '{}\n{}\n'.format(mriscan, netname) if netname == 'bold_net': p = WeakBOLDNetCircosPlot(atlasobj, title, outfilepath) p.add_circosvalue(braincircos.CircosValue(attr, (-1, 1))) p.add_circoslink(WeakCircosLink(net, 0.5, (-1, 1))) elif netname == 'dwi_net': p = WeakDWINetCircosPlot(atlasobj, title, outfilepath) p.add_circosvalue(braincircos.CircosValue(attr, (-100, 100))) p.add_circosvalue( braincircos.CircosValue(fu.attrs.load(mriscan, 'dwi_MD'), (-0.003, 0.003))) p.add_circosvalue( braincircos.CircosValue(fu.attrs.load(mriscan, 'dwi_FA'), (-1, 1))) p.add_circoslink(WeakCircosLink(net, 2, (-6, 6))) else: return p.plot()
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()
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()
# 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) sigRegions = stats_utils.row_wise_ttest(net1, net2) sigAttr = netattr.Attr(sigRegions, atlasobj) net1, net2, ratio = neg2pos(net1, net2)