Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrockhill committed Jul 21, 2021
1 parent 0f7a945 commit 6548510
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
4 changes: 1 addition & 3 deletions mne/gui/_ieeg_locate_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ def _load_electrodes(info):
f'got {coord_frame} for {ch_name}. The easiest way is to '
'use saved locations from this GUI. You may want to solve '
'previous channel locations having the wrong coordinate '
'frame by removing them with '
'`inst.set_montage(mne.channels.make_dig_montage(None), '
'on_missing="ignore")`')
'frame by removing them with `inst.info["dig"] = []`')
chs[ch_name] = ch_coord
return

Expand Down
19 changes: 17 additions & 2 deletions tutorials/clinical/10_ieeg_localize.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,28 @@ def plot_overlay(image, compare, title, thresh=None):
# load electrophysiology data
raw = mne.io.read_raw(op.join(misc_path, 'seeg', 'sample_seeg_ieeg.fif'))

ch_coords = np.array([ch['loc'][:3] for ch in raw.info['chs']])
# load electrode positions from file
elec_df = pd.read_csv(op.join(misc_path, 'seeg', 'sample_seeg_electrodes.tsv'),
sep='\t', header=0, index_col=None)
ch_names = elec_df['name'].tolist()
ch_coords = elec_df[['R', 'A', 'S']].to_numpy(dtype=float)

# create symbolic link to share ``subjects_dir``
seeg_subject_dir = op.join(subjects_dir, 'sample_seeg')
if not op.exists(seeg_subject_dir):
os.symlink(op.join(misc_path, 'seeg', 'sample_seeg'), seeg_subject_dir)

# get fiducial points for our subject from the Talairach transform
# the was computed during the Freesurfer recon-all
lpa, nasion, rpa = mne.coreg.get_mni_fiducials(
'sample_seeg', subjects_dir=subjects_dir)
lpa, nasion, rpa = lpa['r'], nasion['r'], rpa['r']

# create a montage in subject-specific brain space
ch_pos = dict(zip(ch_names, ch_coords / 1000)) # mm -> m
montage = mne.channels.make_dig_montage(
ch_pos, coord_frame='mri', nasion=nasion, lpa=lpa, rpa=rpa)

###############################################################################
# Let's plot the electrode contact locations on the subject's brain.

Expand All @@ -223,7 +238,7 @@ def plot_overlay(image, compare, title, thresh=None):
op.join(misc_path, 'seeg', 'sample_seeg', 'mri', 'brain.mgz'))

# get native to head trans
subj_trans = mne.channels.compute_native_head_t(raw.get_montage())
subj_trans = mne.channels.compute_native_head_t(montage)

# set new montage
raw.set_montage(montage)
Expand Down

0 comments on commit 6548510

Please sign in to comment.