Skip to content

Virtual Screen

Located in ExampleScripts- Virtual 2D Screen

Note there are also additional Mixed Reality versions in the ExampleScripts- Mixed Reality folder

In the ExampleScripts- Virtual 2D Screen folder  you find a few examples related to using a virtual screen within a SightLab script. There are examples for both single and multi-user, as well as using either a stereo or mono screen. Also a example with an optional video player that lets you more easily cycle through a series of videos. Here's a brief overview of the examples and how to use them.  Note that K-Lite Codec pack may be needed to play back some video files. https://codecguide.com/download_kl.htm 

In the VideoScreenConfig file you can choose the following (note there is also a "VideoScreenConfig2" that is configured for the STIM file screen):

# Choose environment, use empty for mixed reality
ENVIRONMENT_MODEL = "sightlab_resources/environments/Stimulus.osgb"
EMPTY_ENVIROMENT_MODEL = "sightlab_resources/environments/empty.osgb"
# Choose stereo or Mono and Stereo Video Type
VIDEO_TYPE = "Mono"
# VIDEO_TYPE ='Stereo'
# STEREO_VIDEO_FORMAT ='Left_Right'
STEREO_VIDEO_FORMAT = "Top_Bottom"
# Choose location of Media
USE_DIRECTORY = False
USE_SPECIFIC_VIDEO_PATH = False
PASSTHROUGH = False
LINK_TO_HEAD = False
SAVE_CONDITION_TO_FILE = False

if USE_DIRECTORY == True:
    video_directory = r"C:Path_To_Video"
    video_files = [
        f

        for f in os.listdir(video_directory)

        if f.endswith((".mp4", ".avi", ".mov", ".wmv"))
    ]
    current_video_index = 0
    MEDIA_FILE = viz.addVideo(os.path.join(video_directory, video_files[0]))
elif USE_SPECIFIC_VIDEO_PATH == True:
    video_file = r"C:Path_To_Video"
    MEDIA_FILE = viz.addVideo(os.path.join(video_file))
else:
    MEDIA_FILE = viz.addVideo("sightlab_resources/media_2D/droneShots.mp4")
    STEREO_MEDIA_FILE = viz.addVideo("sightlab_resources/media_2D/SBS.mp4")
# These can swap out the default keys used for play/pause and restarting of the video
VIDEO_PLAYBACK_KEY = "v"
VIDEO_RESET_KEY = "k"
FAST_FORWARD_KEY = "f"
NEXT_VIDEO_KEY = "c"

Running the Session

  • Press either the spacebar or the right trigger to start the video and exit the fadequad (this will also start recording data files in Sightlab)

    • For multi-user this is just the spacebar on the server
    • Default to pause/play video is the 'k' key or 'p' key, or use the highlighter tool by pressing the right grip button to bring up the highlighter and then the right trigger to play and pause the video.
    • Default to start video from beginning is the 'v' key
    • Press the 'r' key to reset your viewpoint
    • Controls for movement and other interactions here

NOTE: For Multi-User you need to select "empty.osgb" for the environment on the server (so that it uses the hard coded path)

  • After a session you can view the data files in the data folder and use the 2D_screen_replay to replay the session

    • If selected to save a video, can review that in recordings
    • If using Biopac can link video to see physiological data

    2D_Screen

  • Displays your video on the computer monitor (screen object) in 2D

  • Session Replay will playback session

3D_Screen

  • Same as 2D_Screen, but for playback of stereo videos (change if Top/Bottom or Left/Right in VideoScreenConfig)

Video_Player

  • Will display a virtual screen in a  black environment
  • If using the Meta Quest Pro or Varjo, will use mixed reality to display the real world with the virtual screen
  • Screen can be grabbed and moved with the trigger buttons
  • Can resize the screen using the 'm' or 'n' keys
  • Can get position of screen using the 't' key, which you can use these values to set its position in the code
  • Can use a virtual pointer to start and stop playback

2D_Screen_server and 2D_Screen_client

  • Multi-User version

Cycle Videos

  • Adjust settings in the ExperimentSettings file and use these options on creating the virtual screen object:
  • Usage example:

    • player1 = media_player.VideoPlayer(screen=screen, video_directory=VIDEO_DIRECTORY)

Video_Player_STIM_File

  • See how to use a STIM file to choose the videos and options per trial (set up with VideoScreenConfig2) Swapping out the environment

Find in the code where it has: 

env = vizfx.addChild("sightlab_resources/environments/Stimulus.osgb")

and change this path to whatever environment you want to use. 

Adding a screen

To add a video screen to your environment model, you will need to either access a screen object in your environment using:

screen = env.getChild('screen') #where 'screen' is the name of that component

Or you can use File-Add and add a 2D image to your environment model and rename it to 'screen' and place it where you want in your scene. 

You can also use File-Add and add the "screen.osgb" from sightlab_resources/objects

See the page on creating a scene for more information