I don't know why I thought the vertices needed to be equidistant yesterday. In setup_volume_source_space,
the volume is setup over a grid. So I can downsample volumes into a grid.
In [1]:
%matplotlib inline
import numpy as np
import nibabel as nib
from mne.datasets import spm_face
# get the aseg file
data_path = spm_face.data_path()
aseg_fname = data_path + '/subjects/spm/mri/aseg.mgz'
# read aseg file using nibabel
aseg = nib.load(aseg_fname)
hdr = aseg.get_header()
dat = aseg.get_data()
# get indices to region of interest
ix = dat == 18
X, Y, Z = np.where(ix)
# create a downsampled grid (5mm spacing)
kernel = np.zeros((5, 5, 5))
kernel[0, 0, 0] = 1
n = np.ceil(256./5.)
grid = np.tile(kernel, (n, n, n))
grid = grid[:256, :256, :256]
# downsample region of interest
x, y, z = np.where(ix*grid)
In [3]:
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
# plot the region of interest
ax = plt.axes(projection='3d')
ax.scatter(X, Y, Z, c='red', alpha=0.1)
ax.scatter(x, y, z, c='blue')
Out[3]:
No comments:
Post a Comment