Skip to content

Paul + Synthseg - #42

Merged
Hendrik-code merged 11 commits into
mainfrom
dev_synthseg
Aug 3, 2026
Merged

Paul + Synthseg#42
Hendrik-code merged 11 commits into
mainfrom
dev_synthseg

Conversation

@Hendrik-code

@Hendrik-code Hendrik-code commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

this implements pauls method
plus synthseg as baseline.

@Hendrik-code Hendrik-code changed the title Dev synthseg Paul + Synthseg Jun 8, 2026
Luugaaa and others added 6 commits June 9, 2026 17:09
…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>
@Hendrik-code
Hendrik-code marked this pull request as ready for review August 3, 2026 07:34
Copilot AI review requested due to automatic review settings August 3, 2026 07:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.synthseg package 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

  • @staticmethod at module scope turns _minmax_denorm into a staticmethod object, making it non-callable as a regular function.
@staticmethod

auglab/transforms/gpu/fromSeg.py:497

  • @staticmethod at module scope turns _zscore_renorm into a staticmethod object, 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
Comment thread README.md Outdated
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>
@Hendrik-code
Hendrik-code merged commit 4cc600a into main Aug 3, 2026
@Hendrik-code
Hendrik-code deleted the dev_synthseg branch August 5, 2026 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants