Skip to content

Fix: Correct FastSurfer-CC error code handling and documentation formatting#794

Open
dkuegler wants to merge 3 commits intoDeep-MI:devfrom
dkuegler:fix/FastSurferCC/errorcode
Open

Fix: Correct FastSurfer-CC error code handling and documentation formatting#794
dkuegler wants to merge 3 commits intoDeep-MI:devfrom
dkuegler:fix/FastSurferCC/errorcode

Conversation

@dkuegler
Copy link
Member

@dkuegler dkuegler commented Feb 25, 2026

Summary

This PR fixes the error code handling in the FastSurfer-CC (CorpusCallosum) module and corrects documentation formatting issues.

Changes Made

1. Error Code Handling (fastsurfer_cc.py)

  • Fixed the error code return value in the main() function
  • The function now correctly returns 0 on success or an error message string on failure
  • Properly passed to sys.exit() to ensure correct process exit codes are communicated to the shell

2. Documentation Fixes

  • Removed extra formatting characters ("===+") in FastSurfer-CC documentation
  • Added proper heading to the argument parser's self-documentation

Motivation

Proper error code handling is critical for:

  • Automated workflows and script pipelines that depend on exit codes
  • CI/CD integration and error detection
  • Correct reporting of pipeline failures to calling processes

The documentation fixes improve clarity and prevent build/documentation generation issues.

Files Modified

  • CorpusCallosum/fastsurfer_cc.py - Error code handling in main function
  • CorpusCallosum/README.md - Documentation formatting

Breaking Changes

None - this is a bug fix that corrects existing behavior.

Testing Recommendations

  1. Test FastSurfer-CC with valid inputs and verify exit code is 0
  2. Test FastSurfer-CC with invalid inputs (missing files, bad parameters) and verify non-zero exit code
  3. Verify error messages are properly displayed
  4. Check that documentation builds without warnings
  5. Run existing test suite to ensure no regressions

Related Issues

Related to error handling improvements and documentation quality

Type

  • Feature
  • Bug Fix
  • Documentation
  • Code Quality/Refactoring

FastSurfer-CC's fastsurfer_cc.py returned with erroror code 0 despite failing some cc surface processing steps.
This Commit fixes the error processing of FsatSurfer-CC so that the error code and error message are consistent and robust.
CorpusCallosum.fastsurfer_cc.main now does not only return None irrespective of success, but returns 0 if successful and an error string.

Also two minor fixes:
1. use BASH_SOURCE[0] instead of $0 in recon_sirf/functions.sh
2. add a missing wrap in run_fastsurfer.sh
- Add a heading to the Parser self-documentation
Copy link
Contributor

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 aims to improve error code handling in the FastSurfer-CC (CorpusCallosum) module and includes several code quality improvements across multiple files. The primary goal is to align the error handling with the established pattern in the codebase where main functions return exit codes or error messages rather than calling sys.exit() directly.

Changes:

  • Modified fastsurfer_cc.py main() function to return Literal[0] | str and wrapped the call with sys.exit() at the call site
  • Renamed variable io_futures to futures throughout the file for improved clarity
  • Added timing wrapper ${wrap[@]} to a command in run_fastsurfer.sh for consistent execution time logging
  • Updated recon_surf/functions.sh to use ${BASH_SOURCE[0]} instead of $0 for proper path resolution in sourced scripts
  • Enhanced documentation formatting in doc/scripts/fastsurfer_cc.rst with proper backticks and section headings

Reviewed changes

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

File Description
CorpusCallosum/fastsurfer_cc.py Updated return type from None to Literal[0] | str, renamed io_futures to futures, added error handling for failed futures, and wrapped main() call with sys.exit()
run_fastsurfer.sh Added timing wrapper to reduce_to_aseg.py command (line 1012) and improved array append syntax (line 1278)
recon_surf/functions.sh Changed from $0 to ${BASH_SOURCE[0]} for proper directory resolution in sourced scripts
doc/scripts/fastsurfer_cc.rst Added command-line interface heading, changed start-line to skip title, and improved flag formatting with backticks

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

@dkuegler dkuegler requested a review from ClePol February 25, 2026 16:30
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