def test_show_image(): m = si.BrainObservatoryMonitor() img = np.zeros(si.MONITOR_DIMENSIONS) m.show_image(img, show=False, warp=True, mask=False) m.show_image(img, show=False, warp=False, mask=True)
def test_mask(): m = si.BrainObservatoryMonitor() assert(m._mask is None) assert(m.mask.sum() == 931286) assert(m.mask.shape == si.MONITOR_DIMENSIONS) assert(m._mask is not None)
def test_spatial_frequency_to_pix_per_cycle(): m = si.BrainObservatoryMonitor() x1 = m.spatial_frequency_to_pix_per_cycle(.1, 15.0) x2 = m.spatial_frequency_to_pix_per_cycle(.05, 15.0) np.testing.assert_almost_equal(x1, 97.7072500845) np.testing.assert_almost_equal(x2/x1, 2)
def test_natural_movie_image_to_screen(data_set): compare_set = set(data_set.list_stimuli()).intersection(si.NATURAL_MOVIE_STIMULUS_TYPES) if len(compare_set) > 0: for stimulus_type in compare_set: template = data_set.get_stimulus_template(stimulus_type) m = si.BrainObservatoryMonitor() m.natural_movie_image_to_screen(template[0, :, :]).shape == si.MONITOR_DIMENSIONS
def test_lsn_image_to_screen(data_set): compare_set = set(data_set.list_stimuli()).intersection(si.LOCALLY_SPARSE_NOISE_STIMULUS_TYPES) if len(compare_set) > 0: for stimulus_type in compare_set: template = data_set.get_stimulus_template(stimulus_type) m = si.BrainObservatoryMonitor() m.lsn_image_to_screen(template[0,:,:]).shape == si.MONITOR_DIMENSIONS
def test_pixels_to_visual_degrees(): m = si.BrainObservatoryMonitor() np.testing.assert_almost_equal(m.pixels_to_visual_degrees(45), 4.64716996476) np.testing.assert_almost_equal(m.pixels_to_visual_degrees(45, small_angle_approximation=False), 4.64462483116) np.testing.assert_almost_equal(m.pixels_to_visual_degrees(1), 0.103270443661) np.testing.assert_almost_equal(m.pixels_to_visual_degrees(1, small_angle_approximation=False), 0.103270415704)
def test_map_stimulus(): m = si.BrainObservatoryMonitor() test_list = [(0, 0), (-5.333333333333333, -7.333333333333333), (-5.333333333333333, -7.333333333333333), (-2.6666666666666665, -3.6666666666666665), (-16.88888888888889, 0.0), (-16.88888888888889, 0.0), (-16.88888888888889, 0.0), (-141.0, -373.0), (0, 0), (0, 0), (240.0, 330.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (50.666666666666664, 104.5), (50.666666666666664, 104.5), (50.666666666666664, 104.5), (99.0, -43.0), (240.0, 330.0), (240.0, 330.0), (240.0, 330.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (50.666666666666664, 104.5), (50.666666666666664, 104.5), (50.666666666666664, 104.5), (99.0, -43.0), (240.0, 330.0), (240.0, 330.0), (240.0, 330.0), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (50.666666666666664, 104.5), (50.666666666666664, 104.5), (50.666666666666664, 104.5), (99.0, -43.0), (240.0, 330.0), (240.0, 330.0), (60.0, 0.0), (-4.0, -7.333333333333333), (-4.0, -7.333333333333333), (-2.0, -3.6666666666666665), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (-81.0, -373.0), (60.0, 0.0), (60.0, 0.0), (60.0, 0.0), (-4.0, -7.333333333333333), (-4.0, -7.333333333333333), (-2.0, -3.6666666666666665), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (-81.0, -373.0), (60.0, 0.0), (60.0, 0.0), (60.0, 0.0), (-4.0, -7.333333333333333), (-4.0, -7.333333333333333), (-2.0, -3.6666666666666665), (0.0, 0.0), (0.0, 0.0), (0.0, 0.0), (-81.0, -373.0), (60.0, 0.0), (60.0, 0.0), (141.0, 373.0), (-2.2, 0.9555555555555556), (-2.2, 0.9555555555555556), (-1.1, 0.4777777777777778), (22.8, 118.11666666666666), (22.8, 118.11666666666666), (22.8, 118.11666666666666), (0.0, 0.0), (141.0, 373.0), (141.0, 373.0), (0, 0), (-5.333333333333333, -7.333333333333333), (-5.333333333333333, -7.333333333333333), (-2.6666666666666665, -3.6666666666666665), (-16.88888888888889, 0.0), (-16.88888888888889, 0.0), (-16.88888888888889, 0.0), (-141.0, -373.0), (0, 0), (0, 0), (0, 0), (-5.333333333333333, -7.333333333333333), (-5.333333333333333, -7.333333333333333), (-2.6666666666666665, -3.6666666666666665), (-16.88888888888889, 0.0), (-16.88888888888889, 0.0), (-16.88888888888889, 0.0), (-141.0, -373.0), (0, 0), (0, 0)] counter = 0 for source_stimulus in sorted(si.all_stimuli()): for target_stimulus in sorted(si.all_stimuli()): tmp = m.map_stimulus((0,0), source_stimulus, target_stimulus) np.testing.assert_array_almost_equal(tmp, test_list[counter]) counter += 1 np.testing.assert_array_almost_equal(m.map_stimulus(tmp, target_stimulus, source_stimulus), np.array([0,0]))
def test_grating_to_screen(data_set): compare_set = set(data_set.list_stimuli()).intersection([si.STATIC_GRATINGS, si.DRIFTING_GRATINGS]) if len(compare_set) > 0: for stimulus_type in compare_set: m = si.BrainObservatoryMonitor() curr_row = data_set.get_stimulus_table(stimulus_type).iloc[10] phase = 0 spatial_frequency = .04 orientation = curr_row.orientation template = m.grating_to_screen(phase, spatial_frequency, orientation) assert m.natural_movie_image_to_screen(template).shape == si.MONITOR_DIMENSIONS
def test_pixels_to_visual_degrees(): m = si.BrainObservatoryMonitor() np.testing.assert_almost_equal(m.pixels_to_visual_degrees(1), 0.103270443661,10)
def test_visual_degrees_to_pixels(): m = si.BrainObservatoryMonitor() np.testing.assert_approx_equal(m.visual_degrees_to_pixels(4.5), 43.5749072092)
def test_get_mask(): m = si.BrainObservatoryMonitor() mask = m.get_mask() assert mask.sum() == 931286 assert mask.shape == si.MONITOR_DIMENSIONS