- eelbrain.morph_source_space(data, subject_to=None, vertices_to=None, morph_mat=None, copy=False, parc=True, xhemi=False, mask=None)
Morph source estimate to a different MRI subject
subject_to (str) – Name of the subject on which to morph (by default this is the same as the current subject for
vertices_to (list of array of int | 'lh' | 'rh') – 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_mat (spmatrix) – The morphing matrix. If
datacontains a whole source space, the morph matrix can be automatically loaded, although providing a cached matrix can speed up processing by a second or two.
copy (bool) – Make sure that the data of
morphed_ndvaris separate from
parc (Union[bool, str]) – Parcellation for target source space. The default is to keep the parcellation from
data. Set to
Falseto 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 in
data, otherwise remove only sourves with
”unknown-*”label (default is True unless
morphed_ndvar – NDVar morphed to the destination subject.
- Return type
morph data from both hemisphere to one for comparing hemispheres
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 of
subject_to, by default a shallow copy of
datais returned. That means that it is not safe to assume that
morphed_ndvarcan be modified in place without altering
data. To make sure the date of the output is independent from the data of the input, set the argument
Generate a symmetric ROI based on a test result (
# 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], 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)