-
Notifications
You must be signed in to change notification settings - Fork 0
Installation Guide
You Will Need:
- A computer with (at minimum) a GPU with 4GB of GPU-RAM
- Access to a 3D printer and a supply of PLA
- Laboratory mice with implanted RFID tags
- Access to a laser/waterjet cutter and ¼” acrylic
- 1 ThorLabs metal platform (fits 3 cages)
- Everything listed in the Bill of Materials
a) I recommend cutting the lid piece ahead of time. Make an order with your machine shop (or cut your own, if you can). The air holes do not have to be exact – the screw holes should be relatively precise, which is why I do not recommend doing this by hand. If doing this by hand, measure very carefully and use a drill press to form the holes.
b) Print the 3D-printed pieces: This will take a while, likely overnight, and may take a few passes to fit all the pieces. Ensure you print the water bottle holster in white if you can.
c) Drill 2 3mm holes on each short side of the cage, 25 mm above the floor. Use the base attachment piece as a reference.
d) Drill 4 2.5mm holes on one side of the cage, to match the water bottle holster.
a) Start with the reader bases. Place the 12mm length M3 bolts through the holes in each breakout board, and screw 4 nuts on the backside to act as spacers. Mount each board on its respective reader, and screw another 4 nuts to fasten them firmly. Repeat for each breakout board.
b) Place the two base attachment pieces with 10 holes (exclusive) between them, flat sides facing inward. Screw them into the platform with the ¼”-20 bolts. The cage should fit nicely between them – if not, count again.
c) Place each reader base with the outward hole side in line with the base attachment piece holes: there should be a line of 6 holes, with the base attachment piece in the middle. These pieces will form the four corners of the cage. Carefully, taking care that the bases stay flush with the platform, screw them in with more ¼”-20 bolts. Alternating the bolt you are screwing in will make this an easier process.
d) Place each RFID reader on its respective breakout board.
e) Either paint the exterior of the cage with nonhazardous white paint, or tape printer paper over the sides, much in the same way as wrapping a package. This ensures a better background for the mice to be seen on. Place the cage on the readers and line up the holes with the base attachment – screw in the 16mm M3 bolts and thread the nuts on the exterior of the cage. The readers should be gently pressing against the floor of the cage.
f) Screw in the camera and LEDs to the mount with the M2/M2.5 bolts, then screw the mount to the lid in the center of the cage.
a) Clone NaturalMouseTracker to the computer you plan to use for processing the videos (git clone). Choose a directory you can easily remember. Additionally, clone the RPi branch of this repository to the Raspberry Pi you plan to use to record. You can clone the entire repo, but it will take more space than necessary. To clone just the RPi branch, git clone <NaturalMouseTracker> --branch RPI--single-branch. Note the path it is cloned to.
b) (RPI) As noted in the Recording section of the wiki, the picamera library used for the recording is currently broken. Please remove the default installation (sudo pip3 uninstall picamera) and install the following fork by running the setup script - sudo python3 setup.py install.
c) (Desktop) Follow the instructions in https://github.com/AlexeyAB/darknet ‘s README for installing darknet. If using CUDA >= 10.1, edit the .vcxproj files in build/darknet with a text editor to replace 10.0 with 10.x (x being the version number) – this is necessary or the system will not compile.
d) (Desktop) Download the conda environment for your OS here: https://github.com/AlexEMG/DeepLabCut/tree/master/conda-environments
e) (Desktop) Create a new conda environment based on the file downloaded
i. $ conda env create -f dlc-ubuntu-GPU.yaml (replace dlc-ubuntu-GPU.yaml with your OS specific .yaml file)
ii. To enter the environment: $ source activate dlc-ubuntu-GPU.yaml (If on windows omit ‘source’)
f) (Desktop) Run the command python setup.py install
g) (Desktop) If using black mice, you can use the pretrained weights in the repository. Move yolo-obj_best.weights into the folder as well. Otherwise, you will need to train your own network. Follow the instructions in https://github.com/AlexeyAB/darknet to do so. Ensure you prepare 2000+ good quality images – I recommend including non-mouse objects of a similar size and shape to your mice in the dataset. Otherwise, the network can rely too heavily on contrast.
a) (RPi) Before plugging in all your USB cables, ensure that you have set up SSH on your Pi – running the system headless will achieve a better framerate.
b) (RPi) Plug in your external hard drive, and run the following commands:
i. sudo apt-get update
ii. sudo lsblk -o UUID,NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL,MODEL (note the location, UUID, and FSTYPE of your HDD)
iii. (if FSTYPE is EXFAT) sudo apt-get install exfat-fuse (Enable read/write to exFAT drives)
iv. (if FSTYPE is NTFS) sudo apt-get install ntfs-3g (Enable read/write to NTFS drives)
v. sudo mkdir /mnt/frameData (Create mounting point)
vi. sudo nano /etc/fstab
vii. Add the following line: UUID=<UUID> /mnt/frameData <FSTYPE> defaults,auto,umask=000,users,rw,nofail 0 0
viii. Exit nano (Ctrl-X) and sudo reboot
ix. This will mount your external hard drive on the Pi automatically upon connection.
x. For any problems, check https://www.raspberrypi.org/documentation/configuration/external-storage.md.
c) (RPi) Do a test run of the program with a sample RFID tag. First, run sudo python3 record.py. Hover the tag over the 4 readers in sequence, and note this sequence. Use Ctrl-C to terminate, check the output and adjust the reader enumeration in record.py lines 66-69 so that it matches the actual sequence. This must be done each time the USBs are unplugged, but not as long as they remain plugged in.
thread0 = Thread(target=self.scan, daemon= True, args=(self.reader0 ,0 # CHANGE THESE NUMBERS TO MATCH THE SEQUENCE,))
thread1 = Thread(target=self.scan, daemon= True, args=(self.reader1, 1 # THIS ONE TOO,))
thread2 = Thread(target=self.scan, daemon= True, args=(self.reader2, 2 # YEP THIS ONE TOO,))
thread3 = Thread(target=self.scan, daemon= True, args=(self.reader3, 3 # AND THIS ONE,))
For example, if you want the order to be topLeft at 0, topRight at 1, bottomLeft at, and bottomRight at 3, run your tag over the readers in that order, and note the output you get. If the output does not match your desired order, change the numbers as in the above code to until they do match.
NOTE: If you have gone the route of static usb names, in lines 39-42 you should replace ‘dev/tty/USB0’ with ‘BottomR’ or whatever your chosen symlink was. Do this for all readers.
d) (RPi) Put the mice in the cage, along with food and water. Place the lid with the camera mount on top.
e) (RPi) When starting your 24/7 monitoring, run sudo crontab -e. Edit the crontab to include the following line: */15 * * * * /usr/bin/python3 <path_to_installation>/record.py. This will run the recording script every 15 minutes.
f) (RPi) After finishing your recording, edit the crontab again (sudo crontab -e) and place a # in front of the previous command. Remove your external hard drive and connect it to your computer.
g) (Desktop) Run python run.py and follow the prompts.
h) Return later to find your SQL database full of the data needed, along with corresponding CSV files!
OPTIONAL: Assigning USB IDs
Helpful links: (Scheduling) Cron/Crontab: https://www.raspberrypi.org/documentation/linux/usage/cron.md