Skip to content

Commit 9d6cd9e

Browse files
committed
BF: Do not overwrite previously converted nifti files unless overwrite
I remember us fixing this in Austin but somehow that was not committed
1 parent 3779ff9 commit 9d6cd9e

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

heudiconv/convert.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ def convert(items, converter, scaninfo_suffix, custom_callable, with_prov,
246246
os.makedirs(prefix_dirname)
247247

248248
for outtype in outtypes:
249-
lgr.debug("Processing %d dicoms for output type %s",
250-
len(item_dicoms), outtype)
249+
lgr.debug("Processing %d dicoms for output type %s. Overwrite=%s",
250+
len(item_dicoms), outtype, overwrite)
251251
lgr.debug("Includes the following dicoms: %s", item_dicoms)
252252

253253
seqtype = op.basename(op.dirname(prefix)) if bids else None
@@ -291,6 +291,11 @@ def convert(items, converter, scaninfo_suffix, custom_callable, with_prov,
291291
prov_files.append(prov_file)
292292

293293
tempdirs.rmtree(tmpdir)
294+
else:
295+
raise RuntimeError(
296+
"was asked to convert into %s but destination already exists"
297+
% (outname)
298+
)
294299

295300
if len(bids_outfiles) > 1:
296301
lgr.warning("For now not embedding BIDS and info generated "

tests/test_heuristics.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
import pytest
1313

14+
import logging
15+
lgr = logging.getLogger(__name__)
16+
1417
try:
1518
from datalad.api import Dataset
1619
except ImportError: # pragma: no cover
@@ -54,6 +57,10 @@ def test_dbic_bids_largely_smoke(tmpdir, heuristic, invocation):
5457
head = ds.repo.get_hexsha()
5558

5659
# and if we rerun -- should fail
60+
lgr.info(
61+
"RERUNNING, expecting to FAIL since the same everything "
62+
"and -c specified so we did conversion already"
63+
)
5764
with pytest.raises(RuntimeError):
5865
runner(args)
5966

0 commit comments

Comments
 (0)