neurosynth / nsviewer

Neurosynth viewer
28 stars 22 forks source link

De-fuzzing the fuzz #17

Open njvack opened 10 years ago

njvack commented 10 years ago

Hey Tal,

I've been looking into how to get rid of the overlap artifacts that happen with zooming and transparent layers, and I think I have a pretty good handle on it.

My plan would be to have each view have its own array of layers and its own canvas, draw the pixels directly to it (with color mapping done at this step), and then use drawImage() to blit the layer to the View's canvas.

If I were to work up a PR along these lines, would you be receptive?

tyarkoni commented 10 years ago

That sounds good to me. My only real concern with refactoring the models is to make sure that performance doesn't get worse. Right now the viewer unnecessarily paints each visible layer directly to the on-screen canvas, which makes it very unresponsive as soon as you have 3 or 4 layers. I can't tell if your approach will fix that (it sounds like there will still be the same number of pixel-drawing operations), but it doesn't seem like it will make it any worse, so go for it!

njvack commented 10 years ago

Well... I have ideas about performance, too :)

Most notably, I'd like to replace nested js arrays with strided, typed arrays (see https://github.com/mikolalysenko/ndarray), mapping the full-range data to byte arrays. Then color mapping and thresholding can both be done by indexing into a 256-element array.

See https://github.com/mikolalysenko/ndarray-experiments for benchmarks of different techniques...

njvack commented 10 years ago

But! Note that I do not want to make that major of a change in this PR. That's its own can of worms.