AHF_HeadFixer
The HeadFixer class controls the headfixing mechanism. HeadFixer is implemented for two types of hardware: pistons, in AHF_HeadFixer_Pistons, and servos, in AHF_HeadFixer_PWM_PCA9685. Note that servos require extra parameters for fixation position. Currently, AHF_HeadFixer_PWM_PCA9685 is used for all tasks requiring headfixation.
AHF_HeadFixer_NoFix is functionally equivalent to AHF_HeadFixer with defaultPropHeadFix set to 0; however, AHF_HeadFixer_NoFix reduces setup and setdown overhead and does not require calibrating parameters.
AHF_HeadFixer.AHF_HeadFixer module
- class AHF_HeadFixer.AHF_HeadFixer(taskP, settingsDictP)
Bases:
AHF_Base.AHF_BaseBase class for all head fix classs. Other head fixers subclass from this, or from one of its subclasses boolean for settability of headFixing levels, default is False. Can be used for incremental learning
- clearResultsDict(resultsDict)
- abstract config_subject_get(starterDict={})
- Returns
dict – the default dictionary for individualized parameters
- abstract static config_user_get(starterDict={})
static method that querries user for settings, with default responses from starterDict, and returns starterDict with settings as edited by the user.
- abstract config_user_subject_get(starterDict={})
Prompts the user for individualized parameters, with default responses from starterDict, and returns starterDict with settings as edited by the user.
- defaultHeadFixTime = 40
Default length, in seconds, of headfixation
- defaultPropHeadFix = 0.75
Proportion of entries to headfix
- defaultSkeddadleTime = 5
Length of time, in seconds, that a mouse has to leave for before being eligible for re-headfixation
- abstract fixMouse(thisTag, resultsDict={}, settingsDict={})
performs head fixation by energizing a piston, moving a servomotor, etc returns True if successful, else false.
- abstract hardwareTest()
Tests functionality, gives user a chance to change settings. :Returns: bool – True if any settings have changed
- hasLevels = False
- hasMouseLog(hasContact, isFixed, thisTag, resultsDict)
Utility function for head fix subclasses Run after head fixing to update common results
- isChecking = False
- static isFixedCheck()
- newResultsDict(starterDict={})
Returns a dictionary counting number of head fixes, subclasses could track more levels of head fixing, e.g.
- newSettingsDict(starterDict={})
- abstract releaseMouse(thisTag, resultsDict={}, settingsDict={})
releases mouse from head fixation by relaxing a piston, moving a servomotor, etc
- setup()
gets settings from dict, not @abstract because this may be all you need, as for HeadFixer_NoFix
- waitForMouse(thisTag)
Utility function for head fix subclasses Waits for a mouse to either make contact or leave the chamber
- AHF_HeadFixer.random() x in the interval [0, 1).
AHF_HeadFixer.AHF_HeadFixer_NoFix module
- class AHF_HeadFixer_NoFix.AHF_HeadFixer_NoFix(taskP, settingsDictP)
Bases:
AHF_HeadFixer.AHF_HeadFixerHead Fixer that only checks for contact, does not implement a head-fixing mechanism
- static about()
Returns a brief message describing your sub-class, used when asking user to pick a sub-class of this class
- config_subject_get(starterDict={})
- Returns
dict – the default dictionary for individualized parameters
- static config_user_get(starterDict={})
Querries user returns dictionary
- config_user_subject_get(starterDict={})
Prompts the user for individualized parameters, with default responses from starterDict, and returns starterDict with settings as edited by the user.
- defaultSkeddadleTime = 0.5
Length of time, in seconds, that a mouse has to leave for before being eligible for re-headfixation
- fixMouse(tag, resultsDict={}, settingsDict={})
Just does contact check with super(), does not fix
- hardwareTest()
Tests functionality, gives user a chance to change settings. :Returns: bool – True if any settings have changed
- hasLevels = False
- isChecking = False
- releaseMouse(tag, resultsDict={}, settingsDict={})
releases mouse from head fixation by relaxing a piston, moving a servomotor, etc
- setdown()
oppposite of setup. Releases any hardware resouces. can be run before editing settings so GPIO pins can be reused, for example. This strategy should be used in hardwareTest method.
- setup()
gets settings from dict, not @abstract because this may be all you need, as for HeadFixer_NoFix
AHF_HeadFixer.AHF_HeadFixer_PWM module
- class AHF_HeadFixer_PWM.AHF_HeadFixer_PWM(taskP, settingsDictP)
Bases:
AHF_HeadFixer.AHF_HeadFixerAbstract class for PWM-based head fixers for servo motors. As long as your subclass maps your PWM range onto the appropriate pulse width for the servo, you should be good to go.
- calculate_steps(individualDict)
- config_subject_get(starterDict={})
- Returns
dict – the default dictionary for individualized parameters
- abstract static config_user_get(starterDict={})
static method that querries user for settings, with default responses from starterDict, and returns starterDict with settings as edited by the user.
- config_user_subject_get(starterDict={})
Prompts the user for individualized parameters, with default responses from starterDict, and returns starterDict with settings as edited by the user.
- defaultFixedPosition = 685
Default position of fixed headfixer in PWM range
- defaultReleasePosition = 933
Default position of released headfixer in PWM range
- defaultTightnessHeadFix = 1
Percentage( 0 to 1) of head-fix tightness (0 equals release, 1 equals full head-fix). Values below 0.5 might allow the mouse to leave the tunnel
- fixMouse(thisTag, resultsDict={}, individualDict={})
performs head fixation by energizing a piston, moving a servomotor, etc returns True if successful, else false.
- hardwareTest()
Tests functionality, gives user a chance to change settings. :Returns: bool – True if any settings have changed
- hasLevels = True
- individualSettings(starterDict={})
copies servo fixed position to dictionary - there is no reason to have different released positions per subject TO DO: add multiple headfixing levels, maybe progression based on resdults
- numLevels = 8
Number of increments on the servo (currently unused)
- releaseMouse(thisTag, resultsDict={}, settingsDict={})
releases mouse from head fixation by relaxing a piston, moving a servomotor, etc
- abstract setPWM(servoPosition)
- setdown()
oppposite of setup. Releases any hardware resouces. can be run before editing settings so GPIO pins can be reused, for example. This strategy should be used in hardwareTest method.
- abstract setup()
gets settings from dict, not @abstract because this may be all you need, as for HeadFixer_NoFix
- AHF_HeadFixer_PWM.random() x in the interval [0, 1).
AHF_HeadFixer.AHF_HeadFixer_PWM_PCA9685 module
> Last modified: 2022/10/17 by Roark Zhang - update to new adafruit library
> uses PCA9685 code from AdaFruit, install as follows
sudo pip3 install –upgrade adafruit-python-shell wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/raspi-blinka.py sudo python3 raspi-blinka.py
sudo pip3 install adafruit-circuitpython-busdevice sudo pip3 install adafruit-circuitpython-register sudo pip3 install adafruit-circuitpython-pca9685
- class AHF_HeadFixer_PWM_PCA9685.AHF_HeadFixer_PWM_PCA9685(taskP, settingsDictP)
Bases:
AHF_HeadFixer_PWM.AHF_HeadFixer_PWMinherits from AHF_HeadFixer_PWM
- static about()
Returns a brief message describing your sub-class, used when asking user to pick a sub-class of this class
- static config_user_get(starterDict={})
static method that querries user for settings, with default responses from starterDict, and returns starterDict with settings as edited by the user.
- defaultAddress = 64
- setPWM(servoPosition)
- setdown()
oppposite of setup. Releases any hardware resouces. can be run before editing settings so GPIO pins can be reused, for example. This strategy should be used in hardwareTest method.
- setup()
gets settings from dict, not @abstract because this may be all you need, as for HeadFixer_NoFix
AHF_HeadFixer.AHF_HeadFixer_PWM_Pi module
- class AHF_HeadFixer_PWM_Pi.AHF_HeadFixer_PWM_Pi(taskP, settingsDictP)
Bases:
AHF_HeadFixer_PWM.AHF_HeadFixer_PWM- static about()
Returns a brief message describing your sub-class, used when asking user to pick a sub-class of this class
- static config_user_get(starterDict={})
static method that querries user for settings, with default responses from starterDict, and returns starterDict with settings as edited by the user.
- defaultChannel = 1
- setPWM(servoPosition)
- setdown()
oppposite of setup. Releases any hardware resouces. can be run before editing settings so GPIO pins can be reused, for example. This strategy should be used in hardwareTest method.
- setup()
gets settings from dict, not @abstract because this may be all you need, as for HeadFixer_NoFix
AHF_HeadFixer.AHF_HeadFixer_Pistons module
- class AHF_HeadFixer_Pistons.AHF_HeadFixer_Pistons(taskP, settingsDictP)
Bases:
AHF_HeadFixer.AHF_HeadFixerHead fixer using solenoid-driven pistons to push head bar against front plate a single GPIO output triggers a driver of some kind to energize solenoids
- static about()
Returns a brief message describing your sub-class, used when asking user to pick a sub-class of this class
- config_subject_get(starterDict={})
- Returns
dict – the default dictionary for individualized parameters
- static config_user_get(starterDict={})
Querries user for pin number for piston, returns dictionary
- config_user_subject_get(starterDict={})
Prompts the user for individualized parameters, with default responses from starterDict, and returns starterDict with settings as edited by the user.
- defaultPin = 12
- fixMouse(thisTag, resultsDict={}, settingsDict={})
sets GPIO pin high to trigger pistons
- releaseMouse(resultsDict={}, individualDict={})
sets GPIO pin low to retract pistons
- setdown()
oppposite of setup. Releases any hardware resouces. can be run before editing settings so GPIO pins can be reused, for example. This strategy should be used in hardwareTest method.
- setup()
gets settings from dict, not @abstract because this may be all you need, as for HeadFixer_NoFix
- AHF_HeadFixer_Pistons.random() x in the interval [0, 1).