def roi_index_to_volume_index(roi_indices, brain_mask):
"""Get the 3d index of a voxel given the linear index in a ROI created with the given brain mask.
This is the inverse function of :func:`volume_index_to_roi_index`.
This function is useful if you, for example, have sampling results of a specific voxel
and you want to locate that voxel in the brain maps.
Please note that this function can be memory intensive for a large list of roi_indices
Args:
roi_indices (int or ndarray): the index in the ROI created by that brain mask
brain_mask (str or 3d array): the brain mask you would like to use
Returns:
ndarray: the 3d voxel location(s) of the indicated voxel(s)
"""
mask = autodetect_brain_mask_loader(brain_mask).get_data()
return np.argwhere(mask)[roi_indices, :]
评论列表
文章目录