Editing
Medical Image Segmentation
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== <span style="color: #FFFFFF;">Applying</span> == '''Medical image segmentation with nnU-Net:''' <syntaxhighlight lang="python"> # nnU-Net: self-configuring framework for medical segmentation # pip install nnunetv2 # Step 1: Prepare dataset in nnU-Net format # Dataset must be organized as: # nnUNet_raw/Dataset001_Liver/ # imagesTr/ -- training images (NIfTI format: .nii.gz) # labelsTr/ -- training segmentation masks # imagesTs/ -- test images # dataset.json -- metadata file import json dataset_info = { "name": "LiverTumor", "description": "Liver and tumor segmentation from CT scans", "reference": "Medical Segmentation Decathlon", "licence": "CC-BY-SA 4.0", "channel_names": {"0": "CT"}, "labels": {"background": 0, "liver": 1, "tumor": 2}, "numTraining": 131, "file_ending": ".nii.gz" } # Step 2: Plan and preprocess # nnUNetv2_plan_and_preprocess -d 001 --verify_dataset_integrity # Step 3: Train (nnU-Net auto-selects architecture: 2D, 3D full res, 3D low res, cascade) # nnUNetv2_train 001 3d_fullres 0 --npz (fold 0 of 5-fold CV) # Step 4: Predict on new data # nnUNetv2_predict -i /path/to/imagesTs -o /path/to/output \ # -d 001 -c 3d_fullres --save_probabilities # Custom PyTorch U-Net for teaching purposes import torch import torch.nn as nn class DoubleConv(nn.Module): def __init__(self, in_ch, out_ch): super().__init__() self.conv = nn.Sequential( nn.Conv3d(in_ch, out_ch, 3, padding=1), nn.BatchNorm3d(out_ch), nn.ReLU(inplace=True), nn.Conv3d(out_ch, out_ch, 3, padding=1), nn.BatchNorm3d(out_ch), nn.ReLU(inplace=True) ) def forward(self, x): return self.conv(x) class UNet3D(nn.Module): def __init__(self, in_ch=1, out_ch=3, features=[32, 64, 128, 256]): super().__init__() self.encoders = nn.ModuleList([DoubleConv(in_ch if i==0 else features[i-1], features[i]) for i in range(len(features))]) self.pool = nn.MaxPool3d(2) self.decoders = nn.ModuleList([nn.ConvTranspose3d(features[i], features[i-1], 2, stride=2) for i in range(len(features)-1, 0, -1)]) self.dec_convs = nn.ModuleList([DoubleConv(features[i], features[i-1]) for i in range(len(features)-1, 0, -1)]) self.head = nn.Conv3d(features[0], out_ch, 1) def forward(self, x): skips = [] for enc in self.encoders[:-1]: x = enc(x); skips.append(x); x = self.pool(x) x = self.encoders[-1](x) for up, conv, skip in zip(self.decoders, self.dec_convs, reversed(skips)): x = up(x) x = torch.cat([x, skip], dim=1) x = conv(x) return self.head(x) </syntaxhighlight> ; Medical segmentation tools : '''Self-configuring''' β nnU-Net v2 (start here for any new task) : '''Interactive/prompted''' β MedSAM, SAM-Med2D, SAM-Med3D : '''Universal anatomy''' β TotalSegmentator (117 CT structures), MONAI Label : '''Pathology (WSI)''' β CLAM, HoverNet (nucleus segmentation), CONCH : '''Research framework''' β MONAI (Medical Open Network for AI) β PyTorch-based </div> <div style="background-color: #8B4500; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;">
Summary:
Please note that all contributions to BloomWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
BloomWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information