def test_UC_generate_movie_by_index(self):
        # Setup Uniform Contrast Objects
        uc = sr.UniformContrast(monitor=self.monitor, indicator=self.indicator, duration=0.1,
                                color=1., pregap_dur=1., postgap_dur=1.5, background=0.,
                                coordinate='degree')

        uc_full_seq, uc_full_dict = uc.generate_movie_by_index()

        assert (uc_full_seq.shape == (2, 120, 160))
        assert (len(uc_full_dict['stimulation']['index_to_display']) == 156)

        frames_unique = uc_full_dict['stimulation']['frames_unique']
        all_frames = []
        for ind in uc_full_dict['stimulation']['index_to_display']:
            all_frames.append(frames_unique[ind])

        # Parameters defining where the frame blocks should start and end
        ref_rate = self.monitor.refresh_rate
        pregap_end = uc.pregap_frame_num
        on_end = pregap_end + int(uc.duration*ref_rate)
        postgap_end = on_end + uc.postgap_frame_num

        for i in range(pregap_end):
            assert (all_frames[i] == (0., -1.))

        for i in range(pregap_end, on_end):
            assert (all_frames[i] == (1., 1.))

        for i in range(on_end, postgap_end):
            assert (all_frames[i] == (0., -1.))
    def test_initial_background(self):

        import retinotopic_mapping.StimulusRoutines as stim

        log_dir = os.path.join(curr_folder, 'test_data')

        displayer = ds.DisplaySequence(log_dir=log_dir,
                                       backupdir=None,
                                       identifier='TEST',
                                       display_iter=1,
                                       mouse_id='MOUSE',
                                       user_id='USER',
                                       psychopy_mon='testMonitor',
                                       is_by_index=True,
                                       is_interpolate=False,
                                       is_triggered=False,
                                       is_save_sequence=False,
                                       trigger_event="negative_edge",
                                       trigger_NI_dev='Dev1',
                                       trigger_NI_port=1,
                                       trigger_NI_line=0,
                                       is_sync_pulse=False,
                                       sync_pulse_NI_dev='Dev1',
                                       sync_pulse_NI_port=1,
                                       sync_pulse_NI_line=1,
                                       display_screen=0,
                                       initial_background_color=0.,
                                       color_weights=(0., 1., 1.))

        # print(displayer.initial_background_color)

        uc = stim.UniformContrast(monitor=self.monitor,
                                  indicator=self.indicator,
                                  pregap_dur=0.1,
                                  postgap_dur=0.1,
                                  coordinate='degree',
                                  background=0.,
                                  duration=0.1,
                                  color=0.8)

        displayer.set_stim(uc)
        log_path = displayer.trigger_display()

        import shutil
        log_dir = os.path.join(curr_folder, 'test_data', 'visual_display_log')
        shutil.rmtree(log_dir)
Ejemplo n.º 3
0
# -*- 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()
                     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, is_save_sequence=ds_is_save_sequence,
                     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 ================================
Ejemplo n.º 5
0
import retinotopic_mapping.StimulusRoutines as stim
from retinotopic_mapping.MonitorSetup import Monitor, Indicator
from retinotopic_mapping.DisplayStimulus import DisplaySequence

# This script is meant to be used to test the synchronization between the stim. pc and the microscope, by flashing gray images at the sensor

mon = Monitor(resolution=(1024, 1280), dis=20., mon_width_cm=33.28, mon_height_cm=26.624, refresh_rate=60.0)

# 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)

uc = stim.UniformContrast(mon, ind, duration=1, color=0)
repeated_stim = stim.CombinedStimuli(mon, ind, background=-1, pregap_dur=1, postgap_dur=0)
repeated_stim.set_stimuli([uc]*10) # set the number of iterations here

ds = DisplaySequence(log_dir="C:/data", is_by_index=True, display_screen=1, is_sync_pulse_LJ=True)

ds.set_stim(repeated_stim)
ds.trigger_display(fullscr=False)