Skip to content

Commit bf9a3e1

Browse files
author
DBIC BIDS Team
committed
BF: Various minor fixes while trying to use with nibabel 3.2.1
1 parent 156ed9b commit bf9a3e1

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

heudiconv/bids.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import os
55
import os.path as op
66
import logging
7+
import numpy as np
78
import re
89
from collections import OrderedDict
910
from datetime import datetime
@@ -612,8 +613,10 @@ def get_key_info_for_fmap_assignment(json_file, matching_parameter='ImagingVolum
612613
elif matching_parameter == 'ImagingVolume':
613614
from nibabel import load as nb_load
614615
nifti_file = glob(remove_suffix(json_file, '.json') + '.nii*')
616+
assert len(nifti_file) == 1
617+
nifti_file = nifti_file[0]
615618
nifti_header = nb_load(nifti_file).header
616-
key_info = [nifti_header.affine, nifti_header.dim[1:3]]
619+
key_info = [nifti_header.get_best_affine(), nifti_header.get_data_shape()[:3]]
617620
elif matching_parameter == 'AcquisitionLabel':
618621
# Check the acq label for the fmap and the modality for others:
619622
modality = op.basename(op.dirname(json_file))
@@ -677,10 +680,9 @@ def find_compatible_fmaps_for_run(json_file, fmap_groups, matching_parameters=['
677680
compatible = False
678681
for param in matching_parameters:
679682
fm_info = get_key_info_for_fmap_assignment(fm_group[0], param)
680-
if json_info[param] == fm_info:
681-
compatible = True
682-
else:
683-
compatible = False
683+
# allow for tiny differences between the affines etc
684+
compatible = all(np.allclose(x, y) for x, y in zip(json_info[param], fm_info))
685+
if not compatible:
684686
continue # don't bother checking more params
685687
if compatible:
686688
compatible_fmap_groups[fm_key] = fm_group

0 commit comments

Comments
 (0)