eelbrain.morph_source_space
- eelbrain.morph_source_space(data, subject_to=None, vertices_to=None, morph=None, copy=False, parc=True, xhemi=False, mask=None)
Morph source estimate to a different MRI subject
- Parameters:
data (NDVar | SourceSpace) – NDVar with SourceSpace dimension.
subject_to (str) – Name of the target MRI subject (by default, this is the same as the current subject for
xhemimorphing).vertices_to (list | str) – The vertices on the destination subject’s brain. If
datacontains a whole source space, vertices_to can be automatically loaded, although providing them as argument can speed up processing by a second or two. Use'lh'or'rh'to target vertices from only one hemisphere.morph (spmatrix | SourceMorph) – A pre-computed morph matrix to speed up processing.
copy (bool) – Make sure that the data of
morphed_ndvaris separate fromdata(default False).parc (bool | str) – Parcellation for target source space. The default is to keep the parcellation from
data. Set toFalseto load no parcellation. If the annotation files are missing for the target subject an IOError is raised.xhemi (bool) – Mirror hemispheres (i.e., project data from the left hemisphere to the right hemisphere and vice versa).
mask (bool) – Restrict output to known sources. If the parcellation of
datais retained keep only sources with labels contained indata, otherwise remove only sources with”unknown-*”label (default is True for surface source space data, unlessvertices_tois specified, and False for volume source space data).
- Returns:
morphed_ndvar – NDVar morphed to the destination subject.
- Return type:
See also
xhemimorph data from both hemisphere to one for comparing hemispheres
Notes
This function is used to make sure a number of different NDVars are defined on the same MRI subject and handles scaled MRIs efficiently. If the MRI subject on which
datais defined is a scaled copy ofsubject_to, by default a shallow copy ofdatais returned. That means that it is not safe to assume thatmorphed_ndvarcan be modified in place without alteringdata. To make sure the date of the output is independent from the data of the input, set the argumentcopy=True.Examples
Generate a symmetric ROI based on a test result (
res):# Generate a mask based on significance mask = res.p.min('time') <= 0.05 # store the vertices for which we want the end result fsa_vertices = mask.source.vertices # morphing is easier with a complete source space mask = complete_source_space(mask) # Use a parcellation that is available for the ``fsaverage_sym`` brain mask = set_parc(mask, 'aparc') # morph both hemispheres to the left hemisphere mask_from_lh, mask_from_rh = xhemi(mask) # take the union; morphing interpolates, so re-cast values to booleans mask_lh = (mask_from_lh > 0) | (mask_from_rh > 0) # morph the new ROI to the right hemisphere mask_rh = morph_source_space(mask_lh, vertices_to=[[], mask_lh.source.vertices[0]], xhemi=True) # cast back to boolean mask_rh = mask_rh > 0 # combine the two hemispheres mask_sym = concatenate([mask_lh, mask_rh], 'source') # morph the result back to the source brain (fsaverage) mask = morph_source_space(mask_sym, 'fsaverage', fsa_vertices) # convert to boolean mask (morphing involves interpolation, so the output is in floats) mask = round(mask).astype(bool)