Skip to content

Commit fb96270

Browse files
committed
fix: reuse previously cached heuristics
1 parent 89317df commit fb96270

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

heudiconv/convert.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,20 @@ def prep_conversion(sid, dicoms, outdir, heuristic, converter, anon_sid,
123123
# ref: https://github.com/nipy/heudiconv/issues/84#issuecomment-330048609
124124
# for more automagical wishes
125125
target_heuristic_filename = op.join(idir, 'heuristic.py')
126+
# faciliates change - TODO: remove in 1.0
127+
old_heuristic_filename = op.join(idir, op.basename(heuristic.filename))
128+
if op.exists(old_heuristic_filename):
129+
assure_no_file_exists(target_heuristic_filename)
130+
safe_copyfile(old_heuristic_filename, target_heuristic_filename)
131+
assure_no_file_exists(old_heuristic_filename)
126132
# TODO:
127133
# 1. add a test
128134
# 2. possibly extract into a dedicated function for easier logic flow here
129135
# and a dedicated unittest
130-
if (op.exists(target_heuristic_filename) and
131-
file_md5sum(target_heuristic_filename) != file_md5sum(heuristic.filename)):
136+
if (
137+
op.exists(target_heuristic_filename) and
138+
file_md5sum(target_heuristic_filename) != file_md5sum(heuristic.filename)
139+
):
132140
# remake conversion table
133141
reuse_conversion_table = False
134142
lgr.info(

0 commit comments

Comments
 (0)