Skip to content

[ENH] more specific ROI transforming, add babyseg, update babyAFQ - #210

Open
36000 wants to merge 5 commits into
tractometry:mainfrom
36000:add_babyseg
Open

[ENH] more specific ROI transforming, add babyseg, update babyAFQ#210
36000 wants to merge 5 commits into
tractometry:mainfrom
36000:add_babyseg

Conversation

@36000

@36000 36000 commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Here we change:

  1. ROI transformation has now been changed. ROIs are converted to signed distance fields, transformed, and then the threshold to binarize them is set to the minimum threshold that preserves the original ROI's Betti numbers. In other words, ROIs are dilated as little as possible such that the number of connected components, tunnels, and cavities are preserved.
  2. By default, the tolerance for inclusion/exclusion ROIs is now 0mm (streamlines must intersect the ROIs).
  3. BabySeg is added. I also added a function to convert its maps to WM/GM/CSF segmentations. For this, I added special code to dilate the WM wherever it overlaps with non-cortical gray matter. This can be removed in the future if we see that it hurts, but this is intended to make tractography more easily traverse narrow WM regions. PFT tractography could also solve this, but it is much slower.
  4. I updated babyAFQ and the examples to 3.0. Some ROIs may still need to be tweaked.

Copilot AI review requested due to automatic review settings July 28, 2026 05:47

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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 8 out of 8 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (3)

AFQ/tasks/tissue.py:154

  • The ValueError message is now out of sync with the supported string options. This function also accepts 'multiaxial+brainchop+synthseg' and 'babyseg', but the error text only lists 'synthseg' and 'multiaxial+brainchop', which can mislead users when they pass a valid value.
    raise ValueError(
        "pve must be a PVEImage, PVEImages, 'synthseg', or 'multiaxial+brainchop'"
    )

AFQ/nn/babyseg.py:16

  • Other AFQ.nn modules define all (e.g., AFQ/nn/brainchop.py and AFQ/nn/synthseg.py). Adding babyseg.py without all makes its public surface less explicit/inconsistent with the established pattern.
logger = logging.getLogger("AFQ")


AFQ/nn/babyseg.py:107

  • New BabySeg-specific logic (label mapping + mixed-label boundary handling) is introduced here, but there are no unit tests covering it. The repo already has AFQ/nn/tests/test_nn.py for NN utilities; adding a small synthetic-ndarray test for pve_from_babyseg (including at least one voxel per label group and one mixed-label boundary case) would help prevent regressions without requiring onnxruntime.
def pve_from_babyseg(babyseg_data):
    """
    Compute partial volume estimates from BabySeg segmentation.

    Parameters
    ----------
    babyseg_data : ndarray
        The output segmentation from BabySeg.

    Returns
    -------
    pve : ndarray
        PVE data with CSF, GM, and WM segmentations.
    """

@36000 36000 changed the title [WIP/ENH] add babyseg and update babyAFQ [ENH] more specific ROI transforming, add babyseg, update babyAFQ Aug 27, 2026
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