Hello,
I currently have a script which automatically imports, sorts, and processes data to automatically compute the inverse solution.
For some of the subjects, all of the dipoles are within the BEM layer. For others, they are not and need to be forced inside. i.e., i get this warning: "WARNING: 4 dipole(s) outside the BEM layer "Brain".
Is there a way for me to implement an if() statement that basically does:
if (dipoles outside Brain BEM layer) {
force inside
else
proceed as normal }
I have searched the forums, and found this post that helped me automatically force dipoles inside the BEM layer, but I cannot find a post that specifcally can help me make an if() statement to check.
Thank you so much for your consideration to help. if more details are needed, please let me know and I will response fast.
Here is the function that computes the head model for a subject, then automatically forces dipoles inside the BEM layer. However, the problem is that some subjects dont require this step--which freezes the loop and I have to manually click to make the process continue.
function headFiles = esiHeadModel(subjectStruct,subNum,epFileMatrix,adaptive)
% subject ID label thing
subjectID_input = subjectStruct.subjectID(subNum);
% store names for epochs so brainstorm knows where to look. using a for
% loop makes it so that we can add more epochs down the line if desired
for i=1:length(epFileMatrix)
headFileTemp = epFileMatrix(i).FileName;
headFileNames{i} = char(headFileTemp);
end
% Process: Compute head model
headFiles = bst_process('CallProcess', 'process_headmodel', headFileNames, [], ...
'Comment', '', ...
'sourcespace', 1, ... % Cortex surface
'meg', 4, ... % OpenMEEG BEM
'eeg', 3, ... % OpenMEEG BEM
'ecog', 2, ... % OpenMEEG BEM
'seeg', 2, ... % OpenMEEG BEM
'openmeeg', struct(...
'BemFiles', {{}}, ...
'BemNames', {{'Scalp', 'Skull', 'Brain'}}, ...
'BemCond', [1, 0.0125, 1], ...
'BemSelect', [1, 1, 1], ...
'isAdjoint', 0, ...
'isAdaptative', adaptive, ...
'isSplit', 0, ...
'SplitLength', 4000), ...
'channelfile', '');
sSubject = bst_get('Subject', subjectID_input{1});
TessFile = sSubject.Surface(sSubject.iCortex).FileName;
EnvFile = sSubject.Surface(sSubject.iInnerSkull).FileName;
tess_force_envelope(TessFile, EnvFile);
end