Fix nnU-Net output filename matching & Add --only_backbone option#7
Open
FrancescoCorrenti wants to merge 1 commit intoLucasFidon:masterfrom
Open
Fix nnU-Net output filename matching & Add --only_backbone option#7FrancescoCorrenti wants to merge 1 commit intoLucasFidon:masterfrom
FrancescoCorrenti wants to merge 1 commit intoLucasFidon:masterfrom
Conversation
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.
Fix nnU-Net output filename matching & Add --only_backbone option
Description
This PR introduces two main improvements to the segmentation pipeline logic in
run_segment.py.1. Fix: Robust filename matching for nnU-Net outputs
The Problem:
Previously, the script attempted to locate the intermediate output files (generated by
inference_nnunet.py) by deriving the filename from theoutput_folderpath. However, the underlying nnU-Net inference script generates output filenames based on the parent directory of the input file, not the output directory.The Fix:
I updated the filename derivation logic to use:
This ensures that
run_segment.pycorrectly locates the.npzand.pklfiles generated by the backbone inference step. This fixesFileNotFoundErrorcrashes that occurred when the input folder name and output folder name did not match (specifically when BFC was disabled).2. Feature: Added
--only_backboneargumentI added a new flag
--only_backboneto the argument parser.Changes
f_nvariable assignment to useos.path.dirname(input_path)to align with nnU-Net naming convention.--only_backbonetoArgumentParser.args.only_backboneis true, skipping the fallback and trustworthy sections.Testing
--only_backbonesuccessfully produces the Backbone AI output and exits without errors before running the atlas registration.