BrainSpace icon indicating copy to clipboard operation
BrainSpace copied to clipboard

Matlab - out of memory error for matrix sparsification

Open manea006 opened this issue 3 years ago • 1 comments

For very large matrices I had an out of memory error at this line. Matlab memory usage was much lower than the total memory available. However, with the following replacement it worked.

p = prctile(data, p.Results.sparsity);
for i = 1: length(data)
	col = data(:, i);
	col(col<p) = 0;
	data(:, i) = col;
end

manea006 avatar Jan 11 '21 16:01 manea006

Ah, the CPU vs. memory trade-off. The current BrainSpace implementation should run faster whereas your proposed solution should be more memory efficient. Speed probably isn't much of an issue in this particular case though. I'll mark this as a future enhancement.

ReinderVosDeWael avatar Jan 11 '21 16:01 ReinderVosDeWael