Today I made some fixes to mne-python/examples/inverse/plot_subcortical_activation.py and
mne-python/mne/source_spaces.py (see pull request).
There was one really simple fix I'd like to highlight below. For those of you who have used matlab,
you're probably familiar with the find function, which returns indices to a matrix or array for a
given condition. Previously I used ...
import numpy as np
import nibabel as nib
import mne
from mne.datasets import spm_face
data_path = spm_face.data_path()
# get the aseg file
aseg_fname = data_path + '/subjects/spm/mri/aseg.mgz'
# read the aseg file
aseg = nib.load(aseg_fname)
aseg_data, aseg_hdr = aseg.get_data(), aseg.get_header()
ix = aseg_data == 54 # index to the right amygdala
# get the indices in x, y, z space
iix = []
for i in range(ix.shape[0]):
for j in range(ix.shape[1]):
for k in range(ix.shape[2]):
if ix[i, j, k]:
iix.append([i, j, k])
iix = np.array(iix)
print iix
But it turns out there's a way to accomplish all the indexing in one line ...
ix = np.array(np.where(aseg_data == 54)).T
print ix
I also added the option to load the forward solution from file if it already exists, which is
particularly helpful for shortening runtime during development. Most importantly, I
removed the fixed oriention of the subcortical source spaces.
For another large chunk of today, I've been trying to generate simulated MEG data to validate
on. Tomorrow's post will include more details on that. Essentially I'll be modifying and
existing mne example to simulate a cortical source and/or a subjcortical source. Then I'll
make sure that my code detects these sources in the appropriate locations.
No comments:
Post a Comment