1. Get Started¶
1.1. Requirements¶
python==3.6.x/3.7.x
1.16.5=<numpy<1.18
nibabel>=2.4.1
nipy>=0.4.2
h5py>=2.9.0
scikit-image>=0.15.0
scikit-learn>=0.19.1
scipy>=1.3.1
torch>=1.3.0
torchvision>=0.4.2
pillow>=6.0.0
opencv-python>=4.1.0.25
matplotlib>=2.2.2
cifti>=1.1
resampy
soundfile
six
A easy way to get most of these requirements is to install a python distribution (e.g. Anaconda is recommended).
1.2. Install from source¶
Get source code
Method1: Download source archive file (zip file) from GitHub and unpack it.
Method2: Clone the DNNBrain repostitory by executing:git clone https://github.com/BNUCNL/dnnbrain.gitExecute setup.py
Change to source directory (it should have the files README.md and setup.py).
Runpython setup.py install
–-user option:python setup.py install --user–-prefix or –-home options to setup.py.1.3. Install portable edition¶
This installation scheme allows you put DNNBrain anywhere you like as long as setting the two environment variables (PATH and PYTHONPATH) appropriately. The scheme is described as below:
Get source code through methods mentioned at step 1 of Install from source.
Add source directory (named as path_to_dnnbrain) to PYTHONPATH and “bin” directory under it (named as path_to_dnnbrain_bin) to PATH.
1.4. Configuration¶
No matter what installation scheme you choose, you have to set the environment variable DNNBRAIN_DATA whose value is the absolute path of a directory that used to store DNNBrain’s data, such as test data and pretrained parameters of DNNs.
Note: If you work with DNNBrain on a public platform, such as a Linux server, DNNBRAIN_DATA should be configured by the administrator of the platform.
Note: The updates for PATH and PYTHONPATH are optional according to the installation scheme’s requirement you choose.
Linux | MAC OS X¶
Open a terminal window and make sure that you know which “shell” you are
running (If not sure, try running the command printenv SHELL).
For bash shell, run the following commands to set environment variables:
echo 'export DNNBRAIN_DATA=path_to_dnnbrain_data' >> ~/.bashrc
echo 'export PATH=path_to_dnnbrain_bin:$PATH' >> ~/.bashrc
echo 'export PYTHONPATH=path_to_dnnbrain:$PYTHONPATH' >> ~/.bashrc
For tcsh/csh shell, run the following commands to set environment variables:
echo 'set DNNBRAIN_DATA=path_to_dnnbrain_data' >> ~/.cshrc
echo 'set PATH=(path_to_dnnbrain_bin $PATH)' >> ~/.cshrc
echo 'set PYTHONPATH=(path_to_dnnbrain $PYTHONPATH)' >> ~/.cshrc
Alternatively, you can also set environment variables by editing .bashrc or .cshrc file in a text editor.
You have to make these changes be effective by openning a new terminal window or “source” the .bashrc/.cshrc file in the current terminal window.
Windows¶
Note: DNNBrain scripts in path_to_dnnbrain_bin are only executable in UNIX-like shell, such as git bash.
Open the environment variable editor which can be found under “Windows Menu —> Control Panel —> Advanced System Settings —> Environment Variables”. Then:
Create a new environment variable named DNNBRAIN_DATA with value as path_to_dnnbrain_data.
Add path_to_dnnbrain_bin to PATH.
Add path_to_dnnbrain to PYTHONPATH (If PYTHONPATH is not existed, create a new one).
Separate multiple paths with semicolons (;).
Alternatively, you can use the following commands in PowerShell to complete the above 3 steps (Please replace the path between asterisks with the real path, for example, the *path_to_dnnbrain* should be replaced with the 'F:\Python3.6.5\Lib\site-packages\dnnbrain')
$new_path = *path_to_dnnbrain_data*
[environment]::SetEnvironmentvariable('DNNBRAIN_DATA', $new_path, "User")
$old_path = [environment]::GetEnvironmentvariable("PATH", "User")
$path_to_dnnbrain_data_bin = *path_to_dnnbrain_data_bin*
$new_path=$old_path,$path_to_dnnbrain_data_bin -Join ";"
[environment]::SetEnvironmentvariable("PATH", $new_path, "User")
$old_path = [environment]::GetEnvironmentvariable("PYTHONPATH", "User")
$path_to_dnnbrain = *path_to_dnnbrain*
$new_path=$old_path,$path_to_dnnbrain -Join ";"
[environment]::SetEnvironmentvariable("PYTHONPATH", $new_path, "User")
1.5. Download DNN parameters¶
The pretrained parameters are always necessary and they should be placed in the “models” directory under the DNNBRAIN_DATA.