def test_colors(interactive=False): peak_dirs, peak_vals, peak_affine = generate_peaks() valid_mask = np.abs(peak_dirs).max(axis=(-2, -1)) > 0 indices = np.nonzero(valid_mask) scene = window.Scene() colors = [[1, 0, 0], [1, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1], [0, 0, 1], [1, 1, 0]] peak_actor = PeakActor(peak_dirs, indices, values=peak_vals, affine=peak_affine, colors=colors) scene.add(peak_actor) scene.azimuth(30) scene.reset_camera() scene.reset_clipping_range() if interactive: window.show(scene) arr = window.snapshot(scene) report = window.analyze_snapshot(arr, colors=colors) npt.assert_equal(report.objects, 4)
def test_lookup_colormap(interactive=False): peak_dirs, peak_vals, peak_affine = generate_peaks() valid_mask = np.abs(peak_dirs).max(axis=(-2, -1)) > 0 indices = np.nonzero(valid_mask) scene = window.Scene() colors = [.0, .1, .2, .5, .8, .9, 1] hue = (0, 1) # Red to blue saturation = (0, 1) # White to full saturation lut_cmap = actor.colormap_lookup_table(hue_range=hue, saturation_range=saturation) peak_actor = PeakActor(peak_dirs, indices, values=peak_vals, affine=peak_affine, colors=colors, lookup_colormap=lut_cmap) scene.add(peak_actor) scene.azimuth(30) scene.reset_camera() scene.reset_clipping_range() if interactive: window.show(scene) arr = window.snapshot(scene) report = window.analyze_snapshot(arr) npt.assert_equal(report.objects, 4)
def test_global_opacity(): peak_dirs, peak_vals, peak_affine = generate_peaks() valid_mask = np.abs(peak_dirs).max(axis=(-2, -1)) > 0 indices = np.nonzero(valid_mask) peak_actor = PeakActor(peak_dirs, indices, values=peak_vals, affine=peak_affine) npt.assert_equal(peak_actor.global_opacity, 1) peak_actor.global_opacity = .5 npt.assert_equal(peak_actor.global_opacity, .5) peak_actor.global_opacity = 0 npt.assert_equal(peak_actor.global_opacity, 0)
def test_min_centers(): peak_dirs, peak_vals, peak_affine = generate_peaks() valid_mask = np.abs(peak_dirs).max(axis=(-2, -1)) > 0 indices = np.nonzero(valid_mask) peak_actor = PeakActor(peak_dirs, indices, values=peak_vals, affine=peak_affine) npt.assert_equal(peak_actor.min_centers, [0, 0, 0])
def test_linewidth(): peak_dirs, peak_vals, peak_affine = generate_peaks() valid_mask = np.abs(peak_dirs).max(axis=(-2, -1)) > 0 indices = np.nonzero(valid_mask) peak_actor = PeakActor(peak_dirs, indices, values=peak_vals, affine=peak_affine) npt.assert_equal(peak_actor.linewidth, 1) peak_actor.linewidth = 2 npt.assert_equal(peak_actor.linewidth, 2) peak_actor.linewidth = 5 npt.assert_equal(peak_actor.linewidth, 5) peak_actor.linewidth = 0 npt.assert_equal(peak_actor.linewidth, 0)
def test_symmetric_param(): dirs000 = np.array([[1, 0, 0], [0, -1, 0]]) dirs001 = np.array([[1, 1, 0], [-1, 1, 0]]) peak_dirs = np.zeros((1, 1, 2, 2, 3)) peak_dirs[0, 0, 0, :, :] = dirs000 peak_dirs[0, 0, 1, :, :] = dirs001 valid_mask = np.abs(peak_dirs).max(axis=(-2, -1)) > 0 indices = np.nonzero(valid_mask) peak_actor_asym = PeakActor(peak_dirs, indices, symmetric=False) actor_points = utils.vertices_from_actor(peak_actor_asym) desired_points = np.array([[0, 0, 0], [1, 0, 0], [0, 0, 0], [0, -1, 0], [0, 0, 1], [1, 1, 1], [0, 0, 1], [-1, 1, 1]]) npt.assert_array_equal(actor_points, desired_points) peak_actor_sym = PeakActor(peak_dirs, indices) actor_points = utils.vertices_from_actor(peak_actor_sym) desired_points = np.array([[-1, 0, 0], [1, 0, 0], [0, 1, 0], [0, -1, 0], [-1, -1, 1], [1, 1, 1], [1, -1, 1], [-1, 1, 1]]) npt.assert_array_equal(actor_points, desired_points)
def test_display_cross_section(): peak_dirs, peak_vals, peak_affine = generate_peaks() valid_mask = np.abs(peak_dirs).max(axis=(-2, -1)) > 0 indices = np.nonzero(valid_mask) peak_actor = PeakActor(peak_dirs, indices, values=peak_vals, affine=peak_affine) peak_actor.display_cross_section(0, 0, 0) npt.assert_equal(peak_actor.is_range, False) npt.assert_equal(peak_actor.cross_section, [0, 0, 0]) peak_actor.display_extent(0, 0, 0, 1, 0, 2) npt.assert_equal(peak_actor.is_range, True) peak_actor.display_cross_section(0, 0, 0) npt.assert_equal(peak_actor.is_range, False)