Comments (10)
The heavy lifting is in NSViewer. It's actually not that heavy, but it will require generalizing some of the hardcoded coordinate transformations (in the models.Transform class) to handle arbitrary dimensions. This is on the agenda, but probably not very near-term, unless someone else wants to take it on.
from nsviewer.
I wonder if one could punt to nipy to generate a set of ijk -> xyz mappings...
from nsviewer.
Probably, but I'd like to keep this all client-side, since there's no guarantee all end users will have access to nipy. Unless you just mean we should adapt code to do this from nipy, in which case I support this. Although having said that, now that I went and actually looked at the code, there's probably less to this than I thought. Essentially there are just four transformation methods (viewerToAtlas(), atlasToImage(), etc.) that are currently hardcoded for MNI. All that really needs to happen is that these methods should take an extra dimensions argument (passed from the currently active image) and then the values in the transformation matrix need to be computed dynamically.
from nsviewer.
Actually, part of what should happen is that the Image class needs to start storing other information in the Nifti header--e.g., the qform and sform matrices. This is easy enough to do when reading from Nifti using xtk, since all the header info is available. To do it from JSON will require updating the Neurosynth code that generates the JSON file. Although I'm thinking of entirely deprecating the option to load from JSON, just because it involves that extra conversion step (even though it's blazingly fast compared to reading in the binary file).
I think it's probably worth waiting to see what functionality is included in the standalone I/O library that @haehn and the xtk folks are developing (https://github.com/xtk/XIO). I'm guessing it won't include conversions from image space to arbitrary spaces, but it might make sense to build this into that package rather than this one.
from nsviewer.
I don't think nsviewer needs to be able to take data from image coordinates
into an arbitrary space, just into the MNI coordinate system. Nipy has
plotting functions that do this that could serve as inpiration, e.g.:
https://github.com/nipy/nipy/blob/master/nipy/labs/viz_tools/activation_maps.py#L43.
The main idea is that the function takes map
, a 3D array of values and
affine
, a 4x4 matrix that takes you from ijk to some real-world xyz.
Within the Python ecosystem this is pretty straightforward because the
nibabel image object gives you both the data and the corresponding
transformation matrix (which I guess is not always stored as such in the
image header itself).
Copying this division of labor seems right. The image reader should be able
to tell you about the values in the image and how to put them in the MNI
coordinate system, and the viewer app should take those values and that
matrix (or an object that has both attributes) and then draw them properly.
But this might just be obvious noise -- because these issues are so
annoying, I've never thought about them very hard :)
from nsviewer.
Huh! I wonder why reading the binary data is slower than the JSON data; it should be like an order of magnitude faster.
from nsviewer.
@mwaskom Well if you assume that the image is going to pass in the right transformation matrix, then pretty much everything is already set up that way in NSViewer. The various viewerToAtlas() methods are just convenience wrappers around a generic transformCoordinates() method that takes coords and transform matrix as input and returns the result. Currently there's no reason to ever transform an entire image, because painting 2D slices to the HTML5 canvas is fast, and memory is what's at a premium. So in practice the only time these transformation methods get called right now is when, e.g., the user clicks on the screen and we need to index into the right slices in the image.
I don't see any reason to force MNI coordinate system on the user; right now there's no place other than those wrapper transformation methods that hardcode the coordinate system at all. It's no more work to implement a completely dynamic viewer that adjusts the world coordinates to what's specified in the image than to convert to MNI. In other words, there's really only one degree of freedom the image has to tell the viewer about (the xyz <--> ijk mapping), and everything else can be done dynamically. If we go this route, I would much prefer to leave the coordinate system unconstrained so that users can display non-standard images if they like (of course, they'll then need to provide their own anatomical underlay in the same space).
@njvack Yeah, I don't know why that is. I suspect it's mostly overhead from xtk that will hopefully disappear in the refactored I/O code. Although one major difference is that once a volume is initialized (which is fast), the JSON reader only needs to index into values where there's a non-zero value (because of the way the information is represented), whereas the binary reader needs to read every chunk. But given the TypedArray implementation I would still expect the binary reader to be much faster.
from nsviewer.
Thanks for jogging my memory, @mwaskom... though as you can obviously tell, this project is basically dead. What are you using these days for web-based visualization? Papaya.js?
from nsviewer.
I had moved over to Papaya for the project I'd been using nsviewer for originally, but I haven't found much use for web-based viewers lately and mostly stick with older technology (Freeview and FSLView).
from nsviewer.
people still use slicedrop.com and xtk pretty often :) unfortunately i have 0 time to maintain at the moment
from nsviewer.
Related Issues (20)
- Update image/scene parameters from object
- Allow users to set colormap thresholds when loading images HOT 8
- Add colorbrewer palettes
- Link statistical images to 4D data and plot across time at selected voxel HOT 1
- nsviewer fails to display an image properly HOT 4
- current version is broken: example does not work
- De-fuzzing the fuzz HOT 3
- The example link in the README is broken
- Nifti size in nsviewer HOT 14
- Replace array-of-array volume representation with ndarrays HOT 1
- Pre-compute final color image and render only once HOT 3
- Package dependencies properly
- Possibly switch to custom nifti reader HOT 2
- Images not loading HOT 1
- Singleton pattern? HOT 1
- Layers in different colors HOT 2
- Loading progress indicator needed HOT 1
- Slider value doesn't reflect actual handle position
- Table of clusters HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nsviewer.