Database Access

First steps

Mount file server volumes

  • Several data files (behavior, imaging, and electrophysiology) are referenced in the database.

  • To access these files, mount the PNI file server volumes on your system.

  • Data is stored across three main file servers at PNI (braininit, Bezos, and u19_dj).

On windows systems

  1. 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)
  1. Authenticate with your NetID and PU password (NOT your PNI password, which may be different). When prompted for your username, enter PRINCETON\netid (note that PRINCETON can be upper or lower case), where netid is your PU NetID.

On OS X systems

  1. Select "Go->Connect to Server..." from Finder 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)
  1. Authenticate with your NetID and PU password (NOT your PNI password, which may be different).

On Linux systems

  1. Follow the extra steps described in this link.

DB Access for Python repository

Prerequisites

Click to expand details

Install an integrated development environment

  • DataJoint development and use can be done with a plain text editor in the terminal. However, 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.open in new window

  • 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 virtual environment managers, and you can use either option. Below are the commands for Conda.

  • If you are setting up the pipeline on your local machine, follow the instructions below for Conda. If you are using spock.pni.princeton.edu or scotty.pni.princeton.edu, Conda is preinstalled and you can access it by running module load anacondapy/2021.11.

  • We will install Miniconda, a minimal installer for Conda.

  • Select the Miniconda installer linkopen in new window 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 modify and run the following command

        export PATH="<absolute-path-to-miniconda-directory>/bin:$PATH"
        
    • Create a new conda environment

      • Type the following command into a terminal window

        conda create -n <environment_name> python=<version>
        
      • Example command to create a conda environment

        conda create -n <environment_name> python=3.9
        
    • Activate the conda environment

      conda activate <environment_name>
      

    Other installs

First time configuration

  • The following instructions will configure DJ and connect to the DB.

    conda activate <environment_name>
    cd U19-pipeline_python
    pip install -e .
    python initial_conf.py
    

    (Username and password will be prompted at this moment: Princeton NetID and NetID password usually works)

    • The initial_conf.py script will store a local file with the credentials to access the DB and configuration variables/filepaths.
    • Now that the virtual modules are created to access the tables in the database, you can query and fetch from the database.

Connection after configuration

  • The following instructions will load the DJ configuration and connect to the DB.

    conda activate <environment_name>
    python
    from 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 the MATLAB built-in GUI, i.e. 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 this repository folder.
  • Run dj_initial_conf(1)
  • Insert the user and password for the DB

Note: if you are configuring the repository on a public computer, there are two options:

  • Run dj_initial_conf(0) instead, to avoid storing the user and password in the configuration file.
  • Run dj_initial_conf(1) and log in to the DB with a public user like u19tech.

Connection after configuration

  • Add this repository to the MATLAB Path, or cd to this repository folder.
  • connect_datajoint00

DB Access for MATLAB repository (cluster computing)

Prerequisites

Click to expand details

First time configuration

  • Add this repository to the MATLAB Path
  • Run startup_virtual_machine.m
  • Run dj_initial_conf(1)
  • Insert the user and password for the DB

Note: if you are configuring the repository on a public computer, there are two options:

  • Run dj_initial_conf(0) instead, to avoid storing the user and password in the configuration file.
  • Run dj_initial_conf(1) and log in to the DB with a public user like u19tech.

Connection after configuration

  • Add this repository to the MATLAB Path
  • Run startup_virtual_machine.m

Add researcher to user table

  • This set of instructions applies only to users who will have subjects under their supervision:

Add researcher to user table with MATLAB

  • Connect to the DB
  • Run lab.utils.add_researcher_user_table('NETID', 'full name', 'email', 'phone')
  • Note: (All data in the function call should be written inside quotes)

Add researcher to user table with PYTHON

  • Activate the conda environment and start a Python command line
  • import u19_pipeline.utils.insert_miscellaneous_db as imdimd.add_researcher_user_table('NETID', 'full name', 'email', 'phone')
  • Note: (All data in the function call should be written inside quotes)