Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Recompress files where dcm2niix failed #803

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

octomike
Copy link
Contributor

As threatened in #802 an alternative approach.

  • try to open and read the nifit to verify it wasn't truncated
  • recompress with gzip
  • fail if we couldn't - as opposed to just emit invalid file names (at least fmriprep fails to handle nii.gz that are not gz at all)

I decided to leverage the fact that heudiconv blindly moves all converted output files to nii.gz, even if they are just nii by renaming the successfully re-compressed image to .nii. This feels ugly, but results in the shortest/least-invasive PR.

Copy link

codecov bot commented Nov 12, 2024

Codecov Report

Attention: Patch coverage is 28.00000% with 18 lines in your changes missing coverage. Please review.

Project coverage is 82.12%. Comparing base (900ccdc) to head (a72d5ec).

Files with missing lines Patch % Lines
heudiconv/convert.py 28.00% 18 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #803      +/-   ##
==========================================
- Coverage   82.48%   82.12%   -0.36%     
==========================================
  Files          42       42              
  Lines        4323     4348      +25     
==========================================
+ Hits         3566     3571       +5     
- Misses        757      777      +20     

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

@octomike octomike force-pushed the fix/recompress_uncompressed_nii branch from 7aff494 to a72d5ec Compare November 12, 2024 23:41
"trying to salvage by recompressing ourselves. "
"This might take a while ")
if not recompress_failed(uncompressed):
raise RuntimeError("Error compressing nifti")
Copy link
Member

Choose a reason for hiding this comment

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

why to delay this crash here? this way you are hiding from user information on individual file and corresponding error -- why not just to just call recompress here and let error (if any happens) to bubble up?

I would also just loop here and have recompress to operate on a single file.

FWIW, I think it would be worth adding a test scenario to test this code path. I would have just mock patched the nipype_convert so that I would decompress some output file(s) and thus triggering this code path.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I'll look into it!

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