Support arbitrary patch configurations with dynamic cut handling#39
Draft
Support arbitrary patch configurations with dynamic cut handling#39
Conversation
- Updated core.py to extract cut names dynamically from vertex_dict - Made merge_small_components flexible with optional max_cuts parameter - Made classify_cuts_anatomically fall back to generic naming for non-standard patches - Updated identify_surface_components to support arbitrary patch configurations - Updated docstrings to reflect flexibility - Updated tests to pass with new flexible behavior Co-authored-by: mvdoc <6150554+mvdoc@users.noreply.github.com>
- Added validate_patch_topology() function to check patch topology - Exported key functions in __init__.py for programmatic use - Created comprehensive examples demonstrating flexible patch usage - Added test for topology validation - Added examples/README.md with usage guide - All tests pass (151 passed, 6 skipped) Co-authored-by: mvdoc <6150554+mvdoc@users.noreply.github.com>
- Added section on custom patches and arbitrary regions - Documented how to create custom templates - Added example code for validation - Referenced examples directory for detailed usage Co-authored-by: mvdoc <6150554+mvdoc@users.noreply.github.com>
- Format function calls with multiple parameters across lines - Improve code readability per review suggestions Co-authored-by: mvdoc <6150554+mvdoc@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Extend template logic to allow other patches and regions
Support arbitrary patch configurations with dynamic cut handling
Dec 15, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The template system hardcoded expectations for exactly 5 cuts with specific anatomical names (calcarine, medial1-3, temporal) and required a medial wall. This prevented creating patches for arbitrary brain regions like isolated occipital or temporal patches.
Changes
Dynamic cut extraction
ensure_continuous_cuts,refine_cuts_with_geodesic) now iterate over all keys invertex_dictexcept reservedmwallkeycut_names = ["calcarine", "medial1", "medial2", "medial3", "temporal"]in favor of[k for k in vertex_dict.keys() if k != "mwall"]Flexible template processing
merge_small_components(): Added optionalmax_cutsparameter (defaultNone= keep all cuts)classify_cuts_anatomically(): Falls back to generic names (cut1,cut2, etc.) when anatomical classification not applicableidentify_surface_components(): Addedmax_cutsandclassify_anatomicallyparametersTopology validation
validate_patch_topology()function checks single connected component, disk topology (one boundary loop), and reasonable patch sizeAPI exports
__init__.pyfor programmatic use:validate_patch_topology,ensure_continuous_cuts,refine_cuts_with_geodesic, etc.Usage
Use custom template:
autoflatten subject --template-file occipital_patch.jsonSee
examples/custom_patch_example.pyfor comprehensive examples.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.