Database Access
First steps
- Fill out the DataJoint host access form.
- Fill out the PNI account form.
- Clone the repository:
- For Python: https://github.com/BrainCOGS/U19-pipeline-python
- For MATLAB: https://github.com/BrainCOGS/U19-pipeline-matlab
Mount file server volumes
The database references many data files (behavior, imaging and electrophysiology).
To access these files, mount the PNI file server volumes on your system.
Data is stored on three main PNI file server volumes (braininit, Bezos and u19_dj).
On Windows
- From Windows Explorer, select "Map Network Drive" and enter:
\\cup.pni.princeton.edu\braininit\(for braininit)\\cup.pni.princeton.edu\Bezos-center\(for Bezos)\\cup.pni.princeton.edu\u19_dj\(for u19_dj)
- Authenticate with your NetID and PU password (NOT your PNI password, which may be different). When prompted for your username, enter
PRINCETON\netid(PRINCETON can be upper or lower case), wherenetidis your PU NetID.
On macOS
- In Finder, select "Go -> Connect to Server..." and enter:
smb://cup.pni.princeton.edu/braininit/(for braininit)smb://cup.pni.princeton.edu/Bezos-center/(for Bezos)smb://cup.pni.princeton.edu/u19_dj/(for u19_dj)
- Authenticate with your NetID and PU password (NOT your PNI password, which may be different).
On Linux
- Follow the extra steps described in this link.
DB access for Python repository
Prerequisites
Click to expand details
Install an integrated development environment
You can develop with and use DataJoint from a plain text editor in the terminal, but an integrated development environment (IDE) can improve your experience. Several IDEs are available.
In this setup example, we will use Microsoft's Visual Studio Code. Installation instructions here.
Install the Jupyter extension for VS Code.
Install a virtual environment
A virtual environment lets you install the packages required for a specific project within an isolated environment on your computer.
We highly recommend creating a virtual environment to run the workflow.
Conda and virtualenv are both virtual environment managers; you can use either. Below are the commands for Conda.
If you are setting up the pipeline on your local machine, follow the Conda instructions below. On
spock.pni.princeton.eduorscotty.pni.princeton.edu, Conda is preinstalled; load it withmodule load anacondapy/2021.11.We will install Miniconda, a minimal installer for Conda.
Select the Miniconda installer link for your operating system and follow the instructions.
You may need to add the Miniconda directory to the PATH environment variable:
First, locate the Miniconda directory.
Then edit and run the following command:
bashexport PATH="<absolute-path-to-miniconda-directory>/bin:$PATH"
Create a new Conda environment:
Type the following command into a terminal window:
bashconda create -n <environment_name> python=<version>For example:
bashconda create -n <environment_name> python=3.9
Activate the Conda environment:
bashconda activate <environment_name>
Other installs
- Git: Linux and Mac operating systems have Git preinstalled. If running on Windows, get Git.
- Graphviz: To display DataJoint diagrams, install Graphviz.
- Clone the U19-pipeline-python repository.
First-time configuration
The following commands configure DataJoint and connect to the DB.
bashconda activate <environment_name> cd U19-pipeline-python pip install -e . python initial_conf.py(You will be prompted for a username and password; your Princeton NetID and NetID password usually work.)
- The
initial_conf.pyscript stores a local file with the DB credentials and configuration variables/file paths. - Once the virtual modules for the database tables are created, you can query and fetch from the database.
- The
Connection after configuration
The following commands load the DataJoint configuration and connect to the DB. In a terminal:
bashconda activate <environment_name> pythonThen, in Python:
pythonfrom scripts.conf_file_finding import try_find_conf_file try_find_conf_file() import datajoint as dj dj.conn()
DB access for MATLAB repository
Prerequisites
Click to expand details
- Install DataJoint for MATLAB:
- Use MATLAB's built-in Add-On Explorer (top ribbon -> Add-Ons -> Get Add-Ons).
- Search for, select and install DataJoint.
- Clone the U19-pipeline-matlab repository.
First-time configuration
- Add this repository to the MATLAB path, or cd to the repository folder.
- Run
dj_initial_conf(1). - Enter the DB user name and password.
Note: if you are configuring the repository on a shared computer, there are two options:
- Run
dj_initial_conf(0)instead, so the user name and password are not stored in the configuration file. - Run
dj_initial_conf(1)and log in to the DB with a shared user such as u19tech.
Connection after configuration
- Add this repository to the MATLAB path, or cd to the repository folder.
- Run
connect_datajoint00.
DB access for MATLAB repository (cluster computing)
Prerequisites
Click to expand details
- Clone the U19-pipeline-matlab repository.
- Next to it, create a directory named
datajoint_matlab_libs. - Change to
datajoint_matlab_libsand clone the following repositories:
First-time configuration
- Add this repository to the MATLAB path.
- Run
startup_virtual_machine.m. - Run
dj_initial_conf(1). - Enter the DB user name and password.
Note: if you are configuring the repository on a shared computer, there are two options:
- Run
dj_initial_conf(0)instead, so the user name and password are not stored in the configuration file. - Run
dj_initial_conf(1)and log in to the DB with a shared user such as u19tech.
Connection after configuration
- Add this repository to the MATLAB path.
- Run
startup_virtual_machine.m.
Add a researcher to the user table
- These instructions only apply to users who will have subjects under their supervision.
With MATLAB
- Connect to the DB.
- Run
lab.utils.add_researcher_user_table('NETID', 'full name', 'email', 'phone'). - Note: all arguments must be quoted strings.
With Python
- Activate the Conda environment and start a Python shell.
- Run:python
import u19_pipeline.utils.insert_miscellaneous_db as imd imd.add_researcher_user_table('NETID', 'full name', 'email', 'phone') - Note: all arguments must be quoted strings.