Ejemplo n.º 1
0
 def setup_class(self):
     self.win = Window(monitor='testMonitor',
                       screen=1,
                       fullscr=True,
                       color='gray',
                       useFBO=True)
     self.warper = Warper(self.win,
                          warp='spherical',
                          warpfile="",
                          warpGridsize=128,
                          eyepoint=[0.5, 0.5],
                          flipHorizontal=False,
                          flipVertical=False)
     self.warper.dist_cm = 15
     self.g = ProjectionsLinesAndCircles(self.win, self.warper)
Ejemplo n.º 2
0
 def __enter__(self):
     from psychopy.visual.windowwarp import Warper # eats some time
     comp = self.component
     projection = Warper(self.window.instance, warp=comp.warp,
         warpGridsize=300,
         eyepoint=[comp.eyepoint_x, comp.eyepoint_y])
     self.instance = projection
     return self
Ejemplo n.º 3
0
from psychopy import core
from psychopy import misc
from psychopy.visual.windowwarp import Warper
from psychopy.monitors import Monitor
from psychopy.visual.grating import GratingStim
from psychopy.visual.window import Window

mon = Monitor('GenericMonitor', width=33.169, distance=10)
mon.setSizePix((1440, 900))
win = Window((1440, 900),
             monitor=mon,
             fullscr=True,
             useFBO=True,
             allowStencil=True)
warper = Warper(win, warp='spherical', warpGridsize=300, eyepoint=[0.5, 0.5])
stim = GratingStim(win=win,
                   units='deg',
                   tex='sin',
                   sf=0.1,
                   size=misc.pix2deg(win.size, win.monitor))
print win.size
print 'win size', win.size
print 'mon size', win.monitor.getSizePix()
print 'as deg', misc.pix2deg(win.size, win.monitor)
stim.draw()
win.flip()
core.wait(0.5)
win.close()
Ejemplo n.º 4
0
 def setup_class(self):
     self.win = Window(monitor='testMonitor', screen=1, fullscr=True, color='gray', useFBO = True)
     self.warper = Warper (self.win, warp='spherical', warpfile = "", warpGridsize = 128, eyepoint = [0.5, 0.5], flipHorizontal = False, flipVertical = False)
     self.warper.dist_cm=15
     self.g = ProjectionsLinesAndCircles(self.win, self.warper)
Ejemplo n.º 5
0
class Test_class_WindowWarp:
    def setup_class(self):
        self.win = Window(monitor='testMonitor', screen=1, fullscr=True, color='gray', useFBO = True)
        self.warper = Warper (self.win, warp='spherical', warpfile = "", warpGridsize = 128, eyepoint = [0.5, 0.5], flipHorizontal = False, flipVertical = False)
        self.warper.dist_cm=15
        self.g = ProjectionsLinesAndCircles(self.win, self.warper)

    def teardown_class(self):
        self.win.close()

    def draw_projection (self, frames=120):
        self.g.updateInfo()
        for i in range(frames): 
            self.g.update_sweep()

    def test_spherical(self):
        self.warper.changeProjection('spherical')
        self.draw_projection()

    def test_cylindrical(self):
        self.warper.changeProjection('cylindrical')
        self.draw_projection()

    def test_warpfile(self):
        self.warper.changeProjection('warpfile', warpfile="") #jayb todo
        self.draw_projection()

    def test_distance(self):
        self.test_spherical()
        for i in range (1, 50, 2):
            self.warper.dist_cm = i
            self.warper.changeProjection(self.warper.warp)
            self.g.updateInfo()
            self.g.update_sweep()

        self.test_cylindrical()
        for i in range (1, 50, 2):
            self.warper.dist_cm = i
            self.warper.changeProjection(self.warper.warp)
            self.g.updateInfo()
            self.g.update_sweep()

    def test_flipHorizontal(self):
        self.warper.changeProjection(self.warper.warp, self.warper.warpfile, flipHorizontal = not self.warper.flipHorizontal)
        self.draw_projection()

    def test_flipVertical(self):
        self.warper.changeProjection(self.warper.warp, self.warper.warpfile, flipVertical = not self.warper.flipVertical)
        self.draw_projection()
Ejemplo n.º 6
0
class Test_class_WindowWarp:
    def setup_class(self):
        self.win = Window(monitor='testMonitor',
                          screen=1,
                          fullscr=True,
                          color='gray',
                          useFBO=True,
                          autoLog=False)
        self.warper = Warper(self.win,
                             warp='spherical',
                             warpfile="",
                             warpGridsize=128,
                             eyepoint=[0.5, 0.5],
                             flipHorizontal=False,
                             flipVertical=False)
        self.warper.dist_cm = 15
        self.g = ProjectionsLinesAndCircles(self.win, self.warper)

    def teardown_class(self):
        self.win.close()

    def draw_projection(self, frames=120):
        self.g.updateInfo()
        for i in range(frames):
            self.g.update_sweep()

    def test_spherical(self):
        self.warper.changeProjection('spherical')
        self.draw_projection()

    def test_cylindrical(self):
        self.warper.changeProjection('cylindrical')
        self.draw_projection()

    def test_warpfile(self):
        self.warper.changeProjection('warpfile', warpfile="")  #jayb todo
        self.draw_projection()

    def test_distance(self):
        self.test_spherical()
        for i in range(1, 50, 2):
            self.warper.dist_cm = i
            self.warper.changeProjection(self.warper.warp)
            self.g.updateInfo()
            self.g.update_sweep()

        self.test_cylindrical()
        for i in range(1, 50, 2):
            self.warper.dist_cm = i
            self.warper.changeProjection(self.warper.warp)
            self.g.updateInfo()
            self.g.update_sweep()

    def test_flipHorizontal(self):
        self.warper.changeProjection(
            self.warper.warp,
            self.warper.warpfile,
            flipHorizontal=not self.warper.flipHorizontal)
        self.draw_projection()

    def test_flipVertical(self):
        self.warper.changeProjection(self.warper.warp,
                                     self.warper.warpfile,
                                     flipVertical=not self.warper.flipVertical)
        self.draw_projection()
Ejemplo n.º 7
0
# mywin = visual.Window([1440,900],monitor='testMonitor', screen=1,
#              useFBO = True)

# mywin = visual.Window([1440,900],monitor='testMonitor', screen=1,
#              useFBO = True)

mywin = visual.Window([608, 684], monitor='testMonitor', screen=1, useFBO=True)

# mywin = visual.Window([1440,900],monitor='testMonitor')

print('finally')
warper = Warper(
    mywin,
    # warp='spherical',
    warp='warpfile',
    warpfile="calibratedBallImage.data",
    warpGridsize=300,
    eyepoint=[0.5, 0.5],
    flipHorizontal=False,
    flipVertical=False)

# warper.dist_cm = 10.0
# warper.changeProjection('spherical')

print('??')

#create some stimuli
fixation = visual.GratingStim(win=mywin, size=5, pos=[0, 0], sf=50, color=-1)

# fixation = visual.Rect(
#     win=mywin,
Ejemplo n.º 8
0
                    viewOri=0.0,
                    fullscr=False,
                    monitor=mon)

#Detecting dropped frames if any
win.setRecordFrameIntervals(True)
win._refreshTreshold = 1 / proj_params[
    "monitorRefreshRate"] + 0.004  # warn if frame is late more than 4 ms
logging.console.setLevel(logging.WARNING)

# Perspective correction
if proj_params['warper']:
    warper = Warper(win,
                    warp='spherical',
                    warpfile="",
                    warpGridsize=300,
                    eyepoint=[0.5, 0.5],
                    flipHorizontal=False,
                    flipVertical=True)
# %% Main loop for presenting the stimulus
stim_start = True
stop = False  # For nidaq stop condition
last_data_frame = -1
data_frame = 0
prev_time = 0
# Generate a sequence of 1000 trials to have a sequence for all presentation which is faster.
# Initialize stimuli
trial_epoch_sequence = routine.generateTrialSeries(1000)
routine.Epochs(win, proj_params)

current_epoch_idx = -1
Ejemplo n.º 9
0
    def run(self):
        """
        The main process function for the video server. Handles actually setting up the videodevice object / stream.
        Waits to receive objects to play on the stream, sent from other processes using a Queue or Pipe.

        :return: None
        """
        self._running = True

        if self.use_lightcrafter:
            self.framepacker = ProjectorFramePacker(self.mywin)
            self._log.debug('attached framepacker for lightcrafter')

        self.synchRect = visual.Rect(win=self.mywin, size=(0.25, 0.25), pos=[0.75, -0.75],
                                     lineColor=None, fillColor='grey')

        if self.calibration_file is not None:
            warpfile = self.calibration_file
        else:
            warpfile = 'calibratedBallImage.data'

        if os.path.isfile(warpfile):
            # warp the image according to some calibration that we have already performed
            self.warper = Warper(self.mywin,
                                 # warp='spherical',
                                 warp='warpfile',
                                 warpfile=warpfile,
                                 warpGridsize=300,
                                 eyepoint=[0.5, 0.5],
                                 flipHorizontal=False,
                                 flipVertical=False)
        else:
            self.warper = Warper(self.mywin,
                                 warp='spherical',
                                 warpGridsize=300,
                                 eyepoint=[0.5, 0.5],
                                 flipHorizontal=False,
                                 flipVertical=False)

        _ = self.flyvr_shared_state.signal_ready(BACKEND_VIDEO)

        if not self.flyvr_shared_state.wait_for_start():
            self._log.info('did not receive start signal')
            self._running = False

        while self._running:

            try:
                msg = self._q.get_nowait()
                if isinstance(msg, (VideoStim, VideoStimPlaylist, str, tuple)):
                    self._play(msg)
                elif msg is not None:
                    self._log.error('unsupported message: %r' % (msg,))
            except queue.Empty:
                pass

            if self.stim is not None:
                active_stim = self.stim.update_and_draw(self.mywin, self.logger, frame_num=self.samples_played) \
                              or _NoVideoStim

                if self._save_frames_path:
                    self.mywin.getMovieFrame()
                    self.mywin.saveMovieFrames(
                        os.path.join(self._save_frames_path,
                                     '{}_image{:0>5d}.jpg'.format(self.stim.identifier,
                                                                  self.stim.frame_count)))

                if self.sync_signal > 60 * 10:
                    self.synchRect.fillColor = 'black'
                    self.sync_signal = 0
                elif self.sync_signal > 60 * 5:
                    self.synchRect.fillColor = 'white'

                self.synchRect.draw()
                self.mywin.flip()

                self.samples_played += 1
                self.sync_signal += 1

                self.flyvr_shared_state.VIDEO_OUTPUT_NUM_FRAMES = self.samples_played
                self.logger.log("/video/synchronization_info",
                                np.array([self.flyvr_shared_state.FICTRAC_FRAME_NUM,
                                          self.flyvr_shared_state.DAQ_OUTPUT_NUM_SAMPLES_WRITTEN,
                                          self.flyvr_shared_state.DAQ_INPUT_NUM_SAMPLES_READ,
                                          self.flyvr_shared_state.SOUND_OUTPUT_NUM_SAMPLES_WRITTEN,
                                          self.flyvr_shared_state.VIDEO_OUTPUT_NUM_FRAMES,
                                          self.flyvr_shared_state.TIME_NS,
                                          active_stim.producer_instance_n,
                                          active_stim.producer_playlist_n], dtype=np.int64))

                if not self.stim.advance():
                    self.stim.show = False

            if self.flyvr_shared_state.is_stopped():
                self._running = False

        self._log.info('stopped')