aghaeifar / bet2

MATLAB mex interface and Python wrapper for standalone Brain Extraction Tool (bet2),

Home Page:http://fsl.fmrib.ox.ac.uk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bet2

standalone Brain Extraction Tool (bet2) with python wrapper, released by http://fsl.fmrib.ox.ac.uk/

The following features are added:

  • The program is reconfigured using CMake
  • CMake configures MATLAB mex target as well.
  • Building static and dynamic library (dll or so) of BET
  • Support Windows and Linux

To build:

git clone https://github.com/aghaeifar/bet2.git
cd bet2
mkdir build
cd build
cmake ..
make -j4

To use MATLAB mex interface:

bet2_mex(input)

where input is a 3D single real array.

To use in Python:

import ctypes
handle = ctypes.CDLL(os.path.join(dir_path, "lib", "libbet2.so"))
handle.runBET.argtypes = [np.ctypeslib.ndpointer(np.float32, ndim=self.img_mag.ndim, flags='F'),
                np.ctypeslib.ndpointer(np.float32, ndim=len(mask_size), flags='F'),
                ctypes.c_int, ctypes.c_int, ctypes.c_int]
mask_size = mag.shape
mag = self.img_mag.copy(order='F')
mask = np.zeros(mask_size, dtype=mag.dtype, order='F')
handle.runBET(mag, mask, *mask_size)

where input is a 3D float32 real numpy array.

Precompiled mex files for Windows and Linux can be downloaded in the repository releases.

About

MATLAB mex interface and Python wrapper for standalone Brain Extraction Tool (bet2),

http://fsl.fmrib.ox.ac.uk

License:Other


Languages

Language:C++ 62.6%Language:C 29.1%Language:HTML 5.1%Language:Makefile 1.7%Language:Shell 0.7%Language:Tcl 0.5%Language:CMake 0.2%Language:Python 0.1%Language:CSS 0.0%