Skip to content

Commit e7ac089

Browse files
committed
fix: avoid date sorting assumption
1 parent 093e848 commit e7ac089

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

heudiconv/bids.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,11 @@ def add_rows_to_scans_keys_file(fn, newrows):
339339
# prepare all the data rows
340340
data_rows = [[k] + v for k, v in fnames2info.items()]
341341
# sort by the date/filename
342-
data_rows_sorted = sorted(data_rows, key=lambda x: (x[1], x[0]))
342+
try:
343+
data_rows_sorted = sorted(data_rows, key=lambda x: (x[1], x[0]))
344+
except TypeError as exc:
345+
lgr.warning("Sorting scans by date failed: %s", str(exc))
346+
data_rows_sorted = sorted(data_rows)
343347
# save
344348
with open(fn, 'a') as csvfile:
345349
writer = csv.writer(csvfile, delimiter='\t')

0 commit comments

Comments
 (0)