def functions_and_metrics(resmat, src, functions, metrics, subject, stctext): """ Iterate over resolution functions and metrics, save metric distributions to STC. Parameters: resmat: array resolution matrix src: instace of SourceSpace The source space to use for metrics (e.g. from forward solution). functions: str 'psf' | 'ctf' The resolution function for which to compute metrics. metrics: list of str The resolution metrics to compute. subject: str The subject name (e.g. 'Sub01'). stctext: str Text for STC filename, function and metric will be pre-pended. Returns: nothing """ # After resolution matrix, compute resolution metrics for function in functions: for metric in metrics: # compute resolution metrics resmet = resolution_metrics(resmat, invop['src'], function=function, metric=metric) # prepend psf/ctf and resolution metric filetext = '%s_%s_%s' % (function, metric, stctext) fname_stc = C.fname_STC(C, C.resolution_subdir, subject, filetext) # save STC with resolution metrics print('Writing resolution metrics to %s.' % fname_stc) resmet.save(fname_stc)
# regularisation parameter snr = 3.0 lambda2 = 1.0 / snr**2 # %% # MNE # --- # Compute resolution matrices, peak localisation error (PLE) for point spread # functions (PSFs), spatial deviation (SD) for PSFs: rm_mne = make_inverse_resolution_matrix(forward, inverse_operator, method='MNE', lambda2=lambda2) ple_mne_psf = resolution_metrics(rm_mne, inverse_operator['src'], function='psf', metric='peak_err') sd_mne_psf = resolution_metrics(rm_mne, inverse_operator['src'], function='psf', metric='sd_ext') del rm_mne # %% # dSPM # ---- # Do the same for dSPM: rm_dspm = make_inverse_resolution_matrix(forward, inverse_operator, method='dSPM',