|
119 | 119 | end |
120 | 120 | if isempty(DestRowNames) |
121 | 121 | Messages = [Messages, 'AVG> Could not find a common list of rows: Trying to average directly the matrices...' 10 ... |
122 | | - 'AVG> To avoid this warning, uncheck the option "Match signals" in the process options.']; |
| 122 | + 'AVG> To avoid this warning, uncheck the option "Match signals" in the process options.' 10]; |
123 | 123 | end |
124 | 124 | else |
125 | 125 | DestRowNames = []; |
|
180 | 180 | if strcmpi(matName, 'ImageGridAmp') && (sMat.nComponents ~= 1) && ismember(Function, {'norm', 'rms', 'normdiff', 'normdiffnorm'}) |
181 | 181 | sMat = process_source_flat('Compute', sMat, 'rms'); |
182 | 182 | end |
| 183 | + % Connectivity matrix: unpack NxN matrices |
| 184 | + if strcmpi(matName, 'TF') && (length(sMat.RefRowNames) > 1) && isfield(sMat, 'Options') && isfield(sMat.Options, 'isSymmetric') && isequal(sMat.Options.isSymmetric, 1) |
| 185 | + sMat.TF = process_compress_sym('Expand', sMat.TF, length(sMat.RowNames)); |
| 186 | + sMat.Options.isSymmetric = 0; |
| 187 | + end |
183 | 188 |
|
184 | 189 | % Copy additional fields |
185 | 190 | if isfield(sMat, 'nComponents') && ~isempty(sMat.nComponents) |
|
219 | 224 | % Apply default function |
220 | 225 | [matValues, isError] = process_tf_measure('Compute', matValues, sMat.Measure, defMeasure); |
221 | 226 | if isError |
222 | | - Messages = [Messages, 'Error: Invalid measure conversion: ' sMat.Measure ' => ' defMeasure]; |
| 227 | + Messages = [Messages, 'Error: Invalid measure conversion: ' sMat.Measure ' => ' defMeasure, 10]; |
223 | 228 | continue; |
224 | 229 | end |
225 | 230 | end |
|
239 | 244 | RowNames = []; |
240 | 245 | end |
241 | 246 | if isfield(sMat, 'RefRowNames') && ~isempty(sMat.RefRowNames) |
242 | | - RefRowNames = sMat.RefRowNames; |
| 247 | + if ~isempty(DestRowNames) && (length(sMat.RefRowNames) == length(sMat.RowNames)) |
| 248 | + RefRowNames = DestRowNames; |
| 249 | + else |
| 250 | + RefRowNames = sMat.RefRowNames; |
| 251 | + end |
243 | 252 | end |
244 | 253 | if isfield(sMat, 'Events') && ~isempty(sMat.Events) |
245 | 254 | Events = sMat.Events; |
|
250 | 259 | % === CHANNEL ORDER === |
251 | 260 | % Re-order rows in matrix/timefreq files |
252 | 261 | if ~isempty(DestRowNames) && ~isequal(AllRowNames{iFile}, DestRowNames) |
253 | | - tmpValues = zeros(length(DestRowNames), size(matValues,2), size(matValues,3)); |
254 | | - tmpValues(iRowsDest{iFile},:,:) = matValues(iRowsSrc{iFile},:,:); |
255 | | - matValues = tmpValues; |
| 262 | + nTime = size(matValues, 2); |
| 263 | + nFreq = size(matValues, 3); |
| 264 | + % Connectivity files |
| 265 | + if ~isempty(RefRowNames) |
| 266 | + % Reshape TF matrix: [Nrow x Ncol x Ntime x nFreq] |
| 267 | + R = reshape(matValues, [length(sMat.RefRowNames), length(sMat.RowNames), nTime, nFreq]); |
| 268 | + tmpValues = zeros(length(DestRowNames), length(DestRowNames), size(matValues,2), size(matValues,3)); |
| 269 | + tmpValues(iRowsDest{iFile},iRowsDest{iFile},:,:) = R(iRowsSrc{iFile},iRowsSrc{iFile},:,:); |
| 270 | + matValues = reshape(tmpValues, [], nTime, nFreq); |
| 271 | + % Other files |
| 272 | + else |
| 273 | + tmpValues = zeros(length(DestRowNames), nTime, nFreq); |
| 274 | + tmpValues(iRowsDest{iFile},:,:) = matValues(iRowsSrc{iFile},:,:); |
| 275 | + matValues = tmpValues; |
| 276 | + end |
256 | 277 | end |
257 | 278 | % Remove the @filename at the end of the row names (if DestRowNames, this had been done already in process_stdrow) |
258 | 279 | if ~isempty(RowNames) && iscell(RowNames) && isempty(DestRowNames) |
|
416 | 437 | initRowNames = RowNames; |
417 | 438 | % All other files |
418 | 439 | else |
419 | | - % If current matrix has not the same size than the others |
| 440 | + % If current matrix has not the same size as the others |
420 | 441 | if ~isequal([size(MeanValues,1),size(MeanValues,2),size(MeanValues,3)], [size(matValues,1),size(matValues,2),size(matValues,3)]) |
421 | 442 | Messages = [Messages, sprintf('Error: File #%d contains a data matrix that has a different size:\n', iFile)]; |
422 | 443 | if ischar(FilesListA{iFile}) |
423 | 444 | Messages = [Messages, FilesListA{iFile}, 10]; |
424 | 445 | end |
425 | | - continue; |
| 446 | + MeanValues = []; |
| 447 | + break; |
426 | 448 | elseif ~strcmpi(MeanMatName, matName) |
427 | 449 | Messages = [Messages, sprintf('Error: File #%d has a different type. All the result files should be of the same type (full results or kernel-only):\n', iFile)]; |
428 | 450 | if ischar(FilesListA{iFile}) |
|
0 commit comments