neuromaps.resampling.resample_images

neuromaps.resampling.resample_images(src, trg, src_space, trg_space, method='linear', hemi=None, resampling='downsample_only', alt_spec=None)[source]

Resample images src and trg to same space/density with resampling method.

Parameters:
  • src (str or os.PathLike or niimg_like or nib.GiftiImage or tuple) – Input data to be resampled

  • trg (str or os.PathLike or niimg_like or nib.GiftiImage or tuple) – Input data to be resampled

  • src_space (str) – Template space of input data

  • trg_space (str) – Template space of input data

  • method ({'nearest', 'linear'}, optional) – Method for resampling. Specify ‘nearest’ if data are label images. Default: ‘linear’

  • hemi ({'L', 'R'}, optional) – If src and trg are not tuples this specifies the hemisphere the data represent. Default: None

  • resampling (str, optional) – Name of resampling function to resample src and trg. Must be one of: ‘downsample_only’, ‘transform_to_src’, ‘transform_to_trg’, ‘transform_to_alt’. See Notes for more info. Default: ‘downsample_only’

  • alt_spec ((2,) tuple-of-str) – Where entries are (space, density) of desired target space. Only used if resampling=’transform_to_alt’. Default: None

Returns:

src, trg – Resampled images

Return type:

tuple-of-nib.GiftiImage

Notes

The four available resampling strategies will control how src and/or trg are resampled prior to correlation. Options include:

  1. resampling=’downsample_only’

Data from src and trg are resampled to the lower resolution of the two input datasets

  1. resampling=’transform_to_src’

Data from trg are always resampled to match src space and resolution

  1. resampling=’transform_to_trg’

Data from src are always resampled to match trg space and resolution

  1. resampling=’transform_to_alt’

Data from trg and src are resampled to the space and resolution specified by alt_spec (space, density)