Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ci/bundle_custom_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"cxr_image_synthesis_latent_diffusion_model",
"brain_image_synthesis_latent_diffusion_model",
"retinalOCT_RPD_segmentation",
"mindmap",
]

# This list is used for our CI tests to determine whether a bundle needs to be tested after downloading
Expand Down
47 changes: 47 additions & 0 deletions models/mindmap/LICENSE
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.
102 changes: 102 additions & 0 deletions models/mindmap/configs/inference.json
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()"
]
}
95 changes: 95 additions & 0 deletions models/mindmap/configs/metadata.json
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
],
Comment thread
coderabbitai[bot] marked this conversation as resolved.
"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"
}
}
}
}
}
Loading
Loading