def test_user_given_cmap_with_colorbar(): img = load_mni152_template() oslicer = OrthoSlicer(cut_coords=(0, 0, 0)) # Test with cmap given as a string oslicer.add_overlay(img, cmap='Paired', colorbar=True) oslicer.close()
def test_demo_ortho_slicer(): # This is only a smoke test mp.use('template', warn=False) import matplotlib.pyplot as plt plt.switch_backend('template') plt.clf() oslicer = OrthoSlicer(cut_coords=(0, 0, 0)) img = load_mni152_template() oslicer.add_overlay(img, cmap=plt.cm.gray) oslicer.close()
def test_contour_fillings_levels_in_add_contours(): oslicer = OrthoSlicer(cut_coords=(0, 0, 0)) img = load_mni152_template() # levels should be atleast 2 # If single levels are passed then we force upper level to be inf oslicer.add_contours(img, filled=True, colors='r', alpha=0.2, levels=[0.]) # If two levels are passed, it should be increasing from zero index # In this case, we simply omit appending inf oslicer.add_contours(img, filled=True, colors='b', alpha=0.1, levels=[0., 0.2])
def test_demo_ortho_slicer(): # This is only a smoke test oslicer = OrthoSlicer(cut_coords=(0, 0, 0)) img = load_mni152_template() oslicer.add_overlay(img, cmap=plt.cm.gray) oslicer.title("display mode is ortho") oslicer.close()
def test_data_complete_mask(): """This special case test is due to matplotlib 2.1.0. When the data is completely masked, then we have plotting issues See similar issue #9280 reported in matplotlib. This function tests the patch added for this particular issue. """ # data is completely masked data = np.zeros((10, 20, 30)) affine = np.eye(4) img = nibabel.Nifti1Image(data, affine) oslicer = OrthoSlicer(cut_coords=(0, 0, 0)) oslicer.add_overlay(img) oslicer.close()
def test_annotations(): # Check calls to display.annotate() # In particular, exercise some of the keyword arguments for scale bars orthoslicer = OrthoSlicer(cut_coords=(None, None, None)) orthoslicer.annotate(size=10, left_right=True, positions=False) orthoslicer.annotate(size=12, left_right=False, positions=False, scalebar=True, scale_size=2.5, scale_units='cm', scale_loc=3) orthoslicer.close()
def test_add_markers_cut_coords_is_none(): """Tests a special case for ``add_markers`` when ``cut_coords`` are None. This case is used when coords are placed on glass brain. """ orthoslicer = OrthoSlicer(cut_coords=(None, None, None)) orthoslicer.add_markers([(0, 0, 2)]) orthoslicer.close()
def test_annotations(): """Tests for ``display.annotate()``. In particular, exercise some of the keyword arguments for scale bars. """ orthoslicer = OrthoSlicer(cut_coords=(None, None, None)) orthoslicer.annotate(size=10, left_right=True, positions=False) orthoslicer.annotate(size=12, left_right=False, positions=False, scalebar=True, scale_size=2.5, scale_units='cm', scale_loc=3, frameon=True) orthoslicer.close()
def test_demo_ortho_slicer(): # This is only a smoke test mp.use('template', warn=False) import pylab as pl pl.switch_backend('template') pl.clf() oslicer = OrthoSlicer(cut_coords=(0, 0, 0)) img = load_mni152_template() oslicer.add_overlay(img, cmap=pl.cm.gray) oslicer.close()
def test_contour_fillings_levels_in_add_contours(): oslicer = OrthoSlicer(cut_coords=(0, 0, 0)) img = load_mni152_template() # levels should be atleast 2 # If single levels are passed then we force upper level to be inf oslicer.add_contours(img, filled=True, colors='r', alpha=0.2, levels=[0.]) # If two levels are passed, it should be increasing from zero index # In this case, we simply omit appending inf oslicer.add_contours(img, filled=True, colors='b', alpha=0.1, levels=[0., 0.2]) # without passing colors and alpha. In this case, default values are # chosen from matplotlib oslicer.add_contours(img, filled=True, levels=[0., 0.2]) # levels with only one value oslicer.add_contours(img, filled=True, levels=[0.]) # without passing levels, should work with default levels from # matplotlib oslicer.add_contours(img, filled=True)
def test_add_markers_cut_coords_is_none(): # A special case test for add_markers when cut_coords are None. This # case is used when coords are placed on glass brain orthoslicer = OrthoSlicer(cut_coords=(None, None, None)) orthoslicer.add_markers([(0, 0, 2)]) orthoslicer.close()
def test_user_given_cmap_with_colorbar(img): """Test cmap provided as a string with ``OrthoSlicer``.""" oslicer = OrthoSlicer(cut_coords=(0, 0, 0)) oslicer.add_overlay(img, cmap='Paired', colorbar=True) oslicer.close()
def test_demo_ortho_slicer(): # This is only a smoke test oslicer = OrthoSlicer(cut_coords=(0, 0, 0)) img = load_mni152_template() oslicer.add_overlay(img, cmap=plt.cm.gray) oslicer.close()
def test_position_annotation_with_decimals(): """Test of decimals position annotation with precision of 2.""" orthoslicer = OrthoSlicer(cut_coords=(0, 0, 0)) orthoslicer.annotate(positions=True, decimals=2) orthoslicer.close()