Exemple #1
0
def make_location(x, y, z):

    location = Location(x, y, z)

    # Add Neurosynth coactivation image if it exists
    filename = 'metaanalytic_coactivation_%d_%d_%d_association-test_z_FDR_0.01.nii.gz' % (
        x, y, z)
    filename = join(settings.IMAGE_DIR, 'coactivation', filename)
    if not exists(filename):
        tasks.make_coactivation_map.delay(x, y, z).wait()
    if exists(filename):
        ma_image = LocationImage(
            name='Meta-analytic coactivation for seed (%d, %d, %d)' % (
                x, y, z),
            image_file=filename,
            label='Meta-analytic coactivation',
            stat='z-score',
            display=1,
            download=1,
            description='This image displays regions coactivated with the seed'
            ' region across all studies in the Neurosynth database. It '
            'represents meta-analytic coactivation rather than time '
            'series-based connectivity.'
        )
        location.images.append(ma_image)

    # Add Yeo FC image if it exists
    filename = join(settings.IMAGE_DIR, 'fcmri',
                    'functional_connectivity_%d_%d_%d.nii.gz' % (x, y, z))
    if exists(filename):
        fc_image = LocationImage(
            name='YeoBucknerFCMRI for seed (%d, %d, %d)' % (x, y, z),
            image_file=filename,
            label='Functional connectivity',
            stat='corr. (r)',
            description='This image displays resting-state functional '
            'connectivity for the seed region in a sample of 1,000 subjects. '
            'To reduce blurring of signals across cerebro-cerebellar and '
            'cerebro-striatal boundaries, fMRI signals from adjacent cerebral '
            'cortex were regressed from the cerebellum and striatum. For '
            'details, see '
            '<a href="http://jn.physiology.org/content/106/3/1125.long">Yeo et'
            'al (2011)</a>, <a href="http://jn.physiology.org/cgi/pmidlookup?'
            'view=long&pmid=21795627">Buckner et al (2011)</a>, and '
            '<a href="http://jn.physiology.org/cgi/pmidlookup?view=long&'
            'pmid=22832566">Choi et al (2012)</a>.',
            display=1,
            download=1
        )
        location.images.append(fc_image)

    db.session.add(location)
    db.session.commit()

    # Decode both images
    for img in location.images:
        decode_analysis_image(img.id)

    return location
Exemple #2
0
def get_decoding_data(image, get_json=True):

    if Image.query.get(image) is None:
        return error_page("Invalid image requested for decoding. Please check"
                          " to make sure there is a valid image with id=%d." %
                          image)
    dec = decode_analysis_image(image)
    df = os.path.join(settings.DECODING_RESULTS_DIR, dec.uuid + '.txt')
    if not os.path.exists(df):
        return error_page("An unspecified error occurred during decoding.")
    data = open(df).read().splitlines()
    data = [x.split('\t') for x in data]
    data = [[f, round(float(v or '0'), 3)] for (f, v) in data]
    return jsonify(data=data) if get_json else data
Exemple #3
0
def get_decoding_data(image, get_json=True):

    if Image.query.get(image) is None:
        return error_page("Invalid image requested for decoding. Please check"
                          " to make sure there is a valid image with id=%d." %
                          image)
    dec = decode_analysis_image(image)
    df = os.path.join(settings.DECODING_RESULTS_DIR, dec.uuid + '.txt')
    if not os.path.exists(df):
        return error_page("An unspecified error occurred during decoding.")
    data = open(df).read().splitlines()
    data = [x.split('\t') for x in data]
    data = [[f, round(float(v or '0'), 3)] for (f, v) in data]
    return jsonify(data=data) if get_json else data
Exemple #4
0
def show(symbol):
    gene = Gene.query.filter_by(symbol=symbol).first()
    if gene is None:
        return error_page("We have no data for the gene '%s'" % symbol)
    image = gene.images[0]
    # Run decoder if it hasn't been run before
    dec = decode_analysis_image(image.id)
    url = url_for('api_images.download', val=image.id)
    images = [{
        'id': image.id,
        'name': symbol,
        'url':  url,
        'colorPalette': 'intense red-blue',
        'download': url,
        'sign': 'both'
    }]
    return render_template('genes/show.html', gene=gene,
                           images=json.dumps(images), image_id=dec.uuid)
Exemple #5
0
def show(symbol):
    gene = Gene.query.filter_by(symbol=symbol).first()
    if gene is None:
        return error_page("We have no data for the gene '%s'" % symbol)
    image = gene.images[0]
    # Run decoder if it hasn't been run before
    dec = decode_analysis_image(image.id)
    url = url_for('api_images.download', val=image.id)
    images = [{
        'id': image.id,
        'name': symbol,
        'url': url,
        'colorPalette': 'intense red-blue',
        'download': url,
        'sign': 'both'
    }]
    return render_template('genes/show.html',
                           gene=gene,
                           images=json.dumps(images),
                           image_id=dec.uuid)