Hello,
In the case of this simulation of EEG recordings, the source files you get in the database are created directly, they are not the result of an inversion process. The variable ImageGridAmp is set to zero, and only the vertices in the scouts corresponding to a signal in input are set to non-zero values. This is done here:
% Calculate Vert2Grid and Grid2Source matrices
[tmp, HeadModelMat] = process_inverse('SplitHeadModel', HeadModelMat);
% Apply the fixed orientation to the Gain matrix (normal to the cortex)
HeadModelMat.Gain = bst_gain_orient(HeadModelMat.Gain, HeadModelMat.GridOrient, HeadModelMat.GridAtlas);
end
% Number of sources = number of head model columns
nSources = size(HeadModelMat.Gain,2);
% Number of time points: copy from matrix file
nTime = size(sMatrix.Value,2);
% Initialize space matrix
ImageGridAmp = sparse([],[],[],nSources, nTime, sum(cellfun(@length, {sScouts.Vertices}))*nTime);
% Fill matrix
for i = 1:length(sScouts)
% Is this a volume or surface atlas
isVolumeAtlas = panel_scout('ParseVolumeAtlas', AtlasNames{i});
% Get source indices
iSourceRows = bst_convert_indices(sScouts(i).Vertices, nComponents, HeadModelMat.GridAtlas, ~isVolumeAtlas);
% Replicate scout values into all the sources
ImageGridAmp(iSourceRows,:) = repmat(sMatrix.Value(i,:), length(iSourceRows), 1);
end
% Add noise SNR1 (random noise on the sources)
Then this synthetic source maps are multiplied with the forward model to get EEG recordings, and finally noise is added:
strNoise = [',Nsn=', num2str(SNR1)];
else
strNoise = '';
end
% Set unit range to pAm
ImageGridAmp = 1e-9 .* ImageGridAmp;
% === GENERATE DATA MATRIX ===
% Generate data matrix
F = zeros(length(ChannelMat.Channel), nTime);
F(iChannels,:) = HeadModelMat.Gain(iChannels,:) * ImageGridAmp;
% Add noise SNR2 (sensor noise)
if isNoise && (SNR2 > 0)
% Load the noise covariance matrix
NoiseCovMat = load(file_fullpath(sStudyChannel.NoiseCov(1).FileName));
% Compute noise signals from noise covariance matric
xn = get_noise_signals (NoiseCovMat.NoiseCov(iChannels,iChannels), nTime);
xnn = xn./max(max(xn)); % Noise signal between 0 and 1
xns = xnn.*max(max(F(iChannels,:))); % Make the noise of similar amplitude than the signal
% Add noise to recordings
F(iChannels,:) = F(iChannels,:) + SNR2*xns; % Apply the SNR2
Does it answer your question?
Francois
1 Like