Пример #1
0
def plot_histogram(image,
                   title="Image Histogram",
                   height=400,
                   width=1000,
                   view_in_browser=True,
                   bins=25,
                   remove_zeros=True):
    '''plot interactive histogram (in browser)'''

    image = get_nii_obj(image)[0]
    data = image.get_data()
    histogram = get_histogram_data(data, bins=bins, remove_zeros=remove_zeros)
    bins = '"%s"' % ('","'.join(["%.2f" % (x) for x in histogram["bins"]]))
    counts = '"%s"' % ('","'.join(["%s" % (x) for x in histogram["counts"]]))
    template = get_template("histogram")
    elements = [{
        "HISTOGRAM_DATA": counts
    }, {
        "HISTOGRAM_LABELS": bins
    }, {
        "HISTOGRAM_TITLE": title
    }, {
        "HISTOGRAM_HEIGHT": height
    }, {
        "HISTOGRAM_WIDTH": width
    }]
    for element in elements:
        template = add_string(element, template)

    if view_in_browser == True:
        view(template)
    else:
        return template
Пример #2
0
def plot_histogram(image,
                   title="Image Histogram",
                   height=400,
                   width=1000,
                   view_in_browser=True,
                   bins=25,
                   remove_zeros=True):

    '''plot interactive histogram (in browser)'''

    image = get_nii_obj(image)[0]
    data = image.get_data()
    histogram = get_histogram_data(data,bins=bins,remove_zeros=remove_zeros)
    bins = '"%s"' %('","'.join(["%.2f" %(x) for x in histogram["bins"]]))
    counts = '"%s"' %('","'.join(["%s" %(x) for x in histogram["counts"]]))
    template = get_template("histogram")  
    elements = [{"HISTOGRAM_DATA":counts},
                {"HISTOGRAM_LABELS":bins},
                {"HISTOGRAM_TITLE":title},
                {"HISTOGRAM_HEIGHT":height},
                {"HISTOGRAM_WIDTH":width}]
    for element in elements:
        template = add_string(element,template)      

    if view_in_browser==True:
        view(template)  
    else:
        return template
Пример #3
0
# Make a connectogram d3 visualization from a square connectivity matrix

from pybraincompare.compare.network import connectogram
from pybraincompare.template.visual import view
import pandas

# A square matrix, tab separated file, with row and column names corresponding to node names
connectivity_matrix = "data/parcel_matrix.tsv"

parcel_info = pandas.read_csv("data/parcels.csv")
networks = list(parcel_info["Community"])
# should be in format "L-1" for hemisphere (L or R) and group number (1..N)
groups = ["%s-%s" %(parcel_info["Hem"][x],parcel_info["ID"][x]) for x in range(0,parcel_info.shape[0])]

# A threshold value for the connectivity matrix to determine neighbors, eg, a value of .95 means we only keep top 5% of positive and negative connections, and the user can explore this top percent
threshold = 0.99

html_snippet = connectogram(matrix_file=connectivity_matrix,groups=groups,threshold=threshold,network_names=networks)

view(html_snippet)
Пример #4
0
#!/usr/bin/env python2

from pybraincompare.ontology.tree import named_ontology_tree_from_tsv
from pybraincompare.template.visual import view

# This defines a "mock" ontology for the openfmri proof of concept set - names should be unique
relationship_table = "data/cogatlas_annotate_triples.tsv"

# Create a data structure for d3 visualization and data analysis (no output json, specify with output_json=)
data_structure = named_ontology_tree_from_tsv(relationship_table)
html_snippet = make_ontology_tree_d3(data_structure)

# View in browser!
view(html_snippet)