Copy head models to all subjects using script

Hello,
I am trying to fix a script for data pre-processing upto source localization for EEG data from a visual oddball task. I am using MNI template anatomy for all my subjects, which as I understand, means that I need to compute the BEM head model only once which can then be copied to all other subjects.
I am having trouble carrying out the copying head model bit. Fore reference, here is the relevant excerpt from the script:

ComputeHeadModel = bst_process(‘CallProcess’, ‘process_headmodel’, WeightedAverage{subjectNo}, [ ], …
‘Comment’, ‘’, …
‘sourcespace’, 1, … % Cortex surface
‘volumegrid’, struct(…
‘Method’, ‘adaptive’, …
‘nLayers’, 17, …
‘Reduction’, 3, …
‘nVerticesInit’, 4000, …
‘Resolution’, 0.005, …
‘FileName’, []), …
‘meg’, 0, … % Overlapping spheres
‘eeg’, 3, … % OpenMEEG BEM
‘ecog’, 0, … % OpenMEEG BEM
‘seeg’, 0, … % OpenMEEG BEM
‘openmeeg’, struct(…
‘BemFiles’, {{}}, …
‘BemNames’, {{‘Scalp’, ‘Skull’, ‘Brain’}}, …
‘BemCond’, [1, 0.0125, 1], …
‘BemSelect’, [1, 1, 1], …
‘isAdjoint’, 0, …
‘isAdaptative’, 1, …
‘isSplit’, 0, …
‘SplitLength’, 4000), …
‘source_abs’, -1);

Using this piece of script is giving me errors:

iStudyOther = setdiff(unique([WeightedAverage{subjectNo}.iStudy]), WeightedAverage{1}.iStudy);
% Copy the forward model file to the other runs
ComputeHeadModel = bst_get(‘HeadModelForStudy’, WeightedAverage{subjectNo}.iStudy);
for iStudy = iStudyOther
db_add(WeightedAverage{subjectNo}.iStudy, ComputeHeadModel);
end

How exactly do I proceed from here (script structure is such that each run of the iteration corresponds to one subject. There are 30 such subjects)?

Hello,

What errors do you get? Please copy-paste the full error message here.
How did you try debugging this?

Other remarks:

  • I recommend you define WeightedAverage as an array of structures instead of an cell-array of structures (using () indexing instead of {})
  • Avoid using the same variable names for different data types. ComputeHeadModel is first a list of input data files, and then a database entry for a head model file.