Example #1
0
def test_json_view_data():

    # simple simulated data for stat_img and background
    bg_img, data = _simulate_img()
    stat_map_img, data = _simulate_img()

    # make a mask
    mask_img = new_img_like(stat_map_img, data > 0, stat_map_img.affine)

    # Get color bar and data ranges
    colors = colorscale('cold_hot',
                        data.ravel(),
                        threshold=0,
                        symmetric_cmap=True,
                        vmax=1)

    # Build a sprite
    json_view = html_stat_map._json_view_data(bg_img,
                                              stat_map_img,
                                              mask_img,
                                              bg_min=0,
                                              bg_max=1,
                                              colors=colors,
                                              cmap='cold_hot',
                                              colorbar=True)

    # Check the presence of critical fields
    assert isinstance(json_view['bg_base64'], str)
    assert isinstance(json_view['stat_map_base64'], str)
    assert isinstance(json_view['cm_base64'], str)

    return json_view, data
Example #2
0
def _get_data_and_json_view(black_bg, cbar):
    # simple simulated data for stat_img and background
    bg_img, data = _simulate_img()
    stat_map_img, data = _simulate_img()

    # make a mask
    mask_img = new_img_like(stat_map_img, data > 0, stat_map_img.affine)

    # Get color bar and data ranges
    colors = colorscale('cold_hot',
                        data.ravel(),
                        threshold=0,
                        symmetric_cmap=True,
                        vmax=1)

    # Build a sprite
    json_view = html_stat_map._json_view_data(bg_img,
                                              stat_map_img,
                                              mask_img,
                                              bg_min=0,
                                              bg_max=1,
                                              black_bg=black_bg,
                                              colors=colors,
                                              cmap='cold_hot',
                                              colorbar=cbar)
    return data, json_view
def test_json_view_data():

    # simple simulated data for stat_img and background
    bg_img, data = _simulate_img()
    stat_map_img, data = _simulate_img()

    # make a mask
    mask_img = new_img_like(stat_map_img, data > 0, stat_map_img.affine)

    # Get color bar and data ranges
    colors = colorscale('cold_hot', data.ravel(), threshold=0,
                        symmetric_cmap=True, vmax=1)

    # Build a sprite
    json_view = html_stat_map._json_view_data(
        bg_img, stat_map_img, mask_img, bg_min=0, bg_max=1, colors=colors,
        cmap='cold_hot', colorbar=True)

    # Check the presence of critical fields
    assert isinstance(json_view['bg_base64'], _basestring)
    assert isinstance(json_view['stat_map_base64'], _basestring)
    assert isinstance(json_view['cm_base64'], _basestring)

    return json_view, data