Skip to content

Add fetalsynthseg support for segmentation option#92

Open
vladzalevskyi wants to merge 2 commits intofetpype:mainfrom
vladzalevskyi:main
Open

Add fetalsynthseg support for segmentation option#92
vladzalevskyi wants to merge 2 commits intofetpype:mainfrom
vladzalevskyi:main

Conversation

@vladzalevskyi
Copy link

No description provided.

Copilot AI review requested due to automatic review settings December 12, 2025 12:44
Copy link

Copilot AI left a comment

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 support for the fetalsynthseg segmentation method as an alternative to the existing bounti method. The implementation includes new configuration files, BIDS output path regex rules for renaming segmentation outputs, and updates to valid pipeline definitions. The default Docker configuration is also updated to use fetalsynthseg instead of bounti.

Key changes:

  • Added fetalsynthseg to the list of valid segmentation pipelines
  • Implemented BIDS-compliant output file renaming rules for fetalsynthseg segmentation results
  • Created configuration files for the new segmentation pipeline and corresponding surface extraction variant

Reviewed changes

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

Show a summary per file
File Description
fetpype/definitions.py Added "fetalsynthseg" to VALID_SEGMENTATION list
configs/segmentation/fetalsynthseg.yaml New configuration file defining Docker command for fetalsynthseg pipeline
configs/surface/surfpypefss.yaml New surface extraction configuration using fetalsynthseg labelling scheme
configs/default_docker.yaml Updated default segmentation from bounti to fetalsynthseg and surface config to surfpypefss
fetpype/utils/utils_bids.py Added regex rules for renaming fetalsynthseg output files to BIDS format; minor code formatting cleanup

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

@t-sanchez
Copy link
Contributor

We also have a bit of a finicky flake8, please address this style comments:

Run flake8 --count fetpype
fetpype/utils/utils_bids.py:108:80: E501 line too long (86 > 79 characters)
fetpype/utils/utils_bids.py:120:80: E501 line too long (81 > 79 characters)
fetpype/utils/utils_bids.py:166:80: E501 line too long (80 > 79 characters)
fetpype/utils/utils_bids.py:312:80: E501 line too long (87 > 79 characters)
fetpype/utils/utils_bids.py:437:80: E501 line too long (84 > 79 characters)
fetpype/utils/utils_bids.py:488:80: E501 line too long (82 > 79 characters)
fetpype/utils/utils_bids.py:530:80: E501 line too long (80 > 79 characters)
fetpype/utils/utils_bids.py:532:80: E501 line too long (83 > 79 characters)
8
Error: Process completed with exit code 1.

@t-sanchez
Copy link
Contributor

  • Could you also work on updating the documentation accordingly?

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

@t-sanchez t-sanchez left a comment

Choose a reason for hiding this comment

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

Code review

--input <input_dir>/input_srr.nii.gz
--output <output_dir>/seg-drifts_pred.nii.gz
--gpu --lateralize"
path_to_output: "seg-drifts_pred.nii.gz"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the output name of FetalSynthSeg still named drifts?

Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than creating a duplicated surfpype, the idea would be to have

labelling_scheme:
    bounti: [....]
    fetalsynthseg: [13, 14, 16]

and keep use_scheme=bounti for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

The idea here would be to have a single file surfpype.yaml, have different labelling schemes and and then use_scheme based on what segmentation you're using. Could you adapt your code to this?

Also, I think that if would be great to add a minor edit in the function
check_valid_pipeline
to have

    if "surface" in cfg:
        ...
    if cfg.surface.surface_rh.use_scheme != cfg.segmentation.pipeline:
        raise RuntimeError(f"Segmentation method {cfg.segmentation.pipeline} is incompatible with the surface extraction scheme {cfg.surface.surface_rh.use_scheme }")

And the same check on the LH. Let me know if this isn't clear.

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