{"id":19034836,"url":"https://github.com/int-brain-lab/ibl-pipeline","last_synced_at":"2025-04-23T17:47:14.403Z","repository":{"id":51044808,"uuid":"155388632","full_name":"int-brain-lab/IBL-pipeline","owner":"int-brain-lab","description":"DataJoint pipeline for IBL project","archived":false,"fork":false,"pushed_at":"2022-12-15T17:53:23.000Z","size":89013,"stargazers_count":20,"open_issues_count":11,"forks_count":32,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-18T04:12:28.594Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/int-brain-lab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-30T13:18:45.000Z","updated_at":"2025-01-14T17:56:12.000Z","dependencies_parsed_at":"2023-01-29T04:00:54.731Z","dependency_job_id":null,"html_url":"https://github.com/int-brain-lab/IBL-pipeline","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/int-brain-lab%2FIBL-pipeline","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/int-brain-lab%2FIBL-pipeline/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/int-brain-lab%2FIBL-pipeline/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/int-brain-lab%2FIBL-pipeline/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/int-brain-lab","download_url":"https://codeload.github.com/int-brain-lab/IBL-pipeline/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250485069,"owners_count":21438359,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T21:47:41.624Z","updated_at":"2025-04-23T17:47:14.378Z","avatar_url":"https://github.com/int-brain-lab.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Identify your role\n\nThis is important to identify how you would work with IBL-pipeline. There are two typical roles:\n\n1. User:\n\u003e* Internal user: an IBL user who would like to utilize the IBL-pipeline to query the IBL database for research and create downstream tables for their own analyses in the IBL database, but a user will not contribute to the development of the main IBL pipeline.\n\u003e* External user: similar to an internal user, but an external user will not use IBL database to access data, but would like to adopt the database schemas and tables from IBL pipeline.\n\n2. Developer: besides the actions of the users, a developer would like to contribute to the daily ingestion, computation, and plotting of the IBL-pipeline.\n\n\n# Instruction for users\n\n1. Get credentials to the database  server\n\u003e For an IBL internal user, contact Shan Shen via shanshen@vathes.com or Slack for a username and an initial password to the IBL database. You can change your password with\n```\nimport datajoint as dj\ndj.set_password()\n```\n\u003e For an external user, set up your own database server and here is an [instruction](https://docs.datajoint.io/python/admin/1-hosting.html).\n\n2. Install IBL-pipeline python package\n\n\u003e Install the package with pip, this gives the latest version. Use pip3 instead of pip does not work properly.\n\n```\npip install ibl-pipeline\n```\n\u003e To upgrade to the latest version,\n```\npip install --upgrade ibl-pipeline\n```\n\u003e After the installation, `datajoint` and `ibl_pipeline` could be imported as regular modules\n3. Set up the configuration of DataJoint.\n\u003e Now you have successfully installed datajoint and ibl_pipeline package, to properly connect to the database server, set up the configuration by specifying dj.config.\n\n```\nshanshen@Shans-MacBook-Pro:~$ ipython\nIn [1]: import datajoint as dj\n\nIn [2]: dj.config\nOut[2]:\n{   'connection.charset': '',\n    'connection.init_function': None,\n    'database.host': 'localhost',\n    'database.password': None,\n    'database.port': 3306,\n    'database.reconnect': True,\n    'database.user': None,\n    'display.limit': 12,\n    'display.show_tuple_count': True,\n    'display.width': 14,\n    'fetch_format': 'array',\n    'loglevel': 'INFO',\n    'safemode': True}\n```\n\u003e The default value of dj.config is shown as above. You will need to change the fields:\n```\ndj.config['database.host'] = 'datajoint.internationalbrainlab.org'\ndj.config['database.user'] = 'YOUR_USERNAME'\ndj.config['database.password'] = 'YOUR_PASSWORD'\n```\n\n\u003e Then save the configuration as a json file with either dj.config.save_local(), or dj.config.save_global(). If saved globally, this configuration will be applied in all directories. If saved locally, it only applies when you under your current directory. The configuration will be saved as a json file dj_local_conf.json in the current directory. You don’t need to set up the configuration the next time.\n\n\u003e You can start using ibl_pipeline by importing modules, such as:\n\n```\nfrom ibl_pipeline import reference, subject, action, acquisition, data, behavior, ephys, histology\n```\n\n4. Special notes: the IBL-pipeline is under active development, the tables of interests may have already existed in the database before the latest version of ibl-pipeline is released. To get access to the latest tables, we also recommend using `dj.create_virtual_module`. The syntax to create a virtual module is as follows:\n```\nbehavior = dj.create_virtual_module('behavior', 'ibl_behavior')\n```\n\n\u003e Then `behavior` could be used to access any table:\n\n```\nbehavior.TrialSet()\n```\n\n# Instruction for developers\n\n1. Email shanshen@vathes.com for a database username and initial password.\n\n2. Install Docker (https://www.docker.com/). Linux users also need to install Docker Compose separately. For Mac: https://docs.docker.com/docker-for-mac/.\n\n3. Fork the repository (https://github.com/int-brain-lab/IBL-pipeline) onto your own GitHub account by clicking on the 'Fork' button in the top right corner of Github.\n\n4. Clone the forked repository, i.e. copy the files to your local machine by `git clone git@github.com:YourUserName/IBL-pipeline.git`. Important: do *not* clone the repo from `int-brain-lab`, but the one that you forked onto your own account!\n\nIf you don't have SSH setup, use `git clone https://github.com/YourUserName/IBL-pipeline.git`. See https://help.github.com/articles/which-remote-url-should-i-use/ for an explanation of the distinction - in the long run, it's convenient to setup SSH authorization so you don't have to type passwords every time.\n\n5. Create a file with the name `.env` (in your favourite text editor) in the cloned directory and **modify user and password values** per Step 1.\n\n    File contents of ``.env``:\n    ```\n    DJ_HOST=datajoint.internationalbrainlab.org\n    DJ_USER=username\n    DJ_PASS=password\n    ```\n\n6. Now let's set up the docker container that have the entire environment.\n\n\u003e Copy `docker-compose-template.yml` as `docker-compose.yml` - this is your own file you can customize.\n\n\u003e Note: There is a similar file called `docker-compose-local_template.yml`. You will not need it unless you would like to perform ingestion from scratch in the database hosted on your own machine.\n\n\u003e There are two properties that you may want to customize.\n\n\u003e First, to save figures in a folder outside your `IBL-pipeline` docker folder (which is good practice so you don't clutter up the Github repo), you can tell Docker to create an alias older which points to your preferred place for storing figures.\n\n\ta. `open docker-compose.yml`\n\n\tb. add any folder you would like to access within the docker container in to the `volumes:`\n    for example '~/Documents/ephys_data:/ephys_data'\n\n\tc. close the file\n\n\u003e Second, Set up your `.one_params`.\n\n\u003e If you have your `.one_params` in your root directory `~/.one_params`, you can directly go to Step 7. If you have your `.one_params` in another directory, please change the mapping `docker-compose.yml`\nin the `volumes:` section `your-directory-to-one_params/.one_params: /root/.one_params`.\n\nAfter your are done with these customization, you are ready to start the docker container, by running:\n`docker-compose up -d`. You can check the status of the docker container by `docker ps`\n\n\nNote: Anytime you would like to change the mapping from an outside folder to a directory inside docker container after you have your docker-compose running, please stop your docker container with the command 'docker-compose down', before you do the above steps.\n\n\n\n## To run your own Python scripts ##\n\n7. After running the docker container, you may want to use enter the container to run your own script. The command is `docker exec -it ibl-pipeline_datajoint_1 /bin/bash`. You would then enter the container with the current directory `/notebooks`. You can use `cd` to navigate inside the docker container.\n\n\u003e Note: If you would like to go to a specific folder, for example `prelim_analyses/behavioral_snapshots`at the same time when you run `docker exec`, you can use this command line: `docker exec -it docker exec -it ibl-pipeline_datajoint_1 bash -c \"cd /src/IBL-pipeline/prelim_analyses/behavioral_snapshots; exec /bin/bash\"`\n\n8. To simplify the process of setting up the docker environment, we prepared a bash script `ibl_docker_setup-template.sh`. You may first want to copy this template by `cp ibl_docker_setup-template.sh ibl_docker_setup.sh`, then customize your own `ibl_docker_setup.sh`. In the file, you can change the directory you want to go to in the last line. The default command in the last line is: `docker exec -it docker exec -it ibl-pipeline_datajoint_1 bash -c \"cd /src/IBL-pipeline/prelim_analyses/; exec /bin/bash\"`, which goes to the folder `IBL-pipeline/prelim_analyses`. You can replace this directory with the directory you would like to go to.\n\nAfter setting up this customized file `ibl_docker_setup.sh`, you can run this file to set up all your docker environment, by running `bash ibl_docker_setup.sh`\n\n\n### Run your Python scripts after Docker is already installed for the first time ###\n\n```\n./ibl_docker_setup.sh\ncd /src/ibl-pipeline/ibl_pipeline/analyses\npython behavioral_snapshot.py\n```\n\n## To run example notebooks ##\n\n9. Move into the cloned directory in a terminal, then run `docker-compose up -d`.\n\n10. Go to http://localhost:8888/tree in your favorite browser to open Jupyter Notebook.\n\n11. Open the directory `notebooks_tutorial` and feel free to go to through the tutorials.\n\n\n### Staying up-to date ###\n\nTo stay up-to-date with the latest code from DataJoint, you might first want to check by `git remote -v`.\nIf there is no upstream pointing to the int-brain-lab repository, then do `git remote add upstream https://github.com/int-brain-lab/IBL-pipeline`.\n\nThen `git pull upstream master` will make sure that your local fork stays up to date with the original repo.\n\n#### Contributing code ####\n\nIf you feel happy with the changes you've made, you can add, commit and push them to your own branch. Then go to https://github.com/int-brain-lab/IBL-pipeline, click 'Pull requests', 'New pull request', 'compare across forks', and select your fork of `IBL-pipeline`. If there are no merge conflicts, you can click 'Create pull request', explain what changes/contributions you've made, and and submit it to the DataJoint team for approval.\n\n\n\n# IBL pipeline schemas #\n\nSchema of `reference`:\n![Reference Diagram](images/ephys.png)\n\nSchema of `subject`:\n![Subject Diagram](images/subject.png)\n\nSchema of `action`:\n![Action Diagram](images/action.png)\n\nSchema of `acquisition`:\n![Acquisition Diagram](images/acquisition.png)\n\nSchema of `data`:\n![DataDiagram](images/data.png)\n\nSchema of `behavior`\n![Behavior erd](images/behavior.png)\n\nSchema of `behavior_analyses`:\n![Behavior analyses Diagram](images/behavior_analyses.png)\n\nSchema of `ephys`\n![Ephys erd](images/ephys.png)\n\nSchema of `histology`:\n![Histology Diagram](images/histology.png)\n\nSchema of `qc`:\n\n\n![Quality check Diagram](images/qc.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fint-brain-lab%2Fibl-pipeline","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fint-brain-lab%2Fibl-pipeline","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fint-brain-lab%2Fibl-pipeline/lists"}