# initialize LocallySparseNoise object
lsn = stim.LocallySparseNoise(monitor=mon, indicator=ind, pregap_dur=pregap_dur,
                              postgap_dur=postgap_dur, coordinate=coordinate,
                              background=background, subregion=lsn_subregion,
                              grid_space=lsn_grid_space, sign=lsn_sign,
                              probe_size=lsn_probe_size, probe_orientation=lsn_probe_orientation,
                              probe_frame_num=lsn_probe_frame_num, iteration=lsn_iteration,
                              is_include_edge=lsn_is_include_edge, min_distance=lsn_min_distance)

# initialize DisplaySequence object
ds = DisplaySequence(log_dir=ds_log_dir, backupdir=ds_backupdir,
                     identifier=ds_identifier, display_iter=ds_display_iter,
                     mouse_id=ds_mouse_id, user_id=ds_user_id,
                     psychopy_mon=ds_psychopy_mon, is_by_index=ds_is_by_index,
                     is_interpolate=ds_is_interpolate, is_triggered=ds_is_triggered,
                     trigger_event=ds_trigger_event, trigger_NI_dev=ds_trigger_NI_dev,
                     trigger_NI_port=ds_trigger_NI_port, trigger_NI_line=ds_trigger_NI_line,
                     is_sync_pulse=ds_is_sync_pulse, sync_pulse_NI_dev=ds_sync_pulse_NI_dev,
                     sync_pulse_NI_port=ds_sync_pulse_NI_port,
                     sync_pulse_NI_line=ds_sync_pulse_NI_line,
                     display_screen=ds_display_screen,
                     initial_background_color=ds_initial_background_color)

# display
# =============================== display =========================================
ds.set_stim(lsn)
ds.trigger_display()
plt.show()
# =================================================================================
                         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.,
                         midgap_dur=1.,
                         iteration=1)
ds.set_stim(fc)
camera.trigger.set()
time.sleep(
    0.1
)  # let the first camera frames be below target 10Hz (memory allocation or who knows why)
ds.trigger_display(fullscr=False)
plt.show()
camera.trigger.clear()

if camera.camera_error_trigger.is_set():  # do not save incomplete data
    print('Experiment stopped due to frame drop in camera.')
    sys.exit(0)
# print('Seconds elapsed between camera stop time and stimulus end: {0}'.format(time.time()-camera.stopped_time))
camera.join()
with Hdf5io(
        camcfg.CAMERA['output'] if save_to_hdf5 else camcfg.CAMERA['output'] +
        '/timing.hdf5',
        filelocking=False) as output_file:
    output_file.stimulus_parameters = stimulus_parameters
    output_file.stimulus_frame_timestamps = ds.frame_ts_start
    output_file.stimulusLog = pickle.dumps(ds.seq_log,
# -*- coding: utf-8 -*-
"""
the minimum script to run 10 seconds of black screen
"""

import matplotlib.pyplot as plt
import retinotopic_mapping.StimulusRoutines as stim
from retinotopic_mapping.MonitorSetup import Monitor, Indicator
from retinotopic_mapping.DisplayStimulus import DisplaySequence

# Initialize Monitor object
mon = Monitor(resolution=(1200, 1920), dis=15., mon_width_cm=52., mon_height_cm=32.)

# Initialize Inicator object
ind = Indicator(mon)

# Initialize DisplaySequence object
ds = DisplaySequence(log_dir='C:/data')

# Initialize UniformContrast object
uc = stim.UniformContrast(monitor=mon, indicator=ind, duration=10., color=-1.)

# set uniform contrast stimulus into the DisplaySequence object
ds.set_stim(uc)

# start display
ds.trigger_display()

# plot distribution of frame duration
plt.show()
import retinotopic_mapping.StimulusRoutines as stim
from retinotopic_mapping.MonitorSetup import Monitor, Indicator
from retinotopic_mapping.DisplayStimulus import DisplaySequence

mon = Monitor(resolution=(768, 1360),
              dis=15.,
              mon_width_cm=52.,
              mon_height_cm=32.)

ind = Indicator(mon)

# ks = stim.KSstim(mon, ind)
ds = DisplaySequence(log_dir="data", is_by_index=False)

# ds.set_stim(ks)
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,
                         flash_frame_num=60,
                         pregap_dur=2.,
                         postgap_dur=3.,
                         midgap_dur=1.,
                         iteration=1)
ds.set_stim(fc)
ds.trigger_display(fullscr=True)
plt.show()