Esempio n. 1
0
"""
Reese's GOBS traits and Anderson's surfaces have slightly different names.
This module contains dictionaries to switch between them.
"""

__author__ = 'smathias'

import cPickle
from os.path import join as pj
import pandas
from solarpy.utils.paths import DATA_DIR as data_dir
from solarpy.pysurf.atlas import get_atlas_labels
from difflib import get_close_matches


anderson = get_atlas_labels('Destrieux')
anderson.remove('Unknown')
reese = pandas.read_csv(pj(data_dir, 'freesurfer.csv')).columns
area = [r for r in reese if 'area' in r]
thickness = [r for r in reese if 'thickness' in r]

dic = {}

for t in anderson:

    for h in ['lh', 'rh']:
        for m in ['area', 'thickness']:
            s = '%s_%s_%s' % (h, t, m)
            q = get_close_matches(s, reese, n=1)[0]
            # dic['%s_%s_%s' % (m, h, t)] = q
            s = '%s_%s_%s' % (m, h, t)
Esempio n. 2
0
import solarpy.py2solar.make_jobs as make_jobs


r2a = cPickle.load(open('reese2anderson.pickle'))
a2r = {v: k.replace('-', '_') for k, v in r2a.iteritems()}
dic = {
    'freesurfer.csv': r2a.values(),
    'gobs.csv': [],  # to get age
    'etiv4sam.csv': ['etiv']
}

traits = make_jobs.grab_traits(dic)
traits.rename(columns=a2r, inplace=True)
print traits.columns

regions = atlas.get_atlas_labels('Destrieux')
regions.remove('Unknown')

for region in regions:
    for m in ['area', 'thickness']:

        l = '%s_lh_%s' % (m, region.replace('-', '_'))
        r = '%s_rh_%s' % (m, region.replace('-', '_'))
        b = '%s_bl_%s' % (m, region.replace('-', '_'))
        a = '%s_as_%s' % (m, region.replace('-', '_'))
        if m == 'area':
            traits[b] = traits[l] + traits[r]
        else:
            _l = 'area_lh_%s' % region.replace('-', '_')
            _r = 'area_rh_%s' % region.replace('-', '_')
            traits[b] = ((traits[l] * traits[_l]) + (traits[r] * traits[_r])) / (traits[_l] + traits[_r])