Skip to content

Commit 5da4e89

Browse files
committed
utils: update get_mapper call sites for maptype= rename (from PR 12 / 2a3c944c)
PR 6 renames get_mapper's `type` parameter to `maptype` (mypy Wave 3, 2a3c944c: `type` shadowed the builtin `type` used on the very next line). cortex/utils.py has four call sites still using the old `type=` keyword; since get_mapper has **kwargs, this wasn't a clean TypeError — the old keyword silently landed in **kwargs, get_mapper defaulted `maptype` to "nearest" regardless of what was requested, and the leftover kwarg then propagated down to the sampler functions where PR 6 also added a "raise ValueError on unexpected kwargs" check, surfacing as a confusing ValueError several frames removed from the actual cause (or, worse, no error at all and silently the wrong mapper class if a cache file for "nearest" already happened to exist). Reproduced before this commit: get_mapper('S1', 'fullhead', type='trilinear', recache=True) -> ValueError: nearest sampler does not take any kwargs This isn't otherwise in PR 6 or PR 7's file list (cortex/utils.py belongs to PR 12), but is picked from PR 12's 2a3c944c here — just the four `type=` -> `maptype=` call-site renames in get_cortical_mask, get_hemi_masks, get_roi_mask, and get_roi_masks — so that PR 6+7 doesn't leave get_mapper's real callers broken. PR 12 will still add full typing to cortex/utils.py; this commit only touches the four call sites that would otherwise regress. Verified: get_cortical_mask, get_hemi_masks, and get_roi_masks all run correctly against the S1 test subject after this fix; all 4 previously failed or behaved incorrectly before it (get_mapper('S1', 'fullhead', type='trilinear', recache=True) reproduces the bug directly).
1 parent 29137b9 commit 5da4e89

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

cortex/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ def get_cortical_mask(subject, xfmname, type='nearest'):
337337
dist, idx = get_vox_dist(subject, xfmname)
338338
return dist < dict(thick=8, thin=2)[type]
339339
else:
340-
return get_mapper(subject, xfmname, type=type).mask
340+
return get_mapper(subject, xfmname, maptype=type).mask
341341

342342

343343
def get_vox_dist(subject, xfmname, surface="fiducial", max_dist=np.inf):
@@ -395,7 +395,7 @@ def get_hemi_masks(subject, xfmname, type='nearest'):
395395
-------
396396
397397
'''
398-
return get_mapper(subject, xfmname, type=type).hemimasks
398+
return get_mapper(subject, xfmname, maptype=type).hemimasks
399399

400400
def add_roi(data, name="new_roi", open_inkscape=True, add_path=True,
401401
overlay_file=None, **kwargs):
@@ -590,7 +590,7 @@ def get_roi_mask(subject, xfmname, roi=None, projection='nearest'):
590590
"""
591591
warnings.warn('Deprecated! Use get_roi_masks')
592592

593-
mapper = get_mapper(subject, xfmname, type=projection)
593+
mapper = get_mapper(subject, xfmname, maptype=projection)
594594
rois = get_roi_verts(subject, roi=roi, mask=True)
595595
output = dict()
596596
for name, verts in list(rois.items()):
@@ -790,7 +790,7 @@ def get_roi_masks(subject, xfmname, roi_list=None, gm_sampler='cortical', split_
790790
if (use_cortex_mask or split_lr) or (not return_dict):
791791
vox_dst, vox_idx = get_vox_dist(subject, xfmname)
792792
if use_mapper:
793-
mapper = get_mapper(subject, xfmname, type=mapper_dict[gm_sampler])
793+
mapper = get_mapper(subject, xfmname, maptype=mapper_dict[gm_sampler])
794794
elif use_cortex_mask:
795795
if isinstance(gm_sampler, str):
796796
cortex_mask = db.get_mask(subject, xfmname, type=gm_sampler)

0 commit comments

Comments
 (0)