Ejemplo n.º 1
0
            fwd_inf = join(settings.IMAGE_DIR, 'custom', fwd_inf)
            if exists(rev_inf):
                images = [
                    CustomAnalysisImage(name='%s (consistency)' % custom.name,
                                        image_file=fwd_inf,
                                        label='%s (consistency)' % custom.name,
                                        stat='z-score',
                                        display=1,
                                        download=1),
                    CustomAnalysisImage(name='%s (specificity)' % custom.name,
                                        image_file=rev_inf,
                                        label='%s (specificity)' % custom.name,
                                        stat='z-score',
                                        display=1,
                                        download=1)
                ]
                custom.images = images
                custom.last_run_at = dt.datetime.utcnow()
                db.session.add(custom)
                db.session.commit()
                return redirect(
                    url_for('analyses.show_custom_analysis', uid=uid))
        return error_page("An unspecified error occurred while trying "
                          "to run the custom meta-analysis. Please try "
                          "again.")

    return redirect(url_for('analyses.show_custom_analysis', uid=uid))


add_blueprint(bp)
Ejemplo n.º 2
0
@bp.route('/<string:uuid>/scatter/<string:analysis>')
def get_scatter(uuid, analysis):
    outfile = join(settings.DECODING_SCATTERPLOTS_DIR,
                   uuid + '_' + analysis + '.png')
    if not exists(outfile):
        """ Return .png of scatterplot between the uploaded image and specified
        analysis. """
        dec = Decoding.query.filter_by(uuid=uuid).first()
        if dec is None:
            abort(404)
        result = tasks.make_scatterplot.delay(
            dec.filename, analysis, dec.uuid, outfile=outfile,
            x_lab=dec.name).wait()
        if not exists(outfile):
            abort(404)
    return send_file(
        outfile, as_attachment=False, attachment_filename=basename(outfile))

### API ROUTES ###


@bp.route('/data/')
def get_data_api():
    if 'url' in request.args:
        id = decode_url(request.args['url'], render=False)
    elif 'neurovault' in request.args:
        id = decode_neurovault(request.args['neurovault'], render=False)
    return get_data(id)

add_blueprint(bp)