Skip to content

Automation scripts

These small scripts keep each control computer in sync. They pull the latest protocols from GitHub every morning, push behavior data to the lab NAS every night, and update BpodAcademy and the DataJoint database.

All paths assume the user ratacad1 with everything under ~/ratacad/. Edit them to match your machine.

Schedule

Time Script What it does
01:00 transferBpodData rsync Bpod Local/Data → NAS RATACAD_DATA; (Ubuntu) delete local files older than 30 days
08:00 updateProtocols git pull the protocols repo, then mirror Protocols/ into Bpod Local/Protocols
as needed updateBpodAcademy reinstall BpodAcademy from GitHub into the bpod conda env
as needed / cron on the DB host updateDJ reinstall dj_ratacad and run dj-ratacad update to ingest new sessions

Ubuntu

File Download
updateProtocols.sh download
transferBpodData.sh download
updateBpodAcademy.sh download
updateDJ.sh download
################################################
# bash script to update Bpod protocols directory
# from ScottLabBpodProtocols github
################################################

# navigate to ScottLabBpodProtocols directory
cd ~/ratacad/ScottLabBpodProtocols

# pull latest changes from master branch
#### uses SSH keys for github username = gkane26
git pull origin master

# sync ScottLabBpodProtocols/Protocols with local Bpod Protocols directory
rsync -avuz ~/ratacad/ScottLabBpodProtocols/Protocols ~/ratacad/Bpod\ Local/ --delete-after
#########################################
### transfer local Bpod Data to ENG drive
#########################################

rsync -avuz ~/ratacad/Bpod\ Local/Data/* /ad/eng/research/eng_research_scottlab/RATACAD_DATA
find ratacad/Bpod\ Local/Data -mtime +30 -type f -delete
##########################################
### update BpodAcademy pacakge from github
##########################################

source ~/anaconda3/etc/profile.d/conda.sh
conda activate bpod
pip uninstall -y bpod-academy
pip install git+ssh://git@github.com/RatAcad/BpodAcademy
#!/bin/bash
export RATACAD_DATA_DIR=/ad/eng/research/eng_research_scottlab/RATACAD_DATA
source ~/anaconda3/etc/profile.d/conda.sh
conda activate dj
pip uninstall -y dj-ratacad
pip install git+ssh://git@github.com/RatAcad/dj_ratacad
dj-ratacad update

transferBpodData.sh deletes local data

After copying, it deletes local data files older than 30 days (find ... -mtime +30 -delete). Check that the NAS copy is working before you enable it. The find path is relative, so it relies on cron running from the home directory (cron's default).

Windows

On Windows each .sh file is run by Cygwin through a matching .bat launcher, which is what Task Scheduler calls.

Script .sh .bat
updateProtocols download download
transferBpodData download download
transferMiniscopeData (optional, for miniscope rigs) download download
cd /cygdrive/c/Users/ratacad1/ratacad/ScottLabBpodProtocols
git pull -f origin master
rsync -avuz /cygdrive/c/Users/ratacad1/ratacad/ScottLabBpodProtocols/Protocols /cygdrive/c/Users/ratacad1/ratacad/Bpod\ Local/ --delete-after
rsync -avuz --chmod=u+rwx,g+rwx /cygdrive/c/Users/ratacad1/ratacad/Bpod\ Local/Data/* /cygdrive/z/RATACAD_DATA
rsync -avuz --chmod=u+rwx,g+rwx /cygdrive/d/miniscope/* /cygdrive/z/MINISCOPE_DATA
C:\tools\cygwin\bin\mintty.exe /cygdrive/c/Users/ratacad1/ratacad/scripts/transferBpodData.sh