Paul + Synthseg - #42
Merged
Merged
Conversation
…thesis Integrates V26_6_2 synthesis into AugLab as a self-contained GPU transform. The pipeline runs 1-D K-means intensity parcellation with Voronoi spatial sub-parcellation (V26_6 step), then a per-anatomical-label affine remap on top (V26_6_2 step), followed by foreground z-score normalisation. All constants are configurable (c_choices, s_choices, blur_sigmas, skip_parcellation_prob, skip_sub_parc_prob, alpha_magnitude_range, label_remap_prob, etc.). Registered as ImageContrastV26_6_2GPUTransform in AugTransformsGPU. Includes default config mirroring the V19 baseline. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… miccai paper config for reproducibility
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds two new augmentation baselines to AugLab: (1) a Torch/GPU SynthSeg generator (full pipeline + intensity-only wrapper) and (2) Paul’s PALETTE-style synthesis integrated into the existing GPU augmentation builder, along with example JSON configs.
Changes:
- Introduces a new
auglab.transforms.synthsegpackage implementing the SynthSeg generator (functional.py,generator.py) plus AugLab-compatible wrappers (RandomSynthSegGPU,SynthSegTransformsGPU). - Extends the GPU augmentation builder to optionally append SynthSeg and PALETTE transforms from JSON config blocks, and updates GPU config files accordingly.
- Adds additional GPU augmentation utilities (random-order transform list builder) and updates README/badges/citation info.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Updates badges and adds a citation block. |
| auglab/transforms/synthseg/transforms.py | Adds AugLab-facing wrappers around the SynthSeg generator. |
| auglab/transforms/synthseg/README.md | Documents SynthSeg pipeline, defaults, and usage patterns in AugLab. |
| auglab/transforms/synthseg/generator.py | Implements the main SynthSegGenerator module orchestration. |
| auglab/transforms/synthseg/functional.py | Implements the functional building blocks for SynthSeg generation/deformation. |
| auglab/transforms/synthseg/init.py | Exposes the SynthSeg public API for imports. |
| auglab/transforms/gpu/transforms.py | Integrates SynthSeg + PALETTE into AugTransformsGPU config parsing and pipeline. |
| auglab/transforms/gpu/transforms_list.py | Adds alternative GPU augmentation builders with random ordering/selection. |
| auglab/transforms/gpu/fromSeg.py | Extends seg-driven GPU transforms and adds RandomPALETTEGPU implementation. |
| auglab/configs/transform_params_one-sequence-to-segment-them-all.json | Adds a new augmentation config preset for the paper method. |
| auglab/configs/transform_params_gpu.json | Updates default GPU config to include the new PALETTE transform block. |
| auglab/configs/transform_params_gpu_default01-23_ImageContrastV26_6_2GPUTransform.json | Adds a config preset focused on the V26_6_2 contrast/PALETTE transform. |
Suppressed comments (2)
auglab/transforms/gpu/fromSeg.py:492
@staticmethodat module scope turns_minmax_denorminto astaticmethodobject, making it non-callable as a regular function.
@staticmethod
auglab/transforms/gpu/fromSeg.py:497
@staticmethodat module scope turns_zscore_renorminto astaticmethodobject, which is likely unintended and will break regular function calls.
@staticmethod
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+75
to
+79
| seed_idx = torch.multinomial(c_fg_mask.float(), S, replacement=False) | ||
| centroids_v = coords.index_select(0, seed_idx) | ||
| d = torch.cdist(coords, centroids_v) | ||
| sub = torch.argmin(d, dim=1) | ||
| rid = torch.where(c_mask, offset + sub, rid) |
| from auglab.transforms.gpu.spatial import RandomAffine3DCustom, RandomLowResTransformGPU, RandomFlipTransformGPU, RandomAcqTransformGPU, RandomCropTransformGPU | ||
| from auglab.transforms.gpu.fromSeg import RandomRedistributeSegGPU | ||
| from auglab.transforms.gpu.fromSeg import RandomRedistributeSegGPU, RandomPALETTEGPU | ||
| from auglab.transforms.gpu.domain_transfer import RandomDomainTransferGPU |
Comment on lines
+464
to
468
| img_path = '/home/ge.polymtl.ca/p118739/data/datasets/data-multi-subject/sub-amu02/anat/sub-amu02_T1w.nii.gz' | ||
| img = Image(img_path).change_orientation('RSP') | ||
| img = resample_nib(img, new_size=[1,1,1], new_size_type='mm', interpolation='linear') | ||
| img_tensor = torch.from_numpy(img.data.copy()).to(torch.float32) | ||
|
|
Comment on lines
+256
to
+263
| image = torch.empty((B, C, *spatial), device=device, dtype=dtype) | ||
| for b in range(B): | ||
| idx_b = idx[b] | ||
| for ch in range(C): | ||
| mean_map = means[b, :, ch][idx_b] | ||
| std_map = stds[b, :, ch][idx_b] | ||
| image[b, ch] = mean_map + std_map * torch.randn(spatial, device=device, dtype=dtype) | ||
| return image |
| return seed | ||
|
|
||
|
|
||
| @staticmethod |
Comment on lines
+333
to
+343
| choose_x_params = self.transform_params.get("RandomChooseXTransforms") | ||
| transforms.append( | ||
| RandomChooseXTransformsGPU( | ||
| transforms_list=ta_transforms, num_transforms=len(ta_transforms), p=choose_x_params.get("ta_probability", 1.0), random_order=choose_x_params.get("ta_random_order", True), | ||
| ) | ||
| ) | ||
| transforms.append( | ||
| RandomChooseXTransformsGPU( | ||
| transforms_list=ge_transforms, num_transforms=len(ge_transforms), p=choose_x_params.get("ge_probability", 1.0), random_order=choose_x_params.get("ge_random_order", True) | ||
| ) | ||
| ) |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
this implements pauls method
plus synthseg as baseline.