brainextractor


Namebrainextractor JSON
Version 0.2.2 PyPI version JSON
download
home_page
Summarybrain extraction in python
upload_time2023-05-17 05:50:01
maintainer
docs_urlNone
author
requires_python>=3.7
licenseMIT License
keywords python image-processing neuroscience neuroimaging segmentation fsl brain-extraction skull-stripping
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # brainextractor
A re-implementation of FSL's Brain Extraction Tool in Python.

Follows the algorithm as described in:

```
Smith SM. Fast robust automated brain extraction. Hum Brain Mapp.
2002 Nov;17(3):143-55. doi: 10.1002/hbm.10062. PMID: 12391568; PMCID: PMC6871816.
```

This code was originally made for a [course project](https://www.cse.wustl.edu/~taoju/cse554/).

https://user-images.githubusercontent.com/3641187/190677589-be019bc6-60e4-4e96-8c71-266285ab0755.mp4

## Install

To install, use `pip` to install this repo:

```
# install from pypi
pip install brainextractor

# install repo with pip
pip install git+https://github.com/vanandrew/brainextractor@main

# install from local copy
pip install /path/to/local/repo
```

> **__NOTE:__** It is recommended to use `brainextractor` on **Python 3.7** and above.

## Usage

To extract a brain mask from an image, you can call:

```
# basic usage
brainextractor [input_image] [output_image]

# example
brainextractor /path/to/test_image.nii.gz /path/to/some_output_image.nii.gz
```

You can adjust the fractional intensity with the `-f` flag:

```
# with custom set threshold
brainextractor [input_image] [output_image] -f [threshold]

# example
brainextractor /path/to/test_image.nii.gz /path/to/some_output_image.nii.gz -f 0.4
```

To view the deformation process (as in the video above), you can use the `-w` flag to
write the surfaces to a file. Then use `brainextractor_render` to view them:

```
# writes surfaces to file
brainextractor [input_image] [output_image] -w [surfaces_file]

# load surfaces and render
brainextractor_render [surfaces_file]

# example
brainextractor /path/to/test_image.nii.gz /path/to/some_output_image.nii.gz -w /path/to/surface_file.surfaces

brainextractor_render /path/to/surface_file.surfaces
```

If you need an explanation of the options at any time, simply run the `--help` flag:

```
brainextractor --help
```

If you need to call Brainextractor directly from python:
```python
# import the nibabel library so we can read in a nifti image
import nibabel as nib
# import the BrainExtractor class
from brainextractor import BrainExtractor

# read in the image file first
input_img = nib.load("/content/MNI.nii.gz")

# create a BrainExtractor object using the input_img as input
# we just use the default arguments here, but look at the
# BrainExtractor class in the code for the full argument list
bet = BrainExtractor(img=input_img)

# run the brain extraction
# this will by default run for 1000 iterations
# I recommend looking at the run method to see how it works
bet.run()

# save the computed mask out to file
bet.save_mask("/content/MNI_mask.nii.gz")
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "brainextractor",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "python,image-processing,neuroscience,neuroimaging,segmentation,fsl,brain-extraction,skull-stripping",
    "author": "",
    "author_email": "Andrew Van <vanandrew@wustl.edu>",
    "download_url": "https://files.pythonhosted.org/packages/29/63/eb0e4e41406480981ae657fff94956b3c1c6c0c79ba2953069f88ea5e4c2/brainextractor-0.2.2.tar.gz",
    "platform": null,
    "description": "# brainextractor\nA re-implementation of FSL's Brain Extraction Tool in Python.\n\nFollows the algorithm as described in:\n\n```\nSmith SM. Fast robust automated brain extraction. Hum Brain Mapp.\n2002 Nov;17(3):143-55. doi: 10.1002/hbm.10062. PMID: 12391568; PMCID: PMC6871816.\n```\n\nThis code was originally made for a [course project](https://www.cse.wustl.edu/~taoju/cse554/).\n\nhttps://user-images.githubusercontent.com/3641187/190677589-be019bc6-60e4-4e96-8c71-266285ab0755.mp4\n\n## Install\n\nTo install, use `pip` to install this repo:\n\n```\n# install from pypi\npip install brainextractor\n\n# install repo with pip\npip install git+https://github.com/vanandrew/brainextractor@main\n\n# install from local copy\npip install /path/to/local/repo\n```\n\n> **__NOTE:__** It is recommended to use `brainextractor` on **Python 3.7** and above.\n\n## Usage\n\nTo extract a brain mask from an image, you can call:\n\n```\n# basic usage\nbrainextractor [input_image] [output_image]\n\n# example\nbrainextractor /path/to/test_image.nii.gz /path/to/some_output_image.nii.gz\n```\n\nYou can adjust the fractional intensity with the `-f` flag:\n\n```\n# with custom set threshold\nbrainextractor [input_image] [output_image] -f [threshold]\n\n# example\nbrainextractor /path/to/test_image.nii.gz /path/to/some_output_image.nii.gz -f 0.4\n```\n\nTo view the deformation process (as in the video above), you can use the `-w` flag to\nwrite the surfaces to a file. Then use `brainextractor_render` to view them:\n\n```\n# writes surfaces to file\nbrainextractor [input_image] [output_image] -w [surfaces_file]\n\n# load surfaces and render\nbrainextractor_render [surfaces_file]\n\n# example\nbrainextractor /path/to/test_image.nii.gz /path/to/some_output_image.nii.gz -w /path/to/surface_file.surfaces\n\nbrainextractor_render /path/to/surface_file.surfaces\n```\n\nIf you need an explanation of the options at any time, simply run the `--help` flag:\n\n```\nbrainextractor --help\n```\n\nIf you need to call Brainextractor directly from python:\n```python\n# import the nibabel library so we can read in a nifti image\nimport nibabel as nib\n# import the BrainExtractor class\nfrom brainextractor import BrainExtractor\n\n# read in the image file first\ninput_img = nib.load(\"/content/MNI.nii.gz\")\n\n# create a BrainExtractor object using the input_img as input\n# we just use the default arguments here, but look at the\n# BrainExtractor class in the code for the full argument list\nbet = BrainExtractor(img=input_img)\n\n# run the brain extraction\n# this will by default run for 1000 iterations\n# I recommend looking at the run method to see how it works\nbet.run()\n\n# save the computed mask out to file\nbet.save_mask(\"/content/MNI_mask.nii.gz\")\n```\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "brain extraction in python",
    "version": "0.2.2",
    "project_urls": {
        "github": "https://github.com/vanandrew/brainextractor"
    },
    "split_keywords": [
        "python",
        "image-processing",
        "neuroscience",
        "neuroimaging",
        "segmentation",
        "fsl",
        "brain-extraction",
        "skull-stripping"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5b734fceb923d4fc86b00cc5f20b06c7d1e6869a7e8242788af52378a1b5a55a",
                "md5": "9658eed4e6c6f9eb126de73cb404dc4d",
                "sha256": "e4be1d3a093c28e92a5d2262f60847a1845e949e046dd543ba8aed01aed5bb7b"
            },
            "downloads": -1,
            "filename": "brainextractor-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9658eed4e6c6f9eb126de73cb404dc4d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 13776,
            "upload_time": "2023-05-17T05:49:59",
            "upload_time_iso_8601": "2023-05-17T05:49:59.026781Z",
            "url": "https://files.pythonhosted.org/packages/5b/73/4fceb923d4fc86b00cc5f20b06c7d1e6869a7e8242788af52378a1b5a55a/brainextractor-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2963eb0e4e41406480981ae657fff94956b3c1c6c0c79ba2953069f88ea5e4c2",
                "md5": "2eebc531169ccb86389ca7b69cc29174",
                "sha256": "0d9a627ee28281373aec7c8d38f102c15963f5d8d2e8980590e6ca563fde1b56"
            },
            "downloads": -1,
            "filename": "brainextractor-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "2eebc531169ccb86389ca7b69cc29174",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 13353,
            "upload_time": "2023-05-17T05:50:01",
            "upload_time_iso_8601": "2023-05-17T05:50:01.007670Z",
            "url": "https://files.pythonhosted.org/packages/29/63/eb0e4e41406480981ae657fff94956b3c1c6c0c79ba2953069f88ea5e4c2/brainextractor-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-17 05:50:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "vanandrew",
    "github_project": "brainextractor",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "brainextractor"
}
        
Elapsed time: 1.16481s