osl_ephys.source_recon.rhino.polhemus#
Functions related to polhemus fiducials.
Functions#
|
Get polhemus from fif file. |
|
Extract polhemus from FIF info. |
|
Save MNI fiducials used to calculate sMRI fiducials. |
|
Plot polhemus points. |
|
Interactively delete headshape points. |
|
Remove stray headshape points. |
|
Saves fiducials/headshape from a pos file. |
|
Saves fiducials/headshape from an elc file. |
|
Rescale the x, y, z coordinates of sensors. |
Module Contents#
- osl_ephys.source_recon.rhino.polhemus.get_polhemus_from_info(info, include_eeg_as_headshape=False, include_hpi_as_headshape=True)[source]#
Get polhemus from fif file.
- Parameters:
info (MNE Info object) – Info object.
include_eeg_as_headshape (bool, optional) – Should we include EEG locations as headshape points?
include_hpi_as_headshape (bool, optional) – Should we include HPI locations as headshape points?
- Returns:
polhemus_headshape (np.ndarray) – 3D coordinates for each headshape point.
polhemus_rpa (np.ndarray) – 3D coordinates for rpa.
polhemus_lpa (np.ndarray) – 3D coordinates for lpa.
polhemus_nasion (np.ndarray) – 3D coordinates for nasion.
- osl_ephys.source_recon.rhino.polhemus.extract_polhemus_from_info(fif_file, headshape_outfile, nasion_outfile, rpa_outfile, lpa_outfile, include_eeg_as_headshape=False, include_hpi_as_headshape=True, rescale=None)[source]#
Extract polhemus from FIF info.
Extract polhemus fids and headshape points from MNE raw.info and write them out in the required file format for rhino (in head/polhemus space in mm).
Should only be used with MNE-derived .fif files that have the expected digitised points held in info[‘dig’] of fif_file.
- Parameters:
fif_file (string) – Full path to MNE-derived fif file.
headshape_outfile (string) – Filename to save headshape points to.
nasion_outfile (string) – Filename to save nasion to.
rpa_outfile (string) – Filename to save rpa to.
lpa_outfile (string) – Filename to save lpa to.
include_eeg_as_headshape (bool, optional) – Should we include EEG locations as headshape points?
include_hpi_as_headshape (bool, optional) – Should we include HPI locations as headshape points?
rescale (list, optional) – List containing scaling factors for the x,y,z coordinates of the headshape points and fiducials: [xscale, yscale, zscale].
- osl_ephys.source_recon.rhino.polhemus.save_mni_fiducials(fiducials_file, nasion_outfile, rpa_outfile, lpa_outfile)[source]#
Save MNI fiducials used to calculate sMRI fiducials.
The file must be in MNI space with the following format:
nas -0.5 77.5 -32.6 lpa -74.4 -20.0 -27.2 rpa 75.4 -21.1 -21.9
Note, the first column (fiducial naming) is ignored but the rows must be in the above order, i.e. be (nasion, left, right).
The order of the coordinates is the same as given in FSLeyes.
- Parameters:
fiducials_file (str) – Full path to text file containing the sMRI fiducials.
headshape_outfile (str) – Filename to save nasion to.
nasion_outfile (str) – Filename to save naison to.
rpa_outfile (str) – Filename to save rpa to.
lpa_outfile (str) – Filename to save lpa to.
- osl_ephys.source_recon.rhino.polhemus.plot_polhemus_points(txt_fnames, colors=None, scales=None, markers=None, alphas=None)[source]#
Plot polhemus points.
- Parameters:
txt_fnames (list of strings) – List of filenames containing polhemus points.
colors (list of tuples) – List of colors for each set of points.
scales (list of floats) – List of scales for each set of points.
markers (list of strings) – List of markers for each set of points.
alphas (list of floats) – List of alphas for each set of points.
- osl_ephys.source_recon.rhino.polhemus.delete_headshape_points(recon_dir=None, subject=None, polhemus_headshape_file=None)[source]#
Interactively delete headshape points.
Shows an interactive figure of the polhemus derived headshape points in polhemus space. Points can be clicked on to delete them.
The figure should be closed upon completion, at which point there is the option to save the deletions.
- Parameters:
subjects_dir (string) – Directory containing the subject directories, in the directory structure used by RHINO:
subject (string) – Subject directory name, in the directory structure used by RHINO.
polhemus_headshape_file (string) – Full file path to get the polhemus_headshape_file from, and to save any changes to. Note that this is an npy file containing the (3 x num_headshapepoints) numpy array of headshape points.
Notes
We can call this in two different ways, either:
Specify the subjects_dir AND the subject directory in the directory structure used by RHINO:
delete_headshape_points(recon_dir=recon_dir, subject=subject)
or:
Specify the full path to the .npy file containing the (3 x num_headshapepoints) numpy array of headshape points:
delete_headshape_points(polhemus_headshape_file=polhemus_headshape_file)
- osl_ephys.source_recon.rhino.polhemus.remove_stray_headshape_points(outdir, subject, nose=True)[source]#
Remove stray headshape points.
Removes headshape points near the nose, on the neck or far away from the head.
- Parameters:
outdir (str) – Path to subjects directory.
subject (str) – Subject directory name.
noise (bool, optional) – Should we remove headshape points near the nose? Useful to remove these if we have defaced structurals or aren’t extracting the nose from the structural.
- osl_ephys.source_recon.rhino.polhemus.extract_polhemus_from_pos(outdir, subject, filepath)[source]#
Saves fiducials/headshape from a pos file.
- Parameters:
outdir (str) – Subjects directory.
subject (str) – Subject subdirectory/ID.
filepath (str) – Full path to the .pos file for this subject. Any reference to ‘{subject}’ (or ‘{0}’) is replaced by the subject ID. E.g. ‘data/{subject}/meg/{subject}_headshape.pos’ with subject=’sub-001’ becomes ‘data/sub-001/meg/sub-001_headshape.pos’.
- osl_ephys.source_recon.rhino.polhemus.extract_polhemus_from_elc(outdir, subject, filepath, remove_headshape_near_nose=False)[source]#
Saves fiducials/headshape from an elc file.
- Parameters:
outdir (str) – Subjects directory.
subject (str) – Subject subdirectory/ID.
filepath (str) – Full path to the .elc file for this subject. Any reference to ‘{subject}’ (or ‘{0}’) is replaced by the subject ID. E.g. ‘data/{subject}/meg/{subject}_headshape.elc’ with subject=’sub-001’ becomes ‘data/sub-001/meg/sub-001_headshape.elc’.
remove_headshape_near_nose (bool, optional) – Should we remove any headshape points near the nose?
- osl_ephys.source_recon.rhino.polhemus.rescale_sensor_positions(fif_file, xscale=1, yscale=1, zscale=1)[source]#
Rescale the x, y, z coordinates of sensors.
- Parameters:
fif_file (str) – Path to fif file.
xscale (float, optional) – x coordinate scale factor.
yscale (float, optional) – y coordinate scale factor.
zscale (float, optional) – z coordinate scale factor.