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

with and without --overwrite #288

Open
dkp opened this issue Dec 17, 2018 · 5 comments
Open

with and without --overwrite #288

dkp opened this issue Dec 17, 2018 · 5 comments

Comments

@dkp
Copy link

dkp commented Dec 17, 2018

I believe you may have dealt with similar topics, so sorry if this is a repetition... I don't see this explicitly in the issues. If I have 2 runs to convert, I expect to get:
sub-220_ses-foo_task-rest_run-01_bold.json
sub-220_ses-foo_task-rest_run-01_bold.nii
sub-220_ses-foo_task-rest_run-01_bold.nii.gz
sub-220_ses-foo_task-rest_run-01_events.tsv
sub-220_ses-foo_task-rest_run-02_bold.json
sub-220_ses-foo_task-rest_run-02_bold.nii
sub-220_ses-foo_task-rest_run-02_bold.nii.gz
sub-220_ses-foo_task-rest_run-02_events.tsv

BUT, if I run without --overwrite, then heudiconv complains that it would have to overwritedata and generates only:
sub-220_ses-foo_task-rest_run-01_bold.json
sub-220_ses-foo_task-rest_run-01_bold.nii
sub-220_ses-foo_task-rest_run-01_bold.nii.gz
sub-220_ses-foo_task-rest_run-01_events.tsv

This is not the behavior I expect. That is, it seems that I have to run with --overwrite or not everything will be converted.
Am I missing something?

@mgxd
Copy link
Member

mgxd commented Jan 11, 2019

@dkp can you share a few things?

  • heudiconv version
  • heuristic
  • conversion log
  • dicominfo

Thanks!

@mgxd
Copy link
Member

mgxd commented Mar 13, 2019

hi @dkp is this still a problem?

@dkp
Copy link
Author

dkp commented Mar 13, 2019 via email

@mgxd
Copy link
Member

mgxd commented Mar 13, 2019

The --overwrite flag is intended to facilitate re-conversions (@yarikoptic feel free to chime in, I know we have pushed and pulled on this before) - without it, heudiconv will not write to file if it already exists. Here is the logic

if not op.exists(outname) or overwrite:
tmpdir = tempdirs('dcm2niix')
# run conversion through nipype
res, prov_file = nipype_convert(item_dicoms, prefix, with_prov,
bids, tmpdir, dcmconfig)
bids_outfiles = save_converted_files(res, item_dicoms, bids,
outtype, prefix,
outname_bids,
overwrite=overwrite)
# save acquisition time information if it's BIDS
# at this point we still have acquisition date
if bids:
save_scans_key(item, bids_outfiles)
# Fix up and unify BIDS files
tuneup_bids_json_files(bids_outfiles)
if prov_file:
prov_files.append(prov_file)
tempdirs.rmtree(tmpdir)
else:
raise RuntimeError(
"was asked to convert into %s but destination already exists"
% (outname)
)

What I suspect is happening in your case is 2 (or more) scans are being classified for the same key. This will be caught and rightfully throw an error (stopping any further conversion). This is generally the case when excluding or hardcoding run-<number> in your key. An easy workaround would be to use the {item} formatting key, which is the index of a scan for a given info key. Here's an example

bold = create_key('sub-{subject}/func/sub-{subject}_task-test_run-{item}_bold')

Otherwise, if you could share your heuristic + dicominfo.tsv, we could track down the problem.

And awesome documentation! We were going to write up a readthedocs page, and yours checks off a lot of the boxes! Would you mind if we forked yours as a starting point?

@dkp
Copy link
Author

dkp commented Mar 13, 2019 via email

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

No branches or pull requests

2 participants