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

BF: split prefix into path (if any) and provide only basename as prefix for dcm2niix invocation #485

Merged
merged 5 commits into from
Dec 23, 2020

Conversation

yarikoptic
Copy link
Member

@yarikoptic yarikoptic commented Dec 22, 2020

dcm2niix started to segfault whenever -f is too long rordenlab/dcm2niix#465 .
And it feels that we abused -f wherever -o should have been used.
I have not looked though through history of changes if such use of -f
was warranted, but as I see that output_dir is not explicitly defined,
decided to just use that one instead.

Initial commit resolved the dcm2niix segfault during heudiconv/tests/test_heuristics.py::test_scans_keys_reproin
when testing on my laptop, BUT resulted in test failures since now placing the files in the output directory copying to destination was not working since it was destination. I added conditional in safe_copyfile (0f6abbf) but that was not sufficient and also made me wonder -- if placing already at the destination (or near) why don't we move instead of copying? That would also resolve #481 and make heudiconv more robust IMHO in cases where /tmp has smaller capacity than the destination.

The only negative side-effect might be that the target directory, in case of abnormal heudiconv operation, would have those _heudiXXX files. I could present it as a feature which would ease troubleshooting etc ;)

So I followed up with 8b4b7a0 where I have also added a random suffix to the target suffix given to nipype's dcm2niix call. This is the most radical change in this PR which might introduce some bugs if we are not moving/renaming files properly. But looking at the code we seems to be doing all needed, and then

$> find pytest-of-yoh -iname *_heudi*
pytest-of-yoh/pytest-0/test_embed_dicom_and_nifti_met0/nifti_heudiconv222.nii.gz

as in that explicit test we do not bother renaming etc, whenever all the other files in there seems to look good. So I have good confindence that we should be ok.

then while at it I followed up with 7ad241c which should address #462 .

TODO

edit: additional benefit

  • by placing into target directory right away we would not loose some files nipype or us forgot to move (like we had with DWI .bvec) -- they just will have an odd suffix. I like it

…ix for dcm2niix invocation

dcm2niix started to segfault whenever -f is too long.
rordenlab/dcm2niix#465

And it feels that we abused -f wherever -o should have been used.
I have not looked though through history of changes if such use of -f
was warranted, but as I see that output_dir is not explicitely defined,
decided to just use that one instead.

this seems to resolve the dcm2niix segfault during
heudiconv/tests/test_heuristics.py::test_scans_keys_reproin
when testing on my laptop
Original motivation is that somehow prior commits trying to split apart prefix
from the full path we are already providing broke some tests, e.g. resulted in
extra commits on rewrites.

Since they could be one the same file system and otherwise not used after being
transfered to the target destination, it would be much cheaper to just move
them instead of copying.  It is also more likely to have sufficient space in
destination than in the /tmp, which already brought questions: this commit would
Closes nipy#481 as a result as well.
@codecov
Copy link

codecov bot commented Dec 22, 2020

Codecov Report

Merging #485 (bfa2ae3) into master (ee5cebb) will increase coverage by 0.04%.
The diff coverage is 79.16%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #485      +/-   ##
==========================================
+ Coverage   75.96%   76.01%   +0.04%     
==========================================
  Files          38       38              
  Lines        2996     3010      +14     
==========================================
+ Hits         2276     2288      +12     
- Misses        720      722       +2     
Impacted Files Coverage Δ
heudiconv/convert.py 85.27% <75.00%> (+0.18%) ⬆️
heudiconv/utils.py 89.91% <75.00%> (-0.54%) ⬇️
heudiconv/parser.py 92.39% <100.00%> (+0.25%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ee5cebb...bfa2ae3. Read the comment docs.

@yarikoptic
Copy link
Member Author

yarikoptic commented Dec 22, 2020

Dear @mgxd @tsalo @satra and @nipy/team-heudiconv -- your speedy feedback on this change would be appreciated. We need to workaround a regression (IMHO) in dcm2niix which could lead to segfaults with current version. See description of PR and individual commits for more information. If no objections are voiced within a day, I would aim to release tomorrow (sorry for a short notice etc, but want to get this one out) and will bear the responsibility for fixing what I broke (if anything)

@yarikoptic
Copy link
Member Author

FWIW, wherever dependencies allowed, builds went find on neurodebians

@yarikoptic yarikoptic merged commit 48fd898 into nipy:master Dec 23, 2020
@yarikoptic yarikoptic added this to the 0.9.0 milestone Dec 23, 2020
yarikoptic added a commit that referenced this pull request Dec 23, 2020
Various improvements and compatibility/support (dcm2niix, datalad,
duecredit) changes.  Major change is placement of output files to the
target output directory during conversion.

- #454 zenodo referencing in README.rst and support for ducredit for
  heudiconv and reproin heuristic
- #445 more tutorial references in README.md

- [#485][] placed files during conversion right away into the target
  directory (with a `_heudiconv???` suffix, renamed into ultimate target
  name later on), which avoids hitting file size limits of /tmp ([#481][]) and
  helped to avoid a regression in dcm2nixx 1.0.20201102
- #477 replaced `rec-<magnitude|phase>` with `part-<mag|phase>` now
  that BIDS supports the part entity
- #473 made default for CogAtlasID to be a TODO URL
- #459 made AcquisitionTime used for acq_time scans file field
- #451 retained sub-second resolution in scans files
- #442 refactored code so there is now heudiconv.main.workflow for
  more convenient use as a Python module

- minimal version of nipype set to 1.2.3 to guarantee correct handling
  of DWI files ([#480][])
- `heudiconvDCM*` temporary directories are removed now ([#462][])
- compatibility with DataLad 0.13 ([#464][])

- #443 pathlib as a dependency (we are Python3 only now)

* tag 'v0.9.0':
  Add a helper rule to upload to pypi
  update changelog reference as part of prep release
  [DATALAD RUNCMD] prepare the release
  CHANGELOG entry for 0.9.0
yarikoptic added a commit that referenced this pull request Dec 23, 2020
Various improvements and compatibility/support (dcm2niix, datalad,
duecredit) changes.  Major change is placement of output files to the
target output directory during conversion.

- #454 zenodo referencing in README.rst and support for ducredit for
  heudiconv and reproin heuristic
- #445 more tutorial references in README.md

- [#485][] placed files during conversion right away into the target
  directory (with a `_heudiconv???` suffix, renamed into ultimate target
  name later on), which avoids hitting file size limits of /tmp ([#481][]) and
  helped to avoid a regression in dcm2nixx 1.0.20201102
- #477 replaced `rec-<magnitude|phase>` with `part-<mag|phase>` now
  that BIDS supports the part entity
- #473 made default for CogAtlasID to be a TODO URL
- #459 made AcquisitionTime used for acq_time scans file field
- #451 retained sub-second resolution in scans files
- #442 refactored code so there is now heudiconv.main.workflow for
  more convenient use as a Python module

- minimal version of nipype set to 1.2.3 to guarantee correct handling
  of DWI files ([#480][])
- `heudiconvDCM*` temporary directories are removed now ([#462][])
- compatibility with DataLad 0.13 ([#464][])

- #443 pathlib as a dependency (we are Python3 only now)

* tag 'v0.9.0':
  Do no bother ensuring that version changed - should be no changes
@yarikoptic yarikoptic deleted the bf-split-prefix branch April 30, 2021 12:34
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.

Question: Why is dcm2niix saving to /tmp
1 participant