コード例 #1
0
# plot the results.

# Get Landmarks from MEG file, 0, 1, and 2 correspond to LPA, NAS, RPA
# and the 'r' key will provide us with the xyz coordinates
pos = np.asarray((raw.info['dig'][0]['r'],
                  raw.info['dig'][1]['r'],
                  raw.info['dig'][2]['r']))


# We use a function from MNE-Python to convert MEG coordinates to MRI space
# for the conversion we use our estimated transformation matrix and the
# MEG coordinates extracted from the raw file. `subjects` and `subjects_dir`
# are used internally, to point to the T1-weighted MRI file: `t1_mgh_fname`
mri_pos = head_to_mri(pos=pos,
                      subject='sample',
                      mri_head_t=estim_trans,
                      subjects_dir=op.join(data_path, 'subjects')
                      )

# Our MRI written to BIDS, we got `anat_dir` from our `write_anat` function
t1_nii_fname = op.join(anat_dir, 'sub-01_ses-01_T1w.nii.gz')

# Plot it
fig, axs = plt.subplots(3, 1)
for point_idx, label in enumerate(('LPA', 'NAS', 'RPA')):
    plot_anat(t1_nii_fname, axes=axs[point_idx],
              cut_coords=mri_pos[point_idx, :],
              title=label)
plt.show()

###############################################################################
コード例 #2
0
                pos = np.asarray(
                    (raw.info['dig'][0]['r'], raw.info['dig'][1]['r'],
                     raw.info['dig'][2]['r']))

                bids_fname = bids_basename + '_meg.fif'
                estim_trans = get_head_mri_trans(
                    bids_fname=bids_fname,  # name of the MEG file
                    bids_root=bids_root  # root of our BIDS dir
                )

                # We use a function from MNE-Python to convert MEG coordinates to MRI space
                # for the conversion we use our estimated transformation matrix and the
                # MEG coordinates extracted from the raw file. `subjects` and `subjects_dir`
                # are used internally, to point to the T1-weighted MRI file: `t1_mgh_fname`
                mri_pos = head_to_mri(pos=pos,
                                      subject=subject,
                                      mri_head_t=estim_trans,
                                      subjects_dir=subjects_dir)

                # Our MRI written to BIDS, we got `anat_dir` from our `write_anat` function
                t1_nii_fname = op.join(
                    anat_dir, 'sub-' + subject + '_acq-t1w_T1w.nii.gz')
                # sub-SB01_acq-t1w_T1w

                # Plot it
                fig, axs = plt.subplots(3, 1)
                for point_idx, label in enumerate(('LPA', 'NAS', 'RPA')):
                    plot_anat(t1_nii_fname,
                              axes=axs[point_idx],
                              cut_coords=mri_pos[point_idx, :],
                              title=label)
                plt.show()