cni / nims

Legacy version of NIMS. All new development at @scitran
14 stars 12 forks source link

NIMS: Neurobiological Image Management System

Legacy version of NIMS. All new development happening under @scitran.

NIMS is a scientific data management system, specifically designed for neuroimaging data. It is implemented in Python, based on TurboGears. NIMS is open-source software, released under the MIT license (see below for details).

NIMS Development on Ubuntu 12.04

Set up a virtual python environment:

sudo apt-get install build-essential python-dev python-virtualenv python-numpy python-imaging python-h5py
virtualenv --system-site-packages tg2env
source tg2env/bin/activate

Install the TurboGears development tools:

easy_install -i http://turbogears.org/2.2/downloads/2.2.0 tg.devtools

Clone NIMS from GitHub and install its dependencies:

git clone git@github.com:cni/nims.git
cd nims
python setup.py develop
easy_install "repoze.what >= 1.0.8" "repoze.what-quickstart"

Optionally, add PostgreSQL and LDAP support:

sudo apt-get install postgresql-client libpq-dev
easy_install psycopg2

sudo apt-get install libldap2-dev libsasl2-dev
easy_install python-ldap

Generate a development database and start the paste web server:

paster setup-app development.ini --name=nimsgears
paster serve --reload development.ini

NIMS Deployment on Ubuntu Server 12.04 and Apache

Set up a virtual python environment:

apt-get install build-essential python-dev python-virtualenv php5 libapache2-mod-wsgi libapache2-webauth
virtualenv --system-site-packages /var/local/tg2env
source /var/local/tg2env/bin/activate

Clone NIMS from GitHub and install its dependencies:

easy_install -i http://turbogears.org/2.2/downloads/2.2.0 tg.devtools
git clone git://github.com/cni/nims.git /var/local/nims
cd !$
python setup.py develop

Add PostgreSQL and LDAP support:

apt-get install postgresql-client libpq-dev python-ldap
easy_install psycopg2

Generate the production database:

# first, obtain or create production.ini
paster setup-app production.ini

Configure and restart Apache:

ln -s $PWD/apache.conf /etc/apache2/conf.d/nims.conf
mkdir /var/cache/nimsgears && chown www-data:www-data /var/cache/nimsgears
service apache2 restart

Populating the Database

Once you have the NIMS web GUI running, you need to get your data into NIMS. We use various utilities to pull data from the MR scanner and insert it into NIMS. We use a suite of python scripts (various reapers, sorter.py, scheduler.py and processor.py, all in nimsproc) to do this. The reapers (dicomreaper.py, pfilereaper.py) copy data from the scanner and put it in the NIMS staging area. The sorter moves data from the staging area into the NIMS storage area and creates appropriate database entries. The scheduler finds new datasets in the database and schedules processing jobs for them. The processor executes the scheduled jobs. Some processing steps involve finding peripheral data files associated with the dataset, such as physio files. This is also where NIfTI creation happens and image pyramids are generated. All these tools have nice command-line help, so usage should be self-explanatory.

You also need to run a process to maintain the shadow filesystem, which is a view into the data files that provides human-friendly paths, which are based on the database (e.g., all datasets for an experiment "exp1" will appear in a directory called "exp1"). Each user gets their own shadow filesystem, and it allows them to have read-only access to the data through, e.g., scp. This shadow filesystem is rebuilt periodically to keep it in sync with the current DB structure (see nimsutil/symlinks.py).

We usually launch all these processes using screen, so that we can connect to the screen session from anywhere to check on them. We provide an example .screenrc file that launches all the processes in separate screens (run as "screen -c reaper.screenrc").

Data are automatically organized by the sorter using the PatientID field from DICOM files (or the analogous field in the raw MR data files). The format of the Patient ID string is PI_UID/experiment_name.

License

Copyright (c) 2014 The Board of Trustees of the Leland Stanford Junior University

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.