lrkrol / SEREEGA

SEREEGA: Simulating Event-Related EEG Activity
64 stars 17 forks source link

lf_get_projection bug and fix #3

Closed CPernet closed 6 years ago

CPernet commented 6 years ago

Running the tutorial, but creating multiple sources from radius, I had a problem orienting each source. It was a simple dimension issue, here is a fix (row 83+)

if numel(sourceIdx) > 1
    % iteratively calling this script, returning mean projection
    if size(orientation,1) == 1
        orientation = repmat(orientation,[numel(sourceIdx) 1]);
    end

    for s = 1:numel(sourceIdx)
        projection(s,:) = lf_get_projection(leadfield, sourceIdx(s), 'orientation', orientation(s,:), 'normaliseLeadfield', normaliseLeadfield, 'normaliseOrientation', normaliseOrientation);
    end
    projection = mean(projection, 1);
else
[...]
lrkrol commented 6 years ago

When multiple sources are indicated, the size of orientation should correctly be numel(sourceIdx) x 3, to have one orientation for each source. I have included your fix, but with a warning, to make sure there is no confusion about the number of sources that're being used to generate the projection.