def test_FC_generate_movie(self): fc = sr.FlashingCircle(monitor=self.monitor, indicator=self.indicator, center=(10., 90.), flash_frame_num=30, color=-1., pregap_dur=0.1, postgap_dur=1.0, background=1., coordinate='degree', midgap_dur=0.5, iteration=10) fc_full_seq, fc_full_dict = fc.generate_movie() assert (fc_full_seq.shape == (636, 120, 160)) assert (len(fc_full_dict['stimulation']['frames']) == 636) frames = fc_full_dict['stimulation']['frames'] # print frames # Parameters defining where the frame blocks should start and end flashing_end = fc.pregap_frame_num + fc.flash_frame_num midgap_end = flashing_end + fc.midgap_frame_num next_flash_end = midgap_end + fc.flash_frame_num for i in range(fc.pregap_frame_num): assert (frames[i] == (0, -1.)) for i in range(fc.pregap_frame_num, flashing_end): assert (frames[i] == (1, 1.)) for i in range(flashing_end, midgap_end): assert (frames[i] == (0., -1.)) for i in range(midgap_end, next_flash_end): assert (frames[i] == (1, 1.)) assert (fc_full_seq[6, 39, 124] == -1.)
def test_FC_generate_movie_by_index(self): fc = sr.FlashingCircle(monitor=self.monitor, indicator=self.indicator, center=(10., 90.), flash_frame_num=30, color=-1., pregap_dur=0.5, postgap_dur=1.2, background=1., coordinate='degree', midgap_dur=1., iteration=3) fc_full_seq, fc_full_dict = fc.generate_movie_by_index() assert (fc_full_seq.shape == (2, 120, 160)) # print len(fc_full_dict['stimulation']['index_to_display']) assert (len(fc_full_dict['stimulation']['index_to_display']) == 312) frames_unique = fc_full_dict['stimulation']['frames_unique'] frames = [] for ind in fc_full_dict['stimulation']['index_to_display']: frames.append(frames_unique[ind]) # Parameters defining where the frame blocks should start and end flashing_end = fc.pregap_frame_num + fc.flash_frame_num midgap_end = flashing_end + fc.midgap_frame_num next_flash_end = midgap_end + fc.flash_frame_num for i in range(fc.pregap_frame_num): assert (frames[i] == (0, -1.)) for i in range(fc.pregap_frame_num, flashing_end): assert (frames[i] == (1, 1.)) for i in range(flashing_end, midgap_end): assert (frames[i] == (0., -1.)) for i in range(midgap_end, next_flash_end): assert (frames[i] == (1, 1.)) assert (fc_full_seq[1, 39, 124] == -1)
initial_background_color=ds_initial_background_color, color_weights=ds_color_weights) # ================================================================================= # ========================== Uniform Contrast ===================================== uc = stim.UniformContrast(monitor=mon, indicator=ind, pregap_dur=pregap_dur, postgap_dur=postgap_dur, coordinate=coordinate, background=background, duration=uc_duration, color=uc_color) # ================================================================================= # ======================= Flashing Circle ========================================= fc = stim.FlashingCircle(monitor=mon, indicator=ind, pregap_dur=pregap_dur, postgap_dur=postgap_dur, coordinate=coordinate, background=background, center=fc_center, radius=fc_radius, color=fc_color, flash_frame_num=fc_flash_frame_num, midgap_dur=fc_midgap_dur, iteration=fc_iteration, is_smooth_edge=fc_is_smooth_edge, smooth_width_ratio=fc_smooth_width_ratio, smooth_func=fc_smooth_func) # ================================================================================= # ============================ SinusoidalLuminance ================================ sl = stim.SinusoidalLuminance(monitor=mon, indicator=ind, pregap_dur=pregap_dur, postgap_dur=postgap_dur, coordinate=coordinate, background=background, max_level=sl_max_level, min_level=sl_min_level, frequency=sl_frequency, cycle_num=sl_cycle_num, start_phase=sl_start_phase, midgap_dur=sl_midgap_dur) # ================================================================================= # ======================== Sparse Noise ===========================================
mon_width_cm=52., mon_height_cm=32.) mon.plot_map() # Hiding indicator on a "throwaway" monitor mon_temp = Monitor(resolution=(8, 8), dis=15., mon_width_cm=10., mon_height_cm=10.) ind = Indicator(mon_temp) ds = DisplaySequence(log_dir='C:/data', is_by_index=False, is_save_sequence=True) fc = stim.FlashingCircle(monitor=mon, indicator=ind, coordinate='degree', center=(0., 60.), radius=10., is_smooth_edge=False, smooth_width_ratio=0.2, smooth_func=stim.blur_cos, color=1., flash_frame_num=60, pregap_dur=2., postgap_dur=3., background=-1., midgap_dur=1., iteration=1) ds.set_stim(fc) ds.trigger_display() plt.show()
# is_sync_pulse=False, # display_screen=1, # is_by_index=True) # # ds.set_stim(uniform_contrast) # ds.trigger_display() #============================================================================== #======================= Flashing Circle Stimulus ============================= flashing_circle = stim.FlashingCircle(monitor=mon, indicator=ind, coordinate='degree', center=(20., 30.), radius=30., color=-1., flash_frame_num=30, pregap_dur=2., postgap_dur=3., background=0., is_smooth_edge=True, smooth_width_ratio=0.2, smooth_func=stim.blur_cos) ds = DisplaySequence(log_dir=r'C:\data', backupdir=None, is_triggered=False, is_sync_pulse=False, is_by_index=False, display_iter=2, display_screen=0, is_interpolate=False) ds.set_stim(flashing_circle)
import retinotopic_mapping.StimulusRoutines as stim from retinotopic_mapping.MonitorSetup import Monitor, Indicator from retinotopic_mapping.DisplayStimulus import DisplaySequence import matplotlib import matplotlib.pyplot as plt matplotlib.use('TkAgg') if __name__ == '__main__': mon = Monitor(resolution=(600, 800), downsample_rate=2, dis=20., mon_width_cm=39, mon_height_cm=29, refresh_rate=60.0) mon.plot_map() plt.show() # creating a monitor object to display the indicator on (since we don' use it) mon_bin = Monitor(resolution=(0, 0), dis=15., mon_width_cm=52., mon_height_cm=32.) ind = Indicator(mon_bin, width_cm=3, height_cm=3, is_sync=True, freq=1) flashing_circle = stim.FlashingCircle(mon, ind, coordinate='linear', center=(2.5, 2.5), radius=2.5, color=1, midgap_dur=2, iteration=5) ds = DisplaySequence(log_dir="C:/data", is_by_index=True, display_screen=1, is_sync_pulse_LJ=False) ds.set_stim(flashing_circle) ds.trigger_display(fullscr=True)