From 26f1435855dff01ff2cdddbba1c3cf6d0376168d Mon Sep 17 00:00:00 2001 From: Vincent Bazinet Date: Mon, 25 Apr 2022 20:25:43 -0400 Subject: [PATCH] [FIX] Fix bug in resample_images This commit fixes a bug in `resample_images` that would happen when a single str or os.PathLike object specifies the path to single-hemispheric `src` or `trg` images. This bug would happen when `resample_images`would try to load the gifti file of the un-transformed map. A call to the `tranforms._check_hemi` function fixes the issue. --- neuromaps/resampling.py | 2 ++ neuromaps/transforms.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/neuromaps/resampling.py b/neuromaps/resampling.py index 3e11e942..a74cc372 100644 --- a/neuromaps/resampling.py +++ b/neuromaps/resampling.py @@ -270,6 +270,8 @@ def resample_images(src, trg, src_space, trg_space, method='linear', func = globals()[resampling] src, trg = func(src, trg, src_space, trg_space, hemi=hemi, method=method, **opts) + src, _ = zip(*transforms._check_hemi(src, hemi)) + trg, _ = zip(*transforms._check_hemi(trg, hemi)) src = tuple(load_gifti(s) for s in src) trg = tuple(load_gifti(t) for t in trg) diff --git a/neuromaps/transforms.py b/neuromaps/transforms.py index b38c4e13..28ea7ca1 100644 --- a/neuromaps/transforms.py +++ b/neuromaps/transforms.py @@ -267,14 +267,15 @@ def mni152_to_mni152(img, target='1mm', method='linear'): def _check_hemi(data, hemi): - """ Utility to check that `data` and `hemi` jibe + """ + Utility to check that `data` and `hemi` jibe Parameters ---------- data : str or os.PathLike or tuple Input data hemi : str - Hemisphere(s) corresponding to `data + Hemisphere(s) corresponding to `data` Returns -------