Example #1
0
###############################################################################
### MAIN ######################################################################
###############################################################################
if __name__ == '__main__':
    # Create store
    from cubicweb.dataimport import SQLGenObjectStore
    store = SQLGenObjectStore(session)
    sqlgen_store = True

    root_dir = osp.abspath(sys.argv[4])
    subjects_dir = osp.join(root_dir, 'subjects')
    genetics_dir = osp.join(root_dir, 'genetics')

    ### Study #################################################################
    study = import_study(data_dir=root_dir)
    study = store.create_entity('Study', **study)

    ### Initialize questionnaire ##############################################
    one_subject = glob.glob('%s/*' % subjects_dir)[0]
    questionnaire, questions = import_questionnaire(one_subject)
    questionnaire = store.create_entity('Questionnaire', **questionnaire)
    questions_id = {}
    for question in questions:
        question['questionnaire'] = questionnaire.eid
        question = store.create_entity('Question', **question)
        questions_id[question.text] = question.eid

    ### Initialize genetics ####################################################
    # Chromosomes
    chrs = import_chromosomes(os.path.join(genetics_dir, 'chromosomes.json'))
    chr_map = {}
Example #2
0
### BODYLOCATION ##############################################################
###############################################################################
""" This come from the following sparql request on dbpedia.org
prefix dbpedia-owl:<http://dbpedia.org/ontology/>
prefix dbpprop:<http://dbpedia.org/property/>

select distinct ?u, ?t, ?n, ?a where
{?u a dbpedia-owl:AnatomicalStructure.
 ?u dbpprop:name ?t.
 OPTIONAL{?u dbpprop:meshnumber ?n.
          ?u dbpedia-owl:abstract ?a.
          FILTER (lang(?a)="en")}
  FILTER (lang(?t)="en")}"""
reader = ucsvreader(open(osp.join(HERE, 'bodylocation.csv')), separator='\t')
for identifier, name, mesh, descr in reader:
    store.create_entity('BodyLocation', identifier=identifier,
                        name=name, mesh_id=mesh, description=descr)


###############################################################################
### DISEASE ###################################################################
###############################################################################
"""This come from the following sparql request on dbpedia.org
prefix dbpedia-owl:<http://dbpedia.org/ontology/>
prefix dbpprop:<http://dbpedia.org/property/>

select distinct ?u, ?t, ?n, ?d, ?a where
{?u a dbpedia-owl:Disease.
 ?u dbpedia-owl:meshId ?n.
 ?u dbpedia-owl:icd10 ?d.
 ?u dbpedia-owl:abstract ?a.
 ?u rdfs:label ?t.
Example #3
0
                      help="Json file of snps")
    (options, args) = parser.parse_args(__args__)

    store = SQLGenObjectStore(session)


    ###############################################################################
    ### GENETICS DATA #############################################################
    ###############################################################################
    platform = None
    if options.chromosomes:
        chrs = import_chromosomes(options.chromosomes)
        chr_map = {}
        for _chr in chrs:
            print 'chr', _chr['name']
            _chr = store.create_entity('Chromosome', **_chr)
            chr_map.setdefault(_chr['name'], _chr.eid)
        store.flush()
        if options.genes:
            genes = import_genes(options.chromosomes, options.genes)
            for gene in genes:
                print 'gene', gene['name'], gene['chromosome']
                gene['chromosome'] = chr_map[gene['chromosome']]
                gene = store.create_entity('Gene', **gene)
            store.flush()
        if options.snps:
            snps = import_snps(options.chromosomes, options.snps)
            snp_eids = []
            for ind, snp in enumerate(snps):
                print 'snp', snp['rs_id']
                snp['chromosome'] = chr_map[snp['chromosome']]
Example #4
0
import sys
import os.path as osp
import glob

import nibabel as nb

from cubicweb.dataimport import SQLGenObjectStore as Store

from cubes.brainomics.importers.helpers import get_image_info


if __name__ == '__main__':
    base_path = osp.abspath(sys.argv[4])
    store = Store(session)
    global_study = store.create_entity('Study', data_filepath=unicode(base_path), name = u'mindboggle',
                                       description=u'''The Mindboggle-101 dataset includes manually labeled anatomical regions for 101 healthy subjects. The manually edited cortical labels follow sulcus landmarks according to the Desikan-Killiany-Tourville (DKT) protocol. See http://www.frontiersin.org/Brain_Imaging_Methods/10.3389/fnins.2012.00171/full “101 labeled brain images and a consistent human cortical labeling protocol”
Arno Klein, Jason Tourville. Frontiers in Brain Imaging Methods. 6:171. DOI: 10.3389/fnins.2012.00171
    and http://mindboggle.info/data.html''')
    for study_path in ('Extra-18_volumes', 'MMRR-21_volumes', 'NKI-RS-22_volume',
                       'NKI-TRT-20_volumes', 'OASIS-TRT-20_volumes'):
        full_study_path = osp.join(base_path, study_path)
        if not osp.exists(full_study_path):
            print '%s does not exist, skip it' % full_study_path
            continue
        # Create study
        count_subject = 0
        study = store.create_entity('Study', data_filepath=unicode(full_study_path),
                                    name = unicode(study_path))
        for subject_path in glob.iglob(osp.join(full_study_path,'*')):
            subject_id = subject_path.split('/')[-1]
            print '--->', subject_id
            subject = store.create_entity('Subject', identifier=unicode(subject_id),
Example #5
0
import sys
import os.path as osp
import glob

import nibabel as nb

from cubicweb.dataimport import SQLGenObjectStore as Store

from cubes.brainomics.importers.helpers import get_image_info


if __name__ == '__main__':
    base_path = osp.abspath(sys.argv[4])
    store = Store(session)
    count_all_subject = 0
    global_study = store.create_entity('Study', data_filepath=unicode(base_path), name = u'openfmri',
                                       description=u'''OpenfMRI.org is a project dedicated to the free and open sharing of functional magnetic resonance imaging (fMRI) datasets, including raw data. See http://openfmri.org/''')
    # All studies
    for study_path in glob.iglob(osp.join(base_path,'*/')):
        study_id = study_path[:-1].split('/')[-1]
        print '--->', study_id
        # XXX use True metadata for studies, P.I. ...
        study = store.create_entity('Study', data_filepath=unicode(osp.abspath(study_path)),
                                    name = u'openfmri-%s' % study_id, keywords='openfmri')
        # Device
        device_path = osp.join(study_path, 'scan_key.txt')
        device_eid = None
        if osp.exists(device_path):
            device = open(device_path).readline()
            if device.strip():
                device = store.create_entity('Device', name=unicode(device.strip()),
                                             model=unicode(device.strip()))