Skip to content

Fix silent registration failure when paths contain spaces#40

Open
LalithShiyam wants to merge 1 commit intomasterfrom
fix/shell-escape-paths-with-spaces
Open

Fix silent registration failure when paths contain spaces#40
LalithShiyam wants to merge 1 commit intomasterfrom
fix/shell-escape-paths-with-spaces

Conversation

@LalithShiyam
Copy link
Copy Markdown
Collaborator

@LalithShiyam LalithShiyam commented Mar 16, 2026

Summary

  • Greedy and c3d subprocess calls used shell=True with unquoted f-string paths, causing silent failures when directory paths contained spaces
  • Replaced re.escape() (regex escaping — wrong context) and bare path interpolation with shlex.quote() for proper shell escaping
  • Fixed all 6 affected locations in ImageRegistration: rigid(), affine(), deformable(), _build_cmd() (resample), and rgb2gray()

Problem

When a subject directory path contained spaces (e.g., psma vs acp3 patients/), the shell split the path into separate arguments. Greedy failed but capture_output=True swallowed stderr and the return code was never checked — so PUMA logged alignment as "done" but no output files were created. This caused a FileNotFoundError downstream when trying to copy aligned masks.

Test plan

  • Verified fix on 10-subject dataset with spaces in path (psma vs acp3 patients/puma_input/)
  • Subject 02 completed full pipeline (segmentation → registration → multiplexing) in 4.2 minutes
  • Verified paths without spaces still work (no regression)

🤖 Generated with Claude Code

All subprocess calls to greedy and c3d used shell=True with unquoted
f-string paths. When directory paths contained spaces (e.g.,
"psma vs acp3 patients"), the shell would split them into separate
arguments causing greedy to fail silently — capture_output=True
swallowed stderr and the return code was never checked.

Replace re.escape() (regex escaping, wrong context) and bare f-string
interpolation with shlex.quote() for proper shell escaping across all
subprocess calls: rigid(), affine(), deformable(), _build_cmd(), and
rgb2gray().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant