Skip to content

Multi-label RAP switch#1

Open
rafdhaene wants to merge 10 commits intoarnaudbore:new_rapfrom
rafdhaene:rafael_adaptive_rap
Open

Multi-label RAP switch#1
rafdhaene wants to merge 10 commits intoarnaudbore:new_rapfrom
rafdhaene:rafael_adaptive_rap

Conversation

@rafdhaene
Copy link

@rafdhaene rafdhaene commented Feb 12, 2026

Quick description

This PR adds multi-label Region-Adaptive Propagation (RAP) “switch” policies and integrates them into scil_tracking_local_dev.py, allowing tracking parameters to change based on an integer label map.

Main changes
• Multi label RAP policies (JSON) (per label: algo, theta in degrees, step_size), while keeping backward compatibility with the legacy single-policy format.
• Dynamic parameter switching during tracking: when entering a RAP label region (switch between det/prob, update theta, update step_size).
• CLI integration (--rap_mask, --rap_method switch, --rap_params (JSON policy file)

The goal here is to allow the tracking behavior to be changed conditionally on external information (here: a labeled RAP mask)

Type of change

Check the relevant options.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Provide data, screenshots, command line to test (if relevant)

Data: we use the FiberCup dataset (Tractometer).
RAP mask: integer label map (0...N).

Example JSON:
{
"1": {"algo": "det", "theta": 35, "step_size": 0.5},
"2": {"algo": "prob", "theta": 35, "step_size": 0.5},
"3": {"algo": "prob", "theta": 10, "step_size": 0.25}
}

Command line (local dev)
python -m scilpy.cli.scil_tracking_local_dev
<fodf.nii.gz> <seed_mask.nii.gz> <tracking_mask.nii.gz> out_rap_switch.trk
--algo prob --theta 35 --step 0.5 --min_length 10 --max_length 200
--rap_mask <rap_label_mask.nii.gz>
--rap_method switch
--rap_params <rap_policies.json>
-v INFO -f

image

Notes:
In some cases streamlines can exit voxel bounds, saving may require disabling bbox validation or filtering invalid streamlines prior to writing.
Do not pay attention to the modification of scil_local_tracking_rafael, was changed for tests at beginning

Next step: Implementation of stopping propagation when the next point is outside valid voxel bounds to reduce invalid streamlines

Checklist

  • My code follows the style guidelines of this project (run autopep8)
  • I added relevant citations to scripts, modules and functions docstrings and descriptions
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I moved all functions from the script file (except the argparser and main) to scilpy modules
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

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.

1 participant

Comments