Skip to content

Add multi-MRI preprocessing with rigid registration and averaging#109

Draft
Copilot wants to merge 8 commits intomainfrom
copilot/add-mri-image-processing-rules
Draft

Add multi-MRI preprocessing with rigid registration and averaging#109
Copilot wants to merge 8 commits intomainfrom
copilot/add-mri-image-processing-rules

Conversation

Copy link
Contributor

Copilot AI commented Feb 17, 2026

Previously raised error on multiple MRI images per subject. Now handles them via rigid registration and averaging with optional super-resolution.

Workflow

Multi-MRI path:

  1. n4_mri_individual - N4 correction per image → desc-N4_mriidx-{N}
  2. register_mri_to_first - Greedy 6-DOF rigid to first image → transforms
  3. average_mri - Apply transforms with optional upsampling, average → desc-preproc
  4. n4_mri - Copy to desc-N4 for downstream compatibility

Single-MRI path unchanged: direct N4 application.

Key Changes

New rules:

  • n4_mri_individual - Per-image N4 (multi-MRI only)
  • register_mri_to_first - Rigid registration using greedy
  • average_mri - Transform + average with upsampling support

New scripts:

  • average_registered_mri.py - Applies transformations with optional upsampling, averages images
  • copy_or_n4.py - Routes single vs multi-MRI cases for final output

Configuration:

  • --mri_upsample_factor - Super-resolution factor (default: 1.0)

Example

spimquant /path/to/bids /output participant \
  --register_to_mri \
  --mri_upsample_factor 2.0

Processes 3 MRI acquisitions → N4 each → rigid align → 2× upsample during transform → average for super-resolved output.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • pixi.sh
    • Triggering command: /usr/bin/curl curl -fsSL REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

add a new set of rules to the preproc_mri sml file to deal with multiple matched MRI images (right now an error is raised), including a rule to rigidly register each MRI image to the first one, and then a rule to average all of those images. use greedy for the rigid reg. add an option to upsample the images before averaging (upsample and apply xfm in same step) for effectively superresolvrd images. perform n4 before averaging. call the reconstructed image desc-preproc.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 6 commits February 17, 2026 20:11
Co-authored-by: akhanf <11492701+akhanf@users.noreply.github.com>
Co-authored-by: akhanf <11492701+akhanf@users.noreply.github.com>
Co-authored-by: akhanf <11492701+akhanf@users.noreply.github.com>
Co-authored-by: akhanf <11492701+akhanf@users.noreply.github.com>
Co-authored-by: akhanf <11492701+akhanf@users.noreply.github.com>
Copilot AI changed the title [WIP] Add rules for processing multiple matched MRI images Add multi-MRI preprocessing with rigid registration and averaging Feb 17, 2026
Copilot AI requested a review from akhanf February 17, 2026 20:21
mrindex still used for transforms
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.

2 participants

Comments