-
Notifications
You must be signed in to change notification settings - Fork 14
/
osl_forward_model.m
41 lines (34 loc) · 1.24 KB
/
osl_forward_model.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function D = osl_forward_model(D,varargin)
% OSL_FORWARD_MODEL runs MEG forward model in SPM8 or SPM12
%
% D = osl_forward_model(D,S)
%
% REQUIRED INPUTS:
% - D - MEEG object
%
% OPTIONAL INPUTS:
% - forward_meg - Specify forward model for MEG data {'Single Shell',
% 'MEG Local Spheres','Single Sphere'} (default 'Single Shell')
% - forward_eeg - Specify forward model for EEG data
%
% Returns an MEEG object with D.inv contents updated. NOT saved to disk
%
% Ryan Timms, 2021
% Romesh Abeysuriya 2017
% Adam Baker 2014
arg = inputParser;
arg.KeepUnmatched = true;
arg.addParameter('forward_meg','Single Shell',@(x) any(strcmp(x,{'Single Shell','MEG Local Spheres','Single Sphere'})));
arg.addParameter('forward_eeg','EEG BEM');
arg.parse(varargin{:});
if ~isfield(D,'inv')
error('Coregistration should first be run')
end
for i = 1:numel(D.inv{1}.datareg)
if strcmp(D.inv{1}.datareg(i).modality,'MEG')
D.inv{1}.forward(i).voltype = arg.Results.forward_meg;
elseif strcmp(D.inv{1}.datareg(i).modality,'EEG')
D.inv{1}.forward(i).voltype = arg.Results.forward_eeg;
end
end
D = spm_eeg_inv_forward(D);