Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds a full nnUNet training and inference pipeline accessible via the copick-torch CLI. The workflow covers three stages — dataset preparation, model training, and inference — each exposed as a
CLI subcommand and registered as a copick entry point.
What's new
copick_torch/nnunet/ module
copick.convert.commands): Converts a CoPick project into nnUNet raw dataset format. Reads tomograms and multilabel segmentations, writes them as .nii.gz NIfTI files in the imagesTr /labelsTr / imagesTs directory structure, and emits a dataset.json. Voxel spacing is converted from Ångströms to nanometres for nnUNet's patch-size planner. Conversion is multi-threaded.
copick.training.commands): Runs nnUNetv2_plan_and_preprocess followed by nnUNetv2_train. Supports the standard nnUNet trainer, the Residual Encoder Large variant (resnecl), and all tenMedNeXt variants (S/B/M/L × kernel-3/kernel-5). Multi-GPU DDP is supported via --num-gpus; the plans batch size is scaled automatically so per-GPU memory stays constant. Resumes from an existing
checkpoint if one is found.
copick.inference.commands): Wraps nnUNet inference as nnUNetPredictor. Single-volume inference runs on cuda:0; batch inference shards runs round-robin across all available GPUs usingmp.spawn. Supports fold ensembling (pass multiple -w checkpoint paths). Writes predictions back to the CoPick overlay as multilabel segmentations and saves a YAML parameter log.
both work without patching nnUNet.
pyproject.toml
Usage sketch
1. Prepare dataset
2. Train (standard nnUNet, fold 0)
3. Segment