Differences between revisions 1 and 2
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= FreeSurfer Python Development =

To ensure consistency and universal access to python libraries, a custom python (anaconda) distribution for internal freesurfer developers is installed at `/space/freesurfer/python/linux`. This way, as a lab, we can have complete control over the tools available to us. To make sure calls to `python` or `python3` point to this version, add the following to your PATH. '''''Note:''' the examples on this page assume you're using bash as your shell.''
Line 5: Line 9:
After setting this, any calls to python or python3 will use this install. Keep in mind that there's also a python3 link in `/usr/pubsw/bin`, so it's important that you `/space/freesurfer/python/linux/bin` comes first in your PATH. Keep in mind there's also a `python3` link in `/usr/pubsw/bin`, so it's important that `/space/freesurfer/python/linux/bin` comes first in your PATH.

=== Developing and Using the FreeSurfer Python Library ===

The freesurfer python library, which contains general fs utilities and various submodules like deepsurfer, gems, and samseg, is developed in the repository under `repo/python/freesurfer`. In order to utilize this library during development, you must point your `PYTHONPATH` at it:

{{{
export PYTHONPATH=/path/to/freesurfer-repository/python:$PYTHONPATH
}}}

This allows you to import your working version of the freesurfer library in any script or python interpreter. You can test this by calling `python` then running:

{{{
import freesurfer as fs
fs.run('echo hello!')
}}}
Line 9: Line 28:
If you're on a machine with cuda installed, you can use the gpu-enabled tensorflow by modifying the following search paths. By default, the cpu-tensorflow package is installed, but if you're on a machine with cuda installed, you can use the gpu-enabled tensorflow by adding to the following search paths:
Line 15: Line 34:

= FsPython =

FreeSurfer Python Development

To ensure consistency and universal access to python libraries, a custom python (anaconda) distribution for internal freesurfer developers is installed at /space/freesurfer/python/linux. This way, as a lab, we can have complete control over the tools available to us. To make sure calls to python or python3 point to this version, add the following to your PATH. Note: the examples on this page assume you're using bash as your shell.

export PATH=/space/freesurfer/python/linux/bin:$PATH

Keep in mind there's also a python3 link in /usr/pubsw/bin, so it's important that /space/freesurfer/python/linux/bin comes first in your PATH.

Developing and Using the FreeSurfer Python Library

The freesurfer python library, which contains general fs utilities and various submodules like deepsurfer, gems, and samseg, is developed in the repository under repo/python/freesurfer. In order to utilize this library during development, you must point your PYTHONPATH at it:

export PYTHONPATH=/path/to/freesurfer-repository/python:$PYTHONPATH

This allows you to import your working version of the freesurfer library in any script or python interpreter. You can test this by calling python then running:

import freesurfer as fs
fs.run('echo hello!')

Tensorflow GPU

By default, the cpu-tensorflow package is installed, but if you're on a machine with cuda installed, you can use the gpu-enabled tensorflow by adding to the following search paths:

export PYTHONPATH=/space/freesurfer/python/linux/tensorflow-gpu:$PYTHONPATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

FsPython

Python (last edited 2021-08-26 13:24:17 by AndrewHoopes)