BrainSpace
BrainSpace copied to clipboard
Matlab - out of memory error for matrix sparsification
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
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.