{"id":15066233,"url":"https://github.com/nyumedml/darts","last_synced_at":"2025-08-23T22:32:07.956Z","repository":{"id":84280516,"uuid":"136255608","full_name":"NYUMedML/DARTS","owner":"NYUMedML","description":"Code for DARTS: DenseUnet-based Automatic Rapid Tool for brain Segmentation","archived":false,"fork":false,"pushed_at":"2023-11-01T23:22:20.000Z","size":39628,"stargazers_count":68,"open_issues_count":1,"forks_count":24,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-12-20T06:06:21.817Z","etag":null,"topics":["artificial-intelligence","brain-mri","brain-segmentation","deep-learning","freesurfer","medical-imaging","pytorch","unet"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NYUMedML.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-06T01:38:36.000Z","updated_at":"2024-07-21T18:18:29.000Z","dependencies_parsed_at":"2024-10-13T02:01:41.874Z","dependency_job_id":"8e330b6f-2a2d-41d0-b8d3-9d8bc399f28d","html_url":"https://github.com/NYUMedML/DARTS","commit_stats":{"total_commits":123,"total_committers":11,"mean_commits":"11.181818181818182","dds":0.6585365853658536,"last_synced_commit":"7b66a3c6d5174b298f5fc406dbee4c9e658ea895"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NYUMedML%2FDARTS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NYUMedML%2FDARTS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NYUMedML%2FDARTS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NYUMedML%2FDARTS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NYUMedML","download_url":"https://codeload.github.com/NYUMedML/DARTS/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230542288,"owners_count":18242332,"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":["artificial-intelligence","brain-mri","brain-segmentation","deep-learning","freesurfer","medical-imaging","pytorch","unet"],"created_at":"2024-09-25T01:04:01.560Z","updated_at":"2024-12-20T06:06:33.525Z","avatar_url":"https://github.com/NYUMedML.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DenseUnet-based Automatic Rapid brain Segmentation (DARTS)\n\n## Paper associated with the project\n[Here](https://arxiv.org/abs/1911.05567) is the paper describing the project and experiments in detail.\n\n## Package\n* The DARTS package can be installed using:\n```\npip install DARTSeg\n```\n\n## Pre-trained model wts\n* Download the pretrained models from [here](https://drive.google.com/file/d/1OJ0RmcALNkiU49Npm7Rez6thIKOf3gLQ/view?usp=sharing) as follows:\n\n```\ngdown https://drive.google.com/uc?id=1OJ0RmcALNkiU49Npm7Rez6thIKOf3gLQ -O saved_model_wts.zip\nunzip saved_model_wts.zip\n```\nThere are two model architectures: Dense U-Net and U-Net. Each model is trained using 2D slices extracted coronally, sagittally,or axially. The name of the model will contain the orientation and model architecture information.\n\n## Using pre-trained models to perform complete brain segmentation\n\nFollow these steps to perform segmentation:\n\n```\nfrom DARTS import Segmentation\nseg_obj = Segmentation(model_wts_path='./saved_model_wts/dense_unet_saggital_finetuned.pth', model_type=\"dense-unet\")\nseg_out, seg_proba_out = seg_obj.predict(inputs=\"T1.mgz\")\n```\n\n* The user may also execute the perform_pred.py script with the following code block to perform segmentation:\n\n```\nusage: perform_pred.py [-h] [--input_image_path INPUT_IMAGE_PATH]\n                       [--segmentation_dir_path SEGMENTATION_DIR_PATH]\n                       [--file_name FILE_NAME] [--model_type MODEL_TYPE]\n                       [--model_wts_path MODEL_WTS_PATH] [--is_mgz]\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --input_image_path INPUT_IMAGE_PATH\n                        Path to input image (can be of .mgz or .nii.gz\n                        format)(required)\n  --segmentation_dir_path SEGMENTATION_DIR_PATH\n                        Directory path to save the output segmentation\n                        (required)\n  --file_name FILE_NAME\n                        Name of the segmentation file (required)\n  --model_type MODEL_TYPE\n                        Model types: \"dense-unet\", \"unet\" (default: \"dense-\n                        unet\")\n  --model_wts_path MODEL_WTS_PATH\n                        Path for model wts to be used, provide a model from\n                        saved_model_wts/\n  --is_mgz              Use this flag when image is in .mgz format\n\n```\nAn example could look something like this:\n\n```\nperform_pred.py --input_image_path './../../../data_orig/199251/mri/T1.mgz' \\\n--segmentation_dir_path './sample_pred/' \\\n--file_name '199251' \\\n--is_mgz \\\n--model_wts_path './saved_model_wts/dense_unet_back2front_non_finetuned.pth' \\\n```\n\nAn illustration can be seen in [`predicting_segmentation_illustration.ipynb`](https://github.com/NYUMedML/DARTS/blob/master/predicting_segmentation_illustration.ipynb).\n\n## Deep learning models for brain MR segmentation\nWe pretrain our Dense Unet model using the Freesurfer segmentations of 1113 subjects available in the [Human Connectome Project](https://www.humanconnectome.org/study/hcp-young-adult/document/1200-subjects-data-release) dataset and fine-tuned the model using 101 manually labeled brain scans from [Mindboggle](https://mindboggle.info/data.html) dataset.\n\nThe model is able to perform the segmentation of complete brain **within a minute** (on a machine with single GPU). The model labels 102 regions in the brain making it the first model to segment more than 100 brain regions within a minute. The details of 102 regions can be found below.\n\n## Quantitative results on the Mindboggle held out data\nThe box plot compares the dice scores of different ROIs for Dense U-Net and U-Net. The Dense U-Net consistently outperforms U-Net and achieves good dice scores for most of the ROIs.\n\n\u003cimg src=\"plots/compare_dice_plot_aparc_manual_fd_part_1_dn_v_unet.png\" width=\"800\" /\u003e\n\u003cimg src=\"plots/compare_dice_plot_aparc_manual_fd_part_2_dn_v_unet.png\" width=\"800\" /\u003e\n\n## Qualitative results on the HCP held out data\nWe perform an expert reader evaluation to measure and compare the proposed deep learning models' performance with Freesurfer model. We use HCP held-out test set scans for reader study. On these scans, Freesurfer results have undergone a manual quality control. We also compare the non-finetuned and fine-tuned model with Freesurfer model with manual QC. Seven regions of interest (ROIs) were selected:L/R Putamen (axial view), L/R Pallidum (axial view), L/R Caudate (axial view), L/R Thalamus (axial view), L/R Lateral Ventricles (axial view), L/R Insula (axial view) and L/R Cingulate Gyrus (sagittal view).The readers rated each example on a Likert-type scale from 1 (Poor) to 5 (Excellent).\n\nBased on the readers' ratings, we investigate if there are statistically significant differences between the three methods using paired T-test and Wilcoxon signed rank test at 95\\% significance level. The results can be seen below.\n\u003cimg src=\"plots/reader_study_results.png\" width=\"650\" /\u003e\n\n## Output segmentation\nThe output segmentation has 103 labeled segments with the last one being the **None** class. The labels of the segmentation closely resembles the aseg+aparc segmentation protocol of Freesurfer.\n\nWe exclude 4 brain regions that are not common to a normal brain: White matter and non-white matter hypointentisites, left and right frontal and temporal poles. We also excluded left and right 'unknown' segments. We also exclude left and right bankssts as there is no common definition for these segments that is widely accepted by the neuroradiology community.\n\n\nThe complete list of class number and the corresponding segment name can be found [here](https://github.com/NYUMedML/BrainSeg/blob/master/name_class_mapping.p) as a pickled object or [here](https://github.com/NYUMedML/BrainSeg/blob/master/FreeSurferColorLUT_modified.txt) as a .txt file.\n\n## Sample Predictions\n### Insula\nHere we can clearly see that Freesurfer (FS) incorrectly predicts the right insula segment, the model trained only using FS segmentations also learns a wrong prediction. Our proposed model which is finetuned on manually annotated dataset correctly captures the region. Moreover, the segment looks biologically natural unlike FS's segmentation which is grainy, noisy and with non-smooth boundaries.\n\u003cimg src=\"plots/rt_insula_aparc_with_man_3.png\" width=\"800\" /\u003e\n\n### Putamen\nHere again, we see that FS segmentation is of low quality but our proposed fine-tuned model performs well and produces more natural looking segmentation.\n\u003cimg src=\"plots/Faulty_seg_Putamen.png\" width=\"800\" /\u003e\n\n### Pallidum\nFS segmentation for pallidum also of low quality, but the proposed model performs well.\n\u003cimg src=\"plots/Faulty_seg_Pallidum.png\" width=\"800\" /\u003e\n\n### More Predictions\nSome sample predictions for [Putamen](https://github.com/NYUMedML/BrainSeg/blob/master/plots/Left-Putamen_627549_143_0_1_2.pdf), [Caudate](https://github.com/NYUMedML/BrainSeg/blob/master/plots/Right-Caudate_194443_137_0_1_2.pdf), [Hippocampus](https://github.com/NYUMedML/BrainSeg/blob/master/plots/Right-Hippocampus_894774_108_0_1_2.pdf) and [Insula](https://github.com/NYUMedML/BrainSeg/blob/master/plots/ctx-lh-insula_147030_138_0_1_2.pdf) can be seen here. In all the images, prediction 1 = Freesurfer, Prediction 2 = Non-Finetuned Dense Unet, Prediction 3 = Finetuned Dense Unet.\n\nWe demonstrate that that Freesurfer often makes errors in determining the accurate boundaries whereas the deep learning-based models have natural looking ROIs with accurate boundaries.\n\n## Contact\nIf you have any questions regarding the code, please contact ark576[at]nyu.edu or raise an issue on the github repo.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnyumedml%2Fdarts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnyumedml%2Fdarts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnyumedml%2Fdarts/lists"}