Skip to content

Conversation

yarikoptic
Copy link
Member

We observed the Study Description to contain spaces in it. Due to unresolved bug in nipype (nipy/nipype#3604) we must avoid spaces in the file names since then external execution of dcm2niix would fail. While at it, I decided to sanitize it more and replace all other "funny" characters with the special treatment by shells.

@yarikoptic yarikoptic requested a review from Copilot August 29, 2025 21:29
@yarikoptic yarikoptic added patch Increment the patch version when merged release Create a release when this pr is merged labels Aug 29, 2025
Copy link

@Copilot 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 sanitizes the "locator" value to avoid spaces and special characters that could cause issues with dcm2niix execution due to a known nipype bug. The changes implement a path sanitization utility that replaces problematic characters with underscores.

  • Adds a sanitize_path function to clean paths by replacing unwanted characters with underscores
  • Applies sanitization to the locator value in the main workflow
  • Includes comprehensive test coverage for both valid and invalid path scenarios

Reviewed Changes

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

File Description
heudiconv/utils.py Adds delete_chars and sanitize_path utility functions for path cleaning
heudiconv/main.py Applies sanitize_path to the locator value in the workflow
heudiconv/tests/test_utils.py Adds parametrized tests for the new sanitization functions

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

lgr.warning(
"%r %s contained problematic character(s), it " "was cleaned to be %r",
path,
descr,
clean_path,
)
Copy link
Preview

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

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

The string concatenation with a space between two string literals is unnecessary. The strings should be combined into a single string for better readability: \"%r %s contained problematic character(s), it was cleaned to be %r\"

Copilot uses AI. Check for mistakes.

@yarikoptic yarikoptic force-pushed the bf-locator-sanitize branch from d3bcf81 to e774c2d Compare August 29, 2025 21:49
Copy link

codecov bot commented Aug 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.92%. Comparing base (5b1718b) to head (16c72a1).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #830      +/-   ##
==========================================
+ Coverage   82.84%   82.92%   +0.07%     
==========================================
  Files          42       42              
  Lines        4313     4333      +20     
==========================================
+ Hits         3573     3593      +20     
  Misses        740      740              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@yarikoptic yarikoptic force-pushed the bf-locator-sanitize branch from e774c2d to afb7626 Compare August 29, 2025 22:18
We observed the Study Description to contain spaces in it. Due to unresolved bug in nipype
(nipy/nipype#3604) we must avoid spaces in the file names since
then external execution of dcm2niix would fail.  While at it, I decided to sanitize it more
and replace all other "funny" characters with the special treatment by shells.
@yarikoptic yarikoptic force-pushed the bf-locator-sanitize branch from afb7626 to 16c72a1 Compare August 29, 2025 22:19
@yarikoptic yarikoptic requested a review from bpinsard August 31, 2025 13:37
@yarikoptic
Copy link
Member Author

Do you rely on locator values extracted from DICOMs StudyDescription, @nipy/team-heudiconv ?
if so -- please verify that this PR doesn't affect behavior for you!

I am planing to merge/release within a week or so

@bpinsard
Copy link
Contributor

bpinsard commented Sep 2, 2025

LGTM, I think we were taking care of the sanitization in our heuristics infotoids and using spaces in the Siemens program tree was rare or none.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Increment the patch version when merged release Create a release when this pr is merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants