def mk_participation_index_giftis():
    pidata = numpy.loadtxt(
        os.path.join(rsfmridir, 'PIpos_weighted_louvain_bct.txt'))

    df = load_dataframe.load_dataframe(os.path.join(
        basedir, 'timeseries/out.dat.pindex_behav.txt'),
                                       thresh=0.05)

    associations = {}
    for v in df.iterkeys():
        if not associations.has_key(v[1]):
            associations[v[1]] = numpy.zeros(634)
        vertexnum = int(v[0].replace('V', '')) - 1
        associations[v[1]][vertexnum] = df[v][2]

    vars = associations.keys()
    vars.sort()

    data = numpy.zeros((634, len(vars)))

    for i in range(len(vars)):
        data[:, i] = associations[vars[i]]
    data = data[:620, :]
    meanpi = numpy.mean(pidata, 1)
    data = numpy.hstack((meanpi[:620, None], data))
    vars = ['meanPI'] + vars
    labels_to_gii.labels_to_gii(data,
                                vars,
                                'PI',
                                basedir=basedir,
                                outdir=rsfmridir)
Пример #2
0
def check_text_file(infile):
    local=numpy.loadtxt(os.path.join(basedir,infile))
    remote=load_dataframe('%s/%s'%(dataurl,infile),thresh=1.01)
    if not len(local)==len(remote):
        print 'size mismatch for ',infile
        return
    localdata=numpy.zeros((len(local),4))
    remotedata=numpy.zeros((len(remote),4))
    keys=local.keys()
    for k in range(len(keys)):
        if not remote.has_key(keys[k]):
            print 'remote missing matching key',keys[k]
        localdata[k,:]=local[keys[k]]
        remotedata[k,:]=remote[keys[k]]
    if numpy.allclose(localdata,remotedata,rtol,atol):
        print 'PASS:'******'FAIL:',infile,'maxdiff =',maxdiff
Пример #3
0
def check_text_file(infile):
    local = numpy.loadtxt(os.path.join(basedir, infile))
    remote = load_dataframe('%s/%s' % (dataurl, infile), thresh=1.01)
    if not len(local) == len(remote):
        print 'size mismatch for ', infile
        return
    localdata = numpy.zeros((len(local), 4))
    remotedata = numpy.zeros((len(remote), 4))
    keys = local.keys()
    for k in range(len(keys)):
        if not remote.has_key(keys[k]):
            print 'remote missing matching key', keys[k]
        localdata[k, :] = local[keys[k]]
        remotedata[k, :] = remote[keys[k]]
    if numpy.allclose(localdata, remotedata, rtol, atol):
        print 'PASS:'******'FAIL:', infile, 'maxdiff =', maxdiff
Пример #4
0
    remote = numpy.genfromtxt('%s/rsfmri/%s' % (dataurl, f))
    compare_matrices(local, remote, 'rsfmri/%s' % f)

print '#### Timeseries analysis Results'

tsresults = glob.glob(os.path.join(basedir, 'timeseries/out*.txt'))
if len(tsresults) == 0:
    print 'no timeseries results found - somethign went wrong'
else:
    for ts in tsresults:
        f = ts.replace(basedir + '/', '')

        if ts in downloads:
            print 'SKIPPING DOWNLOADED FILE:', f
        else:
            local = load_dataframe(os.path.join(basedir, f), thresh=1.01)
            remote = load_dataframe('%s/%s' % (dataurl, f), thresh=1.01)
            if not len(local) == len(remote):
                print 'size mismatch for ', f, len(local), len(remote)
                continue
            localdata = numpy.zeros((len(local), 4))
            remotedata = numpy.zeros((len(remote), 4))
            keys = local.keys()
            d = diff(keys, remote.keys())
            if d:
                print 'Key mismatch for', f
                print d
            for k in range(len(keys)):
                if not remote.has_key(keys[k]):
                    print 'remote missing matching key', keys[k]
                else:
Пример #5
0
"""
make matrix showing bwcorr and wgcna relations
"""

