Skip to content

Commit 0d8b22c

Browse files
FIX - solved regression error in source.trial handling, detected using test_bug2381
1 parent f7de187 commit 0d8b22c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

utilities/ft_datatype_source.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@
128128
if isfield(source, 'zgrid')
129129
source = rmfield(source, 'zgrid');
130130
end
131+
132+
if isfield(source, 'avg') && isstruct(source.avg) && isfield(source, 'trial') && isstruct(source.trial) && ~isempty(intersect(fieldnames(source.avg), fieldnames(source.trial)))
133+
% it is not possible to convert both since they have the same field names
134+
ft_warning('removing ''avg'', keeping ''trial''');
135+
source = rmfield(source, 'avg');
136+
end
131137

132138
if isfield(source, 'avg') && isstruct(source.avg)
133139
% move the average fields to the main structure

0 commit comments

Comments
 (0)