-
Notifications
You must be signed in to change notification settings - Fork 106
Add mindmap brain segmentation bundle #789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
usmann56
wants to merge
3
commits into
Project-MONAI:dev
Choose a base branch
from
usmann56:788-add-mindmap-bundle
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2024-2026 Sergey Plis and the neuroneural / brainchop-models contributors | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. | ||
|
|
||
| BSD 2-Clause License | ||
|
|
||
| Copyright (c) 2020, Chris Rorden's Lab | ||
| All rights reserved. | ||
|
|
||
| Redistribution and use in source and binary forms, with or without | ||
| modification, are permitted provided that the following conditions are met: | ||
|
|
||
| 1. Redistributions of source code must retain the above copyright notice, this | ||
| list of conditions and the following disclaimer. | ||
|
|
||
| 2. Redistributions in binary form must reproduce the above copyright notice, | ||
| this list of conditions and the following disclaimer in the documentation | ||
| and/or other materials provided with the distribution. | ||
|
|
||
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
| FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
| OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| { | ||
| "imports": [ | ||
| "$import glob", | ||
| "$import numpy", | ||
| "$import os", | ||
| "$import scripts.checkpoint as checkpoint" | ||
| ], | ||
| "bundle_root": ".", | ||
| "image_key": "image", | ||
| "output_dir": "$@bundle_root + '/eval'", | ||
| "output_ext": ".nii.gz", | ||
| "output_dtype": "$numpy.uint8", | ||
| "output_postfix": "mindmap", | ||
| "separate_folder": true, | ||
| "load_pretrain": true, | ||
| "save_conform": false, | ||
| "dataset_dir": "/workspace/data/mindmap", | ||
| "datalist": "$list(sorted(glob.glob(@dataset_dir + '/*.nii') + glob.glob(@dataset_dir + '/*.nii.gz')))", | ||
| "device": "$torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')", | ||
| "network_def": { | ||
| "_target_": "scripts.network.MindMapNet" | ||
| }, | ||
| "network": "$@network_def.to(@device)", | ||
| "preprocessing": { | ||
| "_target_": "Compose", | ||
| "transforms": [ | ||
| { | ||
| "_target_": "LoadImaged", | ||
| "keys": "@image_key", | ||
| "ensure_channel_first": true, | ||
| "image_only": true | ||
| }, | ||
| { | ||
| "_target_": "scripts.transforms.MindMapPreprocessd", | ||
| "keys": "@image_key" | ||
| }, | ||
| { | ||
| "_target_": "EnsureTyped", | ||
| "keys": "@image_key", | ||
| "dtype": "$torch.float32" | ||
| } | ||
| ] | ||
| }, | ||
| "dataset": { | ||
| "_target_": "Dataset", | ||
| "data": "$[{'image': i} for i in @datalist]", | ||
| "transform": "@preprocessing" | ||
| }, | ||
| "dataloader": { | ||
| "_target_": "DataLoader", | ||
| "dataset": "@dataset", | ||
| "batch_size": 1, | ||
| "shuffle": false, | ||
| "num_workers": 0 | ||
| }, | ||
| "inferer": { | ||
| "_target_": "SimpleInferer" | ||
| }, | ||
| "postprocessing": { | ||
| "_target_": "Compose", | ||
| "transforms": [ | ||
| { | ||
| "_target_": "scripts.transforms.MindMapPostprocessd", | ||
| "keys": "pred", | ||
| "save_conform": "@save_conform" | ||
| }, | ||
| { | ||
| "_target_": "SaveImaged", | ||
| "keys": "pred", | ||
| "output_dir": "@output_dir", | ||
| "output_ext": "@output_ext", | ||
| "output_dtype": "@output_dtype", | ||
| "output_postfix": "@output_postfix", | ||
| "separate_folder": "@separate_folder" | ||
| } | ||
| ] | ||
| }, | ||
| "handlers": [ | ||
| { | ||
| "_target_": "StatsHandler", | ||
| "iteration_log": false | ||
| } | ||
| ], | ||
| "evaluator": { | ||
| "_target_": "SupervisedEvaluator", | ||
| "device": "@device", | ||
| "val_data_loader": "@dataloader", | ||
| "network": "@network", | ||
| "inferer": "@inferer", | ||
| "postprocessing": "@postprocessing", | ||
| "val_handlers": "@handlers", | ||
| "amp": false | ||
| }, | ||
| "checkpoint_sha256": "b87a1646ef21848f4df17c63e3f1ab1087e50d4e859d2e4ab0da9677d234f80e", | ||
| "initialize": [ | ||
| "$monai.utils.set_determinism(seed=123)", | ||
| "$checkpoint.load_meshnet_gn_checkpoint(@network, @bundle_root + '/models/model.pt', @checkpoint_sha256) if @load_pretrain else None" | ||
| ], | ||
| "run": [ | ||
| "$@evaluator.run()" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| { | ||
| "schema": "https://github.com/Project-MONAI/MONAI-extra-test-data/releases/download/0.8.1/meta_schema_20240725.json", | ||
| "version": "0.1.0", | ||
| "changelog": { | ||
| "0.1.0": "initialize the model package structure" | ||
| }, | ||
| "monai_version": "1.6.0", | ||
| "pytorch_version": "2.14.0", | ||
| "numpy_version": "2.4.0", | ||
| "required_packages_version": { | ||
| "nibabel": "5.4.2", | ||
| "scipy": "1.18.1", | ||
| "pytorch-ignite": "0.5.2", | ||
| "safetensors": "0.8.0" | ||
| }, | ||
| "supported_apps": {}, | ||
| "name": "MindMap Brain Segmentation", | ||
| "task": "18-class whole-brain segmentation (gray/white matter and subcortical structures) in any imaging modality", | ||
| "description": "A 24-channel, 13-layer dilated 3D CNN (MeshNet-style; this is model24chan18cls, which shares model16chan18cls's exact topology at 24 instead of 16 channels) that segments a 3D medical image into 18 FreeSurfer-style brain regions, ported from the mindmap model (published as model24chan18cls_gdice_prio in neuroneural/brainchop-test) so it runs as a standard MONAI bundle. The bundle reproduces the upstream reference implementation's full inference pipeline: intensity-clip and reslice the input onto a 256x256x256, 1mm, LIA-oriented conform grid, quantile-normalize it, run the network, keep only the single largest 26-connected foreground component (across all classes jointly), and reslice the label map back onto the input's native grid.", | ||
| "authors": "Sergey Plis and the neuroneural / brainchop-models team (original model16chan18cls/model24chan18cls training); ported to MONAI bundle format by the MONAI Model Zoo community", | ||
| "copyright": "Copyright (c) MONAI Consortium", | ||
| "data_source": "Trained on SynthSeg-style synthetic data (synth18 / label18); not otherwise documented by this port. See the upstream brainchop-models project for the original training details.", | ||
| "data_type": "nibabel", | ||
| "image_classes": "single channel data, any modality, any input size/orientation (internally resampled to a 256x256x256, 1mm conform grid)", | ||
| "label_classes": "18 FreeSurfer-style whole-brain classes: Unknown/background, Cerebral-White-Matter, Cerebral-Cortex, Lateral-Ventricle, Inferior-Lateral-Ventricle, Cerebellum-White-Matter, Cerebellum-Cortex, Thalamus, Caudate, Putamen, Pallidum, 3rd-Ventricle, 4th-Ventricle, Brain-Stem, Hippocampus, Amygdala, Accumbens-area, VentralDC", | ||
| "pred_classes": "18 channels, conform-space network logits (channel 0 is background/Unknown), before this bundle's postprocessing argmaxes, cleans up, and reslices them into a single-channel label map", | ||
| "eval_metrics": {}, | ||
| "intended_use": "This is an example, not to be used for diagnostic purposes", | ||
| "references": [ | ||
| "brainchop-models, the upstream training/checkpoint repository this bundle's weights are pulled from: https://github.com/neuroneural/brainchop-models/tree/f53f7b93d725416c2705a9e4f79765d1739badb9/meshnet/model24chan18cls", | ||
| "neuroneural/brainchop-test, which publishes this model's weights/config publicly as model24chan18cls_gdice_prio: https://github.com/neuroneural/brainchop-test/tree/webgpu/public/models/model24chan18cls_gdice_prio" | ||
| ], | ||
| "network_data_format": { | ||
| "inputs": { | ||
| "image": { | ||
| "type": "image", | ||
| "format": "any modality", | ||
| "modality": "any", | ||
| "num_channels": 1, | ||
| "spatial_shape": [ | ||
| 256, | ||
| 256, | ||
| 256 | ||
| ], | ||
| "dtype": "float32", | ||
| "value_range": [ | ||
| -1, | ||
| 2 | ||
| ], | ||
| "is_patch_data": false, | ||
| "channel_def": { | ||
| "0": "image" | ||
| } | ||
| } | ||
| }, | ||
| "outputs": { | ||
| "pred": { | ||
| "type": "image", | ||
| "format": "segmentation", | ||
| "num_channels": 18, | ||
| "spatial_shape": [ | ||
| 256, | ||
| 256, | ||
| 256 | ||
| ], | ||
| "dtype": "float32", | ||
| "value_range": [ | ||
| -100, | ||
| 100 | ||
| ], | ||
| "is_patch_data": false, | ||
| "channel_def": { | ||
| "0": "Unknown", | ||
| "1": "Cerebral-White-Matter", | ||
| "2": "Cerebral-Cortex", | ||
| "3": "Lateral-Ventricle", | ||
| "4": "Inferior-Lateral-Ventricle", | ||
| "5": "Cerebellum-White-Matter", | ||
| "6": "Cerebellum-Cortex", | ||
| "7": "Thalamus", | ||
| "8": "Caudate", | ||
| "9": "Putamen", | ||
| "10": "Pallidum", | ||
| "11": "3rd-Ventricle", | ||
| "12": "4th-Ventricle", | ||
| "13": "Brain-Stem", | ||
| "14": "Hippocampus", | ||
| "15": "Amygdala", | ||
| "16": "Accumbens-area", | ||
| "17": "VentralDC" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.