Skip to content

Implementation of antsRegistration_affine_SyN.sh for registration#282

Draft
gdevenyi wants to merge 6 commits into
nf-neuro:mainfrom
gdevenyi:antsRegistration_affine_SyN
Draft

Implementation of antsRegistration_affine_SyN.sh for registration#282
gdevenyi wants to merge 6 commits into
nf-neuro:mainfrom
gdevenyi:antsRegistration_affine_SyN

Conversation

@gdevenyi

@gdevenyi gdevenyi commented Jan 8, 2026

Copy link
Copy Markdown
Contributor

Describe your changes

Implement the CoBrALab variant of antsRegistrationSyN.sh with optimized pyramids.

List test packages used by your module

Checklist before requesting a review

  • Create the tool:
    • Edit ./modules/nf-neuro/<category>/<tool>/main.nf
    • Edit ./modules/nf-neuro/<category>/<tool>/meta.yml
    • Edit ./modules/nf-neuro/<category>/<tool>/environment.yml
  • Generate the tests:
    • Edit ./modules/nf-neuro/<category>/<tool>/tests/main.nf.test
    • Run the tests to generate the main.nf.test.snap snapshots
  • Ensure the syntax is correct :
    • Run prettier and editorconfig-checker to fix common syntax issues
    • Run nf-core modules lint and fix all errors
    • Ensure your variables have good, clear names

@gdevenyi
gdevenyi force-pushed the antsRegistration_affine_SyN branch from 390c9c1 to a90da89 Compare January 8, 2026 16:19
@AlexVCaron

Copy link
Copy Markdown
Contributor

Minimal work is required so the module fits with the nf-core framework. Modules names can only be composed of capital alphanumerical characters and must follow the category/module filenaming convention. So here, it would be (with category) REGISTRATION/COBRALABANTS, using the current file hierarchy.

Once done, most linting and testing should work out the box. But nf-test expects some naming/formatting, that sadly isn't targetted when nf-core conventions are not abided to.

@gdevenyi
gdevenyi force-pushed the antsRegistration_affine_SyN branch 2 times, most recently from 2878c25 to ae312c2 Compare January 15, 2026 18:45
@gdevenyi

Copy link
Copy Markdown
Contributor Author

@AlexVCaron I can't sort out how to run the test properly inside the devcontainer, what's the appropriate command?

@gdevenyi
gdevenyi force-pushed the antsRegistration_affine_SyN branch from ae312c2 to b91bb4a Compare January 22, 2026 15:52
@AlexVCaron

AlexVCaron commented Jan 22, 2026

Copy link
Copy Markdown
Contributor

I run the test suite for any component from the root of the repo via : nf-test test <path-to-component-base-directory> --update-snapshot --clean-snapshot

In this case, the path is modules/nf-neuro/registration/cobralab_ants

For the lint, it is done via the nf-core command, from the root of the repo again, but without the full path, just the component name : nf-core modules lint registration/cobralab_ants

Tell me of any problems, I can pull your PR and help debug !

@gdevenyi

Copy link
Copy Markdown
Contributor Author

Right. OK. It seems like the devcontainer doesn't have the antsRegistration_affine_SyN.sh that I got merged into the main repo...

@AlexVCaron

Copy link
Copy Markdown
Contributor

I'll get into that this w-e. It should've been included in the build, I'll investigate

@AlexVCaron

Copy link
Copy Markdown
Contributor

As stated on scilus/containers-scilus#42, scilus/scilus:dev is the container including the dependency for now.

@gdevenyi
gdevenyi force-pushed the antsRegistration_affine_SyN branch 2 times, most recently from 0932c5d to a7e2ecb Compare February 5, 2026 04:43
@gdevenyi
gdevenyi force-pushed the antsRegistration_affine_SyN branch 2 times, most recently from 4db49ca to b09a2af Compare May 29, 2026 19:26
@arnaudbore

Copy link
Copy Markdown
Contributor

@gdevenyi container is updated, we still have some issues with our servers I'll let you know asap when ready.

@gdevenyi

gdevenyi commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

@gdevenyi container is updated, we still have some issues with our servers I'll let you know asap when ready.

No problem my local testbed works.

@gdevenyi
gdevenyi force-pushed the antsRegistration_affine_SyN branch from b09a2af to e9318a2 Compare June 2, 2026 16:04
@gdevenyi
gdevenyi force-pushed the antsRegistration_affine_SyN branch from e9318a2 to 191152d Compare June 4, 2026 15:23
Split single mask input into separate fixed_mask and moving_mask inputs,
matching the pattern from PR nf-neuro#367 for the ants registration module.
antsRegistration_affine_SyN.sh supports --fixed-mask and --moving-mask
as independent flags.
@gdevenyi

gdevenyi commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

Depends on scilus/containers-scilus#45, also need to update the container reference once its released

@arnaudbore

Copy link
Copy Markdown
Contributor

Depends on scilus/containers-scilus#45, also need to update the container reference once its released

Merged and scilus/scilus:dev is updated

@gdevenyi

gdevenyi commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

This all works, I guess the only thing now is this should be pinned to an official scilus container version instead of dev

@gagnonanthony

Copy link
Copy Markdown
Member

I'm not sure there will be a release with a new version soon, right @arnaudbore ? In the meantime, you could pin it to the image SHA.

@gdevenyi

gdevenyi commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

In the meantime, you could pin it to the image SHA.

Sure.

…hread support

- Forward --reproducibility and --random-seed CLI flags to
  antsRegistration_affine_SyN.sh (CoBrALab PR nf-neuro#7)
- Export ANTS_RANDOM_SEED env var (default 1234) for ancillary ANTs tools
- Replace hardcoded thread counts with task.ext.single_thread-aware
  expressions for ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS and OMP_NUM_THREADS
- Remove OPENBLAS_NUM_THREADS (set globally in test config)
- Add reproducibility, ants_rng_seed, single_thread args to meta.yml

Mirrors the pattern already applied to registration/ants (nf-neuro PR nf-neuro#342).
@gdevenyi
gdevenyi force-pushed the antsRegistration_affine_SyN branch 2 times, most recently from 3ec0077 to cb0a599 Compare June 11, 2026 17:03
@gdevenyi
gdevenyi marked this pull request as ready for review June 11, 2026 17:04
@gdevenyi
gdevenyi requested a review from a team June 11, 2026 17:04
Copilot AI review requested due to automatic review settings June 11, 2026 17:04
@gdevenyi

Copy link
Copy Markdown
Contributor Author

The masking implementation here depends on #369, if that's changed this should be as well

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

Note

Copilot was unable to run its full agentic suite in this review.

Adds a new registration/cobralab_ants Nextflow module to nf-neuro, including module metadata and an nf-test suite covering default, “quick”, “no warp”, and stub modes.

Changes:

  • Introduces the REGISTRATION_COBRALABANTS process implementation and module metadata.
  • Adds nf-test coverage and snapshots for multiple registration configurations.
  • Adds test tagging and per-test Nextflow config overrides.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
modules/nf-neuro/registration/cobralab_ants/main.nf Adds the REGISTRATION_COBRALABANTS process implementation, including optional QC generation and stub behavior.
modules/nf-neuro/registration/cobralab_ants/meta.yml Documents module inputs/outputs/tools and parameters used by the process.
modules/nf-neuro/registration/cobralab_ants/environment.yml Adds module conda environment placeholder for linting/metadata consistency.
modules/nf-neuro/registration/cobralab_ants/tests/main.nf.test Adds nf-test cases for default, quick, no-warp, and stub runs.
modules/nf-neuro/registration/cobralab_ants/tests/main.nf.test.snap Adds snapshots asserting expected emitted outputs/hashes for each test.
modules/nf-neuro/registration/cobralab_ants/tests/nextflow.config Test config enabling reproducibility + single-thread mode.
modules/nf-neuro/registration/cobralab_ants/tests/nextflow_quick.config Test config enabling fast mode + QC + single-thread mode.
modules/nf-neuro/registration/cobralab_ants/tests/nextflow_no_warp.config Test config enabling fast + linear-only (no nonlinear warp) + single-thread mode.
modules/nf-neuro/registration/cobralab_ants/tests/tags.yml Adds tags mapping to allow selective test execution by module path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +107 to +114
for image in fixed_image warped; do
mrconvert *\${image}.nii.gz *\${image}_viz.nii.gz -stride -1,2,3
scil_viz_volume_screenshot *\${image}_viz.nii.gz \${image}_coronal.png \
--slices \$coronal_dim --axis coronal \$viz_params
scil_viz_volume_screenshot *\${image}_viz.nii.gz \${image}_sagittal.png \
--slices \$sagittal_dim --axis sagittal \$viz_params
scil_viz_volume_screenshot *\${image}_viz.nii.gz \${image}_axial.png \
--slices \$axial_dim --axis axial \$viz_params

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 587282e — the QC viz calls now use a concrete output filename instead of a glob on both input and output positions.

Comment on lines +8 to +9
input:
tuple val(meta), path(fixed_image), path(moving_image), path(fixed_mask), path(moving_mask) //** optional, input = [] **//

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Invalid for this codebase — the //** optional, input = [] **// convention is how nf-neuro modules pass optional tuple file inputs (the test harness emits [], []). The declaration is identical to the canonical registration/ants module, which CI validates; meta.yml's mandatory: false remains the source of truth.

Comment on lines +74 to +75
moving_id=\$(basename $moving_image .nii.gz)
moving_id=\${moving_id#${meta.id}_*}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 587282e — the .nii.gz assumption was resolved by adopting the extension-agnostic basename parsing from the registration/ants reference module, so both .nii and .nii.gz inputs are handled.


### ** QC ** ###
if $run_qc; then
mv $fixed_image fixed_image.nii.gz

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 587282e (see reply above) — extension-agnostic basename parsing now handles both .nii and .nii.gz.

Comment on lines +101 to +102
fixed_id=\$(basename $fixed_image .nii.gz)
fixed_id=\${fixed_id#${meta.id}_*}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 587282e (see reply above) — extension-agnostic basename parsing now handles both .nii and .nii.gz.

Comment on lines +1 to +5
process {
withName: "REGISTRATION_COBRALABANTS" {
publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }
ext.reproducibility = true
ext.single_thread = true

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Invalid — this publishDir expression is the established convention across every registration module test config in the repo (ants, anattodwi, convert, easyreg, synthmorph). Each config is scoped to a single process via withName, so there is no collision in practice.

Comment on lines +305 to +308
type: list
description: |
Tuple, Transformation files to warp images in fixed space, in the correct order
for REGISTRATION_TRANSFORMTRACTOGRAM : [ meta, [ forward_warp, forward_affine ] ].

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Invalid here — this wording is word-for-word identical to the canonical registration/ants module's forward_image_transform/backward_image_transform descriptions. A cobralab-only edit would diverge from the reference; this should be a separate repo-wide fix across ants/anattodwi/cobralab_ants.

Comment on lines +319 to +321
description: |
Tuple, transformation files to warp images in moving space, in the correct order
for REGISTRATION_TRANSFORMTRACTOGRAM : [ meta, [ backward_affine, backward_warp ] ].

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Invalid here — wording is identical to the canonical registration/ants module; should be a separate repo-wide fix rather than a cobralab-only change.

@gdevenyi gdevenyi changed the title Initial implementation of antsRegistration_affine_SyN.sh Implementation of antsRegistration_affine_SyN.sh for registration Jun 11, 2026
@arnaudbore

Copy link
Copy Markdown
Contributor

@gdevenyi scilus/scilus:2.3.0 is ready 👍

@gdevenyi

Copy link
Copy Markdown
Contributor Author

Cool. Still pending confirmation of the masking implementation in #369

@gdevenyi
gdevenyi force-pushed the antsRegistration_affine_SyN branch from cb0a599 to 235e030 Compare June 25, 2026 15:24
@gdevenyi
gdevenyi marked this pull request as draft June 25, 2026 15:24
Align cobralab_ants with the registration subworkflow masking rework
(PR nf-neuro#369): gate fixed/moving mask forwarding behind masking_strategy
(none/apriori/internal/both), add fixed_warped output (reference warped
to moving space via antsApplyTransforms), and update tests accordingly.

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

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Comment on lines +77 to +78
moving_id=\$(basename $moving_image .nii.gz)
moving_id=\${moving_id#${meta.id}_*}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 587282e — ID parsing is now extension-agnostic (handles both .nii and .nii.gz) and strips by ${prefix} instead of ${meta.id}, matching the registration/ants reference module.

Comment on lines +115 to +116
fixed_id=\$(basename $fixed_image .nii.gz)
fixed_id=\${fixed_id#${meta.id}_*}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 587282efixed_id is now parsed extension-agnostically and stripped by ${prefix}, consistent with the moving_id parsing and the registration/ants reference module.

Comment on lines +122 to +128
mrconvert *\${image}.nii.gz *\${image}_viz.nii.gz -stride -1,2,3
scil_viz_volume_screenshot *\${image}_viz.nii.gz \${image}_coronal.png \
--slices \$coronal_dim --axis coronal \$viz_params
scil_viz_volume_screenshot *\${image}_viz.nii.gz \${image}_sagittal.png \
--slices \$sagittal_dim --axis sagittal \$viz_params
scil_viz_volume_screenshot *\${image}_viz.nii.gz \${image}_axial.png \
--slices \$axial_dim --axis axial \$viz_params

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 587282e — the QC mrconvert/scil_viz_volume_screenshot calls now use a concrete output filename (${image}_viz.nii.gz) instead of a glob, matching the registration/ants reference module.

…ames

Address Copilot review: parse moving/fixed IDs extension-agnostically
(.nii and .nii.gz) and strip by ${prefix} instead of ${meta.id}; use a
concrete viz output filename instead of a glob. Matches the registration/ants
reference module.
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.

5 participants