Skip to content
Snippets Groups Projects
Commit 2777a190 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

Bugfix - dicom json file sorting was not taking into account file names with

non-numeric characters in prefix.
parent dac9abcc
No related branches found
No related tags found
No related merge requests found
......@@ -152,8 +152,9 @@ def scanDir(dcmdir):
if not enabled():
raise RuntimeError('dcm2niix is not available or is too old')
dcmdir = op.abspath(dcmdir)
cmd = 'dcm2niix -b o -ba n -f %s -o . {}'.format(dcmdir)
dcmdir = op.abspath(dcmdir)
cmd = 'dcm2niix -b o -ba n -f %s -o . {}'.format(dcmdir)
snumPattern = re.compile('^[0-9]+')
with tempdir.tempdir() as td:
......@@ -165,11 +166,17 @@ def scanDir(dcmdir):
if len(files) == 0:
return []
# sort numerically by series number
def sortkey(f):
return int(op.splitext(op.basename(f))[0])
# sort numerically by series number if possible
try:
def sortkey(f):
match = re.match(snumPattern, f)
snum = int(match.group(0))
return snum
files = sorted(files, key=sortkey)
files = sorted(files, key=sortkey)
except Exception:
files = sorted(files)
series = []
for fn in files:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment