Skip to content

Instantly share code, notes, and snippets.

@smackesey
Created May 2, 2014 19:21
Show Gist options
  • Save smackesey/11483825 to your computer and use it in GitHub Desktop.
Save smackesey/11483825 to your computer and use it in GitHub Desktop.
import os
import time
config = {
#######################
# app
#
# outputDataDir -- directory where all application output will be written
# keyBindings -- a dictionary where the keys are 'quit', 'toggleStimulator',
# and 'triggerStimulator', and the values are one-character strings
# representing the button that triggers the action specified by the key
#
'outputDataDir' : os.path.join(
"C:\\Documents and Settings\\Kauferlab\\Desktop\\prosocial_output",
"trial" + time.strftime("%y%m%d%H%M%S")),
# 'keyBindings' : {
# 'quit' : 'q',
# 'toggleStimulator' : 't',
# 'triggerStimulator' : 's'
# },
#######################
# audio
#
# active -- switch controlling whether audio recording is enabled
# outputFormat -- format of the audio data. If 'wav', a wav file is
# generated. If any other value, output is in the form of small npy files
# labeled with starting sample number.
# nidaq -- a dictionary of settings that is forwarded to the underlying
# BufferedTask object. See BufferedTask for setting specification.
'audio': {
'active' : True,
'outputFormat' : 'wav',
'nidaq' : {
'outputDataDir' : os.path.join(
os.path.normpath(os.path.expanduser("~/kauferdata"))),
'numChannels' : 2,
'channelNames' : ["ai0", "ai2"],
'perChannelSampleThreshold': 1000,
'ramBufferSize': 1000*1000, # perChannelSampleThreshold * 1000
'sampleRate' : 200000.0,
'daqDeviceName' : "Dev1",
}
},
#######################
# gui
#
# active -- Boolean switch controlling whether the GUI is active. **NOTE**
# currently disabling this variable does nothing, the GUI is always run.
# feedSize -- tuple giving the (height,width) in pixels of the video feed.
# This is used to size the feed display window.
# sidebarWidth -- width in pixels of the sidebar
# sidebarHeight -- height in pixels of the sidebar
# font -- a number representing a font. Should be created by accessing a
# constant from cv2. This font is used for the sidebar.
# fontColor -- a tuple giving a BGR value for the color of the text used in
# the sidebar
# fontScale -- a floating point number specifying the size of the font used
# in the sidebar
# lineSpace -- the distance in pixels between the bottoms of successive lines
# in the sidebar. Note that this must be larger than the font height.
# baseIndent -- the horizontal size in pixels of the left sidebar margin
# valueXOffset -- the horizontal offset for values displayed in the sidebar
# valueYOffset -- the vertical offset for values displayed in the sidebar
'gui' : {
# 'active' : True,
# 'feedSize' : (480,640),
# 'sidebarWidth' : 300,
# 'sidebarHeight' : 1000,
# 'font' : opencvgui.text.defaultFont,
# 'fontSize' : opencvgui.text.defaultSize,
# 'fontColor' : opencvgui.text.defaultColor,
# 'lineSpace' : 50,
# 'baseIndent' : 5,
# 'valueXOffset' : 20,
# 'valueYOffset' : 20
},
#######################
# stimulator
#
# active -- Boolean-valued switch controlling whether stimulation is active
# channel -- the target channel number of the Master 8
# activeProtocolName -- the name of the protocol that will be used. Must
# correspond to one of the keys in the protocols dictionary.
# minToggleSeparation -- a floting point number giving the minimum amount of
# time in seconds between successive toggles of the stimulator. A higher
# number means less flickering of stimulation status.
# protocols -- a dictionary of protocols. The keys are the names of the
# protocols and the values are protocol specifications. Each protocol is a
# dictionary containing four possible keys:
# - paradigm (required): a dictionary of settings for the Master8
# - trackerFunction (optional): If set to a Python function, this
# function will be called to determine whether stimulation should be
# toggled based no liveTracking status. It will be passed as its sole
# argument an instance of the Tracker controller, which stores state
# variables: arenaRatActive, nearRestrainer, continuouslyActive,
# continuouslyInactive, continuouslyNearRestrainer,
# continuouslyAwayFromRestrainer. Cannot be used simultaneously with
# schedule.
# - triggerInterval (optional): if set to a floating point number
# (representing seconds), a trigger signal will be periodically sent to
# the Master 8
# - toggleSchedule (optional): a tuple of numbers giving (stimulationOn,
# stimulationOff) times in seconds. Cannot be used simultaneously with
# trackerFunction.
'stimulator' : {
'active' : True,
'channel' : 1,
'activeProtocolName' : 'nucleusAccumbensExample',
'minToggleSeparation' : 0.5,
'protocols' : {
"nucleusAccumbensExample" : {
"trackerFunction" : lambda t: 0 < t.continuouslyNearRestrainer < 1,
"paradigm" : {
"mode" : "FREE",
"DURA" : 0.005,
"DELAY" : 0,
"INTER" : 0.1,
}
},
"basolateralAmygdalaExample" : {
"toggleSchedule" : (120,120),
"triggerInterval" : 10,
"paradigm" : {
"mode" : 'TRAIN',
"DURA" : 0.005,
"DELAY" : 0,
"INTER" : .1,
"M" : 20
}
}
}
},
#######################
# tracker
#
# active -- is live-tracking on? *NOTE* currently setting this to False has
# no effect, i.e. live-tracking is always enabled
# frameSize -- a tuple giving the (width, height) in pixels of the frame in
# which the rats are being tracked
# activityThreshold -- the required distance in pixels between successive
# positions of a rat for the rat to be deemed "active"
# arenaCoordinates -- a tuple of tuples containing the upper-left and lower
# right corner coordinates of the arenaregion
# restrainerCoordinates -- a tuple of tuples containing the upper-left and lower
# right corner coordinates of the arenaregion
# nearRestrainerMargin -- an integer giving the fixed number of pixels to
# expand the restrainer region on all sides in order to define the
# near-restrainer region
# color -- a tuple of integers giving the RGB color being tracked; should be
# unique to rats in the frame
# colorTolerance -- an integer giving the tolerance used in thresholding.
# This number is used to define a range around each of the red, green, and
# blue components of the color
# blurAperture -- numerical aperture size for the blur operation. A higher
# number is blurrier.
'tracker' : {
# 'active' : True,
'frameSize' : (480,640),
# 'activityThreshold' : 150,
# 'color' : (255,255,255),
'colorTolerance' : 20,
# 'refreshInterval' : 0.2,
# 'arenaCoordinates' : ((0,0),(0,0)),
# 'restrainerCoordinates' : ((0,0),(0,0)),
# 'nearRestrainerMargin' : 35,
},
#######################
# videoIn
#
# path -- path to a video file to be used as input (rather than a camera). If
# None, a camera is used.
'videoIn' : {
# 'path' : None,
},
#######################
# videoOut
#
# outputDataDir -- directory to which video outputs are written
# fourCC -- a number specifying the codec to use for writing. Should be
# created with the cv2.fourCC method.
# frameRate -- frame rate of each output video
# resolution -- a tuple giving the (width, height) in pixels of each output
# video feed
# markerRadius -- the radius in pixels of the marker used on output videos to
# indicate rat location
# arenaMarkerColor -- a tuple giving a BGR value for the color of the marker
# used to indicate arena rat location
# restrainerMarkerColor -- a tuple giving a BGR value for the color of the marker
# used to indicate restrainer rat location
# restrainerBorderColor -- a tuple giving a BGR value for the color of the border
# used to delineate the restrainer region
# nearRestrainerBorderColor -- a tuple giving a BGR value for the color of the border
# used to delineate the near-restrainer region
# restrainerBorderColor -- a tuple giving a BGR value for the color of the border
# used to delineate the arena region
# stimulationStatusLocation -- a tuple giving the coordinates of the
# bottom-left corner of the text indicating stimulator status
# font -- a number representing a font. Should be created by accessing a
# constant from cv2. This font is used to display stimulator status.
# fontColor -- a tuple giving a BGR value for the color of the text used to
# write stimulator status
# fontScale -- a floating point number specifying the size of the font used
# to write stimulator status
# outputs -- an array of dictionaries specifying outputs. Each dictionary has
# two keys: "filename" and "feedType". "feedType" may be 'tracked',
# 'thresholded', or 'blurred'. This specifies the underlying frame source that
# will be annotated for this output.
# outputCombinedVideo -- a Boolean-valued setting that specifies whether to
# create a video that vertically stacks all outputs during post-processing
'videoOut' : {
# 'outputDataDir' : os.path.join(
# os.path.normpath(os.path.expanduser("~/kauferdata"))),
# 'fourCC' : cv2.cv.CV_FOURCC('m', 'p', '4', 'v'),
# 'frameRate' : 25,
'resolution' : (640,480),
# 'markerRadius' : 10,
# 'arenaMarkerColor' : opencvgui.colors.blue,
# 'restrainerMarkerColor' : opencvgui.colors.red,
# 'arenaBorderColor' : opencvgui.colors.white,
# 'nearRestrainerBorderColor' : opencvgui.colors.green,
# 'restrainerBorderColor' : opencvgui.colors.white,
# 'stimulationStatusLocation' : (10,30),
# 'font' : opencvgui.text.defaultFont,
# 'fontColor' : opencvgui.colors.red,
# 'fontScale' : opencvgui.text.defaultScale * 2,
# 'outputs' : [
# { 'filename' : 'track.avi', 'feedType' : 'tracked' },
# { 'filename' : 'thresholded.avi', 'feedType' : 'thresholded' },
# { 'filename' : 'blurred.avi', 'feedType' : 'blurred' }
# ],
# 'outputCombinedVideo' : False
},
#######################
#
# writer
# format -- File format of the output. Currently suports only CSV.
# outputDataDir -- Directory in which output file is written
# filename -- name of output file
'writer' : {
# 'format' : 'csv',
# 'outputDataDir' : os.path.join(
# os.path.normpath(os.path.expanduser("~/kauferdata"))),
# 'filename' : 'track.csv'
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment