{"id":18785255,"url":"https://github.com/dbouget/mri_brain_tumor_segmentation","last_synced_at":"2025-04-13T12:33:50.424Z","repository":{"id":52672844,"uuid":"323941104","full_name":"dbouget/mri_brain_tumor_segmentation","owner":"dbouget","description":null,"archived":false,"fork":false,"pushed_at":"2021-04-21T14:19:24.000Z","size":1230,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-05-21T06:14:21.849Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dbouget.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-23T15:45:11.000Z","updated_at":"2024-03-05T04:51:50.000Z","dependencies_parsed_at":"2022-08-22T03:40:45.102Z","dependency_job_id":null,"html_url":"https://github.com/dbouget/mri_brain_tumor_segmentation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbouget%2Fmri_brain_tumor_segmentation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbouget%2Fmri_brain_tumor_segmentation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbouget%2Fmri_brain_tumor_segmentation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbouget%2Fmri_brain_tumor_segmentation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dbouget","download_url":"https://codeload.github.com/dbouget/mri_brain_tumor_segmentation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223588790,"owners_count":17169882,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T20:46:05.036Z","updated_at":"2024-11-07T20:46:05.573Z","avatar_url":"https://github.com/dbouget.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Meningioma segmentation in T1-weighted MRI leveraging global context and attention mechanisms\n- - -\n\n## 1. Description\nThe repository contains the architectures, inference code,\nand trained models for meningioma segmentation in T1-weighted MRI volumes.\n\nPlease cite the following article if you re-use any part:\n\u003e`@misc{bouget2021meningioma,`  \n      `title={Meningioma segmentation in T1-weighted MRI leveraging global context and attention mechanisms},`  \n      `author={David Bouget and André Pedersen and Sayied Abdol Mohieb Hosainey and Ole Solheim and Ingerid Reinertsen},`  \n      `year={2021},`  \n      `eprint={2101.07715},`  \n      `archivePrefix={arXiv},`  \n      `primaryClass={eess.IV}`  \n`}`\n\n![Dual attention guided U-Net architecture](resources/images/DAGUNet-Arch.png)\n\n## 2. Installation\nThe following steps have been tested on both Ubuntu and Windows. The details below are for Linux. See the troubleshooting section below for Windows-specific details. \n### a. Python\nThe Python virtual environment can be setup using the following commands:  \n\n\u003e `virtualenv -p python3 venv`  \n`source venv/bin/activate`  \n`pip install -r requirements.txt`\n\n### b. Docker  \nSimply download the corresponding Docker image:  \n\n\u003e `docker pull dbouget/mri_brain-tumor_segmentation:v1`\n\n### c. Models\nIn order to download the models locally and prepare the folders, simply run the following:   \n\n\u003e `source venv/bin/activate`  \n`python setup.py`  \n`deactivate`\n\n## 3. Use\nThe command line input parameters are the following:\n- i [Input]: Path to the MRI volume file, preferably in nifti format. Other formats will\n  be converted to nifti before being processed, using SimpleITK.  \n- o [Output]: Path and prefix for the predictions file. The base name must already exist\n  on disk.\n- m [Model]: Name of the model to use for inference, in the list [UNet-Slabs, PLS-Net, UNet-FV, AGUNet, DAGUNet] \n- g [GPU]: Id of the GPU to use for inference. The CPU is used if no eligible number is provided.\n\nA runtime configuration file also exists in resources/data/runtime_config.ini,\nwhere additional variables can be modified:  \n- non_overlapping: [true, false], only in effect for the UNet-Slabs model. \n  True indicates no overlapping in predictions while false indicates stride 1 overlap.\n- reconstruction_method: [thresholding, probabilities]. In the latter, raw prediction maps\n  in range [0, 1] are dumped while in the former a binary mask is dumped using a pre-set\n  probability threshold value.\n- reconstruction_order: [resample_first, resample_second]. In the former, the raw probability map\n  is resampled to the original patient's space before the reconstruction happens (slower) while\n  in the former the opposite is performed (faster).  \n- probability_threshold: threshold value to be used when the reconstruction method is set to thresholding\n  (optimal values for each model can be found in the paper).\n  \n### a. Python\nTo run inference with the attention-gated U-Net model, using GPU 0, execute the following in the project root directory:  \n\u003e `source venv/bin/activate`  \n`python main.py -i /path/to/file.nii.gz -o /output/path/to/output_prefix -m AGUNet -g 0`  \n`deactivate`\n\n### b. Docker\nThe local resources sub-folder is mapped to the resources sub-folder within the docker container.\nAs such, input MRI volumes have to be copied inside resources/data to be processed and the output folder\nfor the predictions has to be set within the resources sub-folder to be accessible locally.  \n:warning: The docker container does not have gpu support so all inferences are performed on CPU only.   \n\n\u003e `cp /path/to/mri.nii.gz /path/to/mri_brain_tumor_segmentation/resources/data/mri.nii.gz`    \n`docker run --entrypoint /bin/bash -v /path/to/mri_brain_tumor_segmentation/resources:/home/ubuntu/resources -t -i dbouget/mri_brain-tumor_segmentation:v1`  \n`python3 main.py -i ./resources/data/mri.nii.gz -o ./resources/output_prefix -m AGUNet`  \n\n\n## 4. Acknowledgements\nParts of the models' architectures were collected from the following repositories:  \n- https://github.com/niecongchong/DANet-keras/  \n- https://github.com/ozan-oktay/Attention-Gated-Networks  \n\nFor more detailed information about attention mechanisms, please read the corresponding publications:\n\n\u003e`@inproceedings{fu2019dual,`  \n  `title={Dual attention network for scene segmentation},`  \n  `author={Fu, Jun and Liu, Jing and Tian, Haijie and Li, Yong and Bao, Yongjun and Fang, Zhiwei and Lu, Hanqing},`    \n  `booktitle={Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition},`  \n  `pages={3146--3154},`  \n  `year={2019}`  \n`}`\n\n\u003e`@article{oktay2018attention,`  \n  `title={Attention u-net: Learning where to look for the pancreas},`  \n  `author={Oktay, Ozan and Schlemper, Jo and Folgoc, Loic Le and Lee, Matthew and Heinrich, Mattias and Misawa, Kazunari and Mori, Kensaku and McDonagh, Steven and Hammerla, Nils Y and Kainz, Bernhard and others},`  \n  `journal={arXiv preprint arXiv:1804.03999},`  \n  `year={2018}`  \n`}`\n\n## Troubleshooting\nOn windows, to activate the virtual environment, run:\n\u003e `.\\venv\\Scripts\\activate`\n\nThis assumes that one is using [virtualenv](https://pypi.org/project/virtualenv/) to make virtual environments. This can be easily installed using pip by:\n\u003e `pip install virtualenv`\n\nWhen installing dependencies (in a virtual environment), you might have a problem installing torch:\n```\nERROR: Could not find a version that satisfies the requirement torch==1.4.0\nERROR: No matching distribution found for torch==1.4.0\n```\n\nIf so, install torch using this command:\n\u003e `pip install torch===1.4.0 torchvision===0.5.0 -f https://download.pytorch.org/whl/torch_stable.html`\n\nThen, run the same line to install dependencies, and to properly verify that all dependencies are installed:\n\u003e `pip install -r requirements.txt`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbouget%2Fmri_brain_tumor_segmentation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdbouget%2Fmri_brain_tumor_segmentation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbouget%2Fmri_brain_tumor_segmentation/lists"}