from myconnectome.utils.load_dataframe import load_dataframe
import numpy
import os

basedir=os.environ['MYCONNECTOME_DIR']
df=load_dataframe(os.path.join(basedir,'timeseries/out.dat.wgcna_bwcorr.txt'),0.1)

genemodules=[]
genenums=[]
connections=[]

for k in df.iterkeys():
    genemodules.append(k[0])
    genenums.append(int(k[0].split(':')[0].replace('ME','')))
    c=k[1].replace('Cingulo-opercular','Cingulo_opercular').replace('Parieto-Occipital','Parieto_Occipital').replace('rontal-Parietal','rontal_Parietal')
    connections.append(c)
    

modules=[]
for c in connections:
    c_s=c.split('-')
    assert len(c_s)==2
    modules+=c_s
    
modules=list(set(modules))
modules.sort()
modules=modules[4:]+modules[:4]
Пример #6
0
inputs to the R program used for the figures (mk_bwcorr_expression_figure.R)
Created on Sun Jun 21 18:03:58 2015

@author: poldrack
"""

import os
import numpy
from myconnectome.utils.load_dataframe import load_dataframe
import matplotlib.pyplot as plt
import matplotlib

basedir = os.environ['MYCONNECTOME_DIR']

wincorr_df = load_dataframe(os.path.join(
    basedir, 'timeseries/out.dat.wgcna_wincorr.txt'),
                            thresh=1.0)
netnames = [
    'DMN', 'V2', 'FP1', 'V1', 'DA', 'VA', 'Sal', 'CO', 'SM', 'FP2', 'MPar',
    'ParOcc'
]
netidx = {
    1: 0,
    2: 1,
    3: 2,
    4.5: 3,
    5: 4,
    7: 5,
    8: 6,
    9: 7,
    10: 8,
Пример #7
0
    compare_matrices(local,remote,'rsfmri/%s'%f)
    
print '#### Timeseries analysis Results'


tsresults=glob.glob(os.path.join(basedir,'timeseries/out*.txt'))
if len(tsresults)==0:
    print 'no timeseries results found - somethign went wrong'
else:
    for ts in tsresults:
        f=ts.replace(basedir+'/','')
        
        if ts in downloads:
            print 'SKIPPING DOWNLOADED FILE:',f
        else:
            local=load_dataframe(os.path.join(basedir,f),thresh=1.01)
            remote=load_dataframe('%s/%s'%(dataurl,f),thresh=1.01)
            if not len(local)==len(remote):
                print 'size mismatch for ',f,len(local),len(remote)
                continue
            localdata=numpy.zeros((len(local),4))
            remotedata=numpy.zeros((len(remote),4))
            keys=local.keys()
            d=diff(keys,remote.keys())
            if d:
                print 'Key mismatch for',f
                print d
            for k in range(len(keys)):
                if not remote.has_key(keys[k]):
                    print 'remote missing matching key',keys[k]
                else:
Пример #8
0
Created on Sun May  3 06:55:17 2015

@author: poldrack
"""

import os, sys
import numpy
import networkx
from myconnectome.utils.load_dataframe import load_dataframe

basedir = os.environ['MYCONNECTOME_DIR']

thresh = 0.1

winmod = load_dataframe(os.path.join(basedir,
                                     'timeseries/out.dat.wincorr_netdat.txt'),
                        thresh=1.0)
bwmod = load_dataframe(os.path.join(basedir,
                                    'timeseries/out.dat.bwcorr_netdat.txt'),
                       thresh=1.0)

nicenames = {
    '16_Parieto_Occipital': 'ParietoOccip',
    '4.5_Visual_1': 'V1',
    '9_Cingulo_opercular': 'CingOperc',
    '2_Visual_2': 'V2',
    '8_Salience': 'Salience',
    '1_Default': 'Default',
    '11.5_Fronto_Parietal_2': 'FPother',
    '7_Ventral_Attention': 'VentAttn',
    '5_Dorsal_Attention': 'DorsAttn',