@@ -2189,17 +2189,35 @@ function LoadResultsMatrix(iDS, iResult)
21892189 % ===== GET RESULTS VALUES =====
21902190 % === FULL RESULTS ===
21912191 if ~isempty(GlobalData .DataSet(iDS ).Results(iResult ).ImageGridAmp)
2192- % Get ImageGridAmp interesting sub-part
2193- if isempty(iRows )
2194- ResultsValues = double(GlobalData .DataSet(iDS ).Results(iResult ).ImageGridAmp(: , iTime ));
2195- if ~isempty(GlobalData .DataSet(iDS ).Results(iResult ).Std)
2196- Std = double(GlobalData .DataSet(iDS ).Results(iResult ).Std(: , iTime , : , : ));
2192+ % ImageGridAmp = [nSources, nTimes]
2193+ if isnumeric(GlobalData .DataSet(iDS ).Results(iResult ).ImageGridAmp)
2194+ % Get ImageGridAmp interesting sub-part
2195+ if isempty(iRows )
2196+ ResultsValues = double(GlobalData .DataSet(iDS ).Results(iResult ).ImageGridAmp(: , iTime ));
2197+ if ~isempty(GlobalData .DataSet(iDS ).Results(iResult ).Std)
2198+ Std = double(GlobalData .DataSet(iDS ).Results(iResult ).Std(: , iTime , : , : ));
2199+ end
2200+ else
2201+ ResultsValues = double(GlobalData .DataSet(iDS ).Results(iResult ).ImageGridAmp(iRows , iTime ));
2202+ if ~isempty(GlobalData .DataSet(iDS ).Results(iResult ).Std)
2203+ Std = double(GlobalData .DataSet(iDS ).Results(iResult ).Std(iRows , iTime , : , : ));
2204+ end
21972205 end
2198- else
2199- ResultsValues = double(GlobalData .DataSet(iDS ).Results(iResult ).ImageGridAmp(iRows , iTime ));
2200- if ~isempty(GlobalData .DataSet(iDS ).Results(iResult ).Std)
2201- Std = double(GlobalData .DataSet(iDS ).Results(iResult ).Std(iRows , iTime , : , : ));
2206+ % ImageGridAmp = {[nSources,a], [a,b], [b, nTimes]}
2207+ elseif iscell(GlobalData .DataSet(iDS ).Results(iResult ).ImageGridAmp)
2208+ % Get ImageGridAmp interesting sub-part
2209+ ResultsValues = GlobalData .DataSet(iDS ).Results(iResult ).ImageGridAmp;
2210+ assert(isempty(GlobalData .DataSet(iDS ).Results(iResult ).Std), ' Storing Std a cell is not supported yet.' )
2211+ ResultsValues{end } = ResultsValues{end }(: , iTime );
2212+
2213+ if ~isempty(iRows )
2214+ ResultsValues{1 } = ResultsValues{1 }(iRows , : );
22022215 end
2216+
2217+ % Compute full results
2218+ ResultsValues = double(bst_multiply_cellmat(ResultsValues ));
2219+ % Std should be empty if ImageGridAmp is a cell
2220+ Std = [];
22032221 end
22042222 % === KERNEL ONLY ===
22052223 elseif ~isempty(GlobalData .DataSet(iDS ).Results(iResult ).ImagingKernel)
@@ -2586,13 +2604,29 @@ function LoadResultsMatrix(iDS, iResult)
25862604 [maxGFP , iMax ] = max(GFP );
25872605 % Get the results values at this particular time point
25882606 sources = GetResultsValues(iDS , iResult , [], iMax );
2607+ % Store minimum and maximum of displayed data
2608+ DataMinMax = [min(sources(: )), max(sources(: ))];
25892609 % Full results
25902610 else
2591- % Get the maximum on the full results matrix
2592- sources = GlobalData .DataSet(iDS ).Results(iResult ).ImageGridAmp;
2611+ % Get the maximum on the full results matrix (process by time blocks)
2612+ nSamples = GlobalData .DataSet(iDS ).Results(iResult ).NumberOfSamples;
2613+ if isnumeric(GlobalData .DataSet(iDS ).Results(iResult ).ImageGridAmp)
2614+ nSources = size(GlobalData .DataSet(iDS ).Results(iResult ).ImageGridAmp, 1 );
2615+ elseif iscell(GlobalData .DataSet(iDS ).Results(iResult ).ImageGridAmp)
2616+ nSources = size(GlobalData .DataSet(iDS ).Results(iResult ).ImageGridAmp{1 }, 1 );
2617+ end
2618+ ProcessOptions = bst_get(' ProcessOptions' );
2619+ MaxSizeDouble = ProcessOptions .MaxBlockSize;
2620+ blockSize = max(floor(MaxSizeDouble / nSources ), 1 );
2621+ nBlocks = ceil(nSamples / blockSize );
2622+ DataMinMax = [Inf , - Inf ];
2623+ for iBlock = 1 : nBlocks
2624+ iTime = [((iBlock - 1 ) * blockSize + 1 ) : min(iBlock * blockSize , nSamples )];
2625+ sources = GetResultsValues(iDS , iResult , [], iTime );
2626+ DataMinMax(1 ) = min(DataMinMax(1 ), min(sources(: )));
2627+ DataMinMax(2 ) = max(DataMinMax(2 ), max(sources(: )));
2628+ end
25932629 end
2594- % Store minimum and maximum of displayed data
2595- DataMinMax = [min(sources(: )), max(sources(: ))];
25962630end
25972631
25982632
0 commit comments