Skip to main content
Skip table of contents

Implement a 10kHz tachistoscope on the PROPixx

A demonstration of the PROPixx implementing a 10kHz tachistoscope.

PY
import numpy as np
from pypixxlib import _libdpx as dp
import time

dp.DPxOpen()
dp.DPxStopAllScheds()
dp.DPxUpdateRegCache()

#Download a sequence of T-scope images into PROPixx RAM.
#Multiple sequences could be downloaded before an experiment starts,
#or alternatively, sequences could be uploaded just before they are required.
# This sequence will implement 5 T-scope images onto pages 1-5.
# Cover page has white on top 200 rows white.
# Other 4 pages have top 400/600/800/1000 white.

pageData = np.zeros((1080, 1920//8), dtype=np.uint8)

pageData[0:200,:] = 255
dp.DPxWritePPxTScopePages(1,pageData)
pageData[200:400,:] = 255
dp.DPxWritePPxTScopePages(2,pageData)
pageData[400:600,:] = 255
dp.DPxWritePPxTScopePages(3,pageData)
pageData[600:800,:] = 255
dp.DPxWritePPxTScopePages(4,pageData)
pageData[800:1000,:] = 255
dp.DPxWritePPxTScopePages(5,pageData)

dp.DPxEnablePPxTScope()
dp.DPxUpdateRegCache()
time.sleep(1)

#Configure T-Scope for next presentation.
#We'll show the cover page, then the 4 remaining pages updated at 10kHz.
#The T-Scope will automatically wrap from page 5 back to page 2.
#Setting the maxScheduleFrames arg to 5 will cause the sequence to only
#run once.

dp.SetPropixxTScopeSchedule(0, 10000, 0, 1, 5)
dp.DPxUpdateRegCache()

#Rising edge on TScopePrepRequest will request load of cover page onto DLP
#The cover page is what you want the subject to see when the schedule is
#not yet running.  Could even be completely black.

dp.DPxDisablePPxTScopePrepReq()
dp.DPxUpdateRegCache()

dp.DPxEnablePPxTScopePrepReq()
dp.DPxUpdateRegCache()

#Wait until any current DLP processing has terminated, cover page is up,
#and T-scope subsystem is ready to be triggered.
#this usually takes about 100 microseconds.
#Worst case is if we just switched from normal video into T-Scope mode,
#and the DLP just started presenting a 60Hz video frame.
#Then we wait here until that video frame has completed,
#and the delay here could be as much as 17 milliseconds.

while True:
    dp.DPxUpdateRegCache()
    status = dp.DPxIsPPxTScopePrepAck()
    if status:
        break

#The T-Scope schedule is now ready to be triggered.

#Frames will run continuously at exactly 10kHz.
#Based on the images downloaded above using WritePropixxTScopePages:
#-rows  100-400  will be always on
#-rows  401-600  will be on 0.3ms, off 0.1ms
#-rows  601-800  will be on 0.2ms, off 0.2ms
#-rows  801-1000 will be on 0.1ms, off 0.3ms
#-rows 1001-1080 will be always off

print("Showing cover page.")
time.sleep(1)
dp.DPxStartPPxTScopeSched()
dp.DPxUpdateRegCache()

#If the T-scope scheduler is in count-up mode, the sequence will continue
#until manually stopped.  If the scheduler is in count-down mode, it will
#stop automatically when the schedule counter has decremented to 0  .

print("Showing T-scope sequence.")
time.sleep(1)
dp.DPxStopPPxTScopeSched()

dp.DPxDisablePPxTScopePrepReq()

#At this point, a new sequence could be downloaded,
#or an already-downloaded sequence could be started,
#beginning with SetPropixxTScopeSchedule.
#Instead, we will just return to normal video processing.

dp.DPxDisablePPxTScope()
dp.DPxUpdateRegCache()
time.sleep(2)
vidstatus = dp.DPxGetPPxTScopeSchedCount()
print("frames presented:" + str(vidstatus))
dp.DPxClose()
print("Tscope demo complete")

print(pageData.shape)
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.