Giter VIP home page Giter VIP logo

x's Introduction

The X Toolkit: WebGL™ for Scientific Visualization

  • XTK is easy, lightweight and fast !
  • Native reading of a variety of scientific file formats (see File formats)
  • Volume rendering, thresholding and cross-sectional slicing of 3d image data
  • Label maps, color tables and surface overlays are supported, as well as Constructive Solid Geometry
  • CDash + Google Closure driven build and test system

CS460 at the University of Massachusetts Boston

XTK is being taught as part of the CS460 Computer Graphics course at UMass Boston. All lectures and videos are available at https://cs460.org ! This is part of the BostonGFX (==Graphics for Everybody, #GFX4ALL) initiative.

Demos

lesson00
KneeAtlas
lesson00
FiberAtlas
lesson00
Aneuriskweb
lesson00
BrainAtlas
lesson00
Mindboggle
lesson00
Slice:Drop

Lessons

lesson00 Lesson 00: Hello cube!
The most simple XTK lesson displays a white cube.
lesson01 Lesson 01: Skin the cube and rotate it!
This one adds a texture to the cube and activates spinning.
lesson02 Lesson 02: Constructive Solid Geometry is fun!
Mesh primitives can be combined using boolean operations.
lesson03 Lesson 03: We need more cubes!
One thousand objects are rendered in a single scene.
lesson04 Lesson 04: The magic Porsche!
This lesson loads a mesh from a .STL file and shows off the magic mode.
lesson05 Lesson 05: Rotate the skull!
A visualization of a mesh loaded from a .VTK file.
lesson06 Lesson 06: Connectivity!
Load and render brain fibers from a .TRK file.
lesson07 Lesson 07: One renderer is not enough!
Here multiple 3D renderers are showing the same object with different camera positions.
lesson08 Lesson 08: Surf free!
Loading freesurfer meshes and brain fibers at the same time.
lesson09 Lesson 09: Points to Spheres!
Point data is loaded from a .VTK file and each point is displayed as a sphere.
lesson10 Lesson 10: Slice it!
Load a .NRRD single-file DICOM volume and a segmentation mesh from a .VTK file.
lesson11 Lesson 11: Slice it with colors!
This one loads a .NRRD single-file DICOM volume and the corresponding segmentation as a label map colorized using a color lookup-table.
lesson12 Lesson 12: Curvature!
Here we load a freesurfer mesh (.SMOOTHWM) and different curvature (.CRV) values as an overlay.
lesson13 Lesson 13: I want 2D!
This lesson links three 2D renderers to one 3D renderer and loads a .NRRD single-file DICOM and a label map.
lesson14 Lesson 14: Is it a cube?
Zoom in to see the particles and some great effects!
lesson15 Lesson 15: D-I-C-O-M!
Here we visualize a brain MR scan read from DICOM files.
lesson16 Lesson 16: 10 PRINT 3D
A 3D version of the excellent 10 PRINT pattern showcasing advanced XTK object generation.
lesson17 Lesson 17: (RE)Slice it!
New arbitrary reslicing capabilities. Everything is happening in Real Time!
Leap Motion Ready!

Download

       
Get it right here: xtk.js or include it like this:

<script type="text/javascript" src="https://get.goXTK.com/xtk_edge.js"></script>

Example Usage

// create a new 3d renderer
var r = new X.renderer3D();
r.init();
    
// create a mesh from a .vtk file
var skull = new X.mesh();
skull.file = 'skull.vtk';
    
// add the object
r.add(skull);
    
// .. and render it
r.render();

Check out the live version!

API Documentation

The full documentation of the API is available here.

More information...

...is available at Project X, the X Toolkit wiki system.

Need help?

We use http://stackoverflow.com/questions/tagged/xtk for user support. Please ask and tag ([xtk]) your question there!

Contribute?

Yes, please! See the Developer's Heads Up and the X:Future page.

License

Copyright (c) 2012 The X Toolkit Developers <[email protected]>

The X Toolkit (XTK) is licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php

Publications

  • Hähn D, Rannou N, Ahtam B, Grant PE, Pienaar R: Neuroimaging in the Browser using the X Toolkit. NeuroInformatics, September 2012. Abstract and Poster.
  • more..

Affiliations and Sponsors

Boston Children's Hospital Boston      Harvard Medical School

x's People

Contributors

ahartung avatar edwardsp avatar emilysperanza avatar eriksson avatar fogleman avatar gaiborjosue avatar haehn avatar jmargeta avatar meawoppl avatar nicolasrannou avatar nikai3d avatar ricola3d avatar robinnagpal avatar rudolphpienaar avatar satra avatar srikanthpagadala avatar tyarkoni avatar x-robot avatar zhizhong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

x's Issues

About scenes with several types of objects

Hey Haehn !

Do you remember a few days ago we talked about the copy_ method of XTK's object classes, and more especificaly about the one of object.hs within you intented to copy hierarchy of objects of different types and that didn't work. I've done some researches about it, and like your injection seems to be pre-compilation and Google Closure doens't allow multiple inheritance, I don't see many solutions :

  1. To give up ^^
  2. To remove the copy operator from object.js, slice.js, volume.js, etc... and only let a constructor with 0 arguments and create a new class (for ex X.objectsProcessor) were you do "goog.require"s for every object type and you put 1 method to copy a complex object.

So you've no idea of what's the best.. but for the moment the copying of an X.object doesn't execute and I offered to help to solve that, so what to do ? Give up and only manage homogeneus hierarchies or something harder ?

*-deps not ignored in build.py -so

The -deps files are not ignored when running

python build.py -so

for example:

...

----- FILE : /Users/d/Projects/projectX/sampleApp/sampleApp-deps.js -----
Line 1, E:0110: Line too long (111 characters).
Line 3, E:0110: Line too long (177 characters).
Found 86 errors, including 0 new errors, in 2 files (0 files OK).

Some of the errors reported by GJsLint may be auto-fixable using the script
fixjsstyle. Please double check any changes it makes and report any bugs. The
script can be run by executing:

fixjsstyle -r /Users/d/Projects/projectX/sampleApp -e /Users/d/Projects/projectX/sampleApp/lib -x /Users/d/Projects/projectX/sampleApp/sampleApp/sampleApp-deps.js --strict
Style checked
-----------------------
Enjoy XTK

No goog.require("X.Interactor") in X.Camera for observe() method ?

Mhhh... I think everything is in the title !
I was trying to do an UML of XTK to show how it works to my colleagues and noticed there were no link in google closure between Camera and Interactor, while a Camera observes an Interactor. So is it normal that in "camera.js" there is not any require for "X.interactor" while in the "observe()" methode there is a test "instanceof X.interactor" ?

Best wishes,

Ricola3D

Create X.scene?

we would add all the object in the scene, count them there. Then we can add a scene to a 2D/3D renderer.
the benefit with this approach-> add n items to 1 scene then 1 scene to n renderers
instead of n objects to n renderers

add standard Freesurfer mesh .extensions

in addition to .FSM files, we should be able to detect freesurfer meshed with the default extensions like .smoothwm .pial etc.

To do so, just add the default extensions in X.loader at the bottom:

/**
 * Supported data types by extension.
 * 
 * @enum {Array}
 */
X.loader.extensions = {
  // support for the following extensions and the mapping to X.parsers as well
  // as some custom flags and the result type
  'STL': [X.parserSTL, null, null],
  'VTK': [X.parserVTK, null, null],
  'TRK': [X.parserTRK, null, null],
  'FSM': [X.parserFSM, null, null],
  'NRRD': [X.parserNRRD, null, null],
  'CRV': [X.parserCRV, null, null],
  'MGH': [X.parserMGZ, false, null],
  'MGZ': [X.parserMGZ, true, null],
  'TXT': [X.parserLUT, null, null],
  'LUT': [X.parserLUT, null, null],
  'PNG': [X.parserIMAGE, 'png', 'arraybuffer'], // here we use the arraybuffer
  // response type
  'JPG': [X.parserIMAGE, 'jpeg', 'arraybuffer'],
  'JPEG': [X.parserIMAGE, 'jpeg', 'arraybuffer'],
  'GIF': [X.parserIMAGE, 'gif', 'arraybuffer']
};

Object.js : 'new X[classname]' not passing compilation

Hey Haehn,

Now I'm facing an other issue with the 'new X[classname]' in object.js : at the compilation I've the warning "/home/fabien/X/utils/xtk.js" and after when I try an appli on it (in dev mode it seems to work, but not in compiled mode), it says that it is not a constructor.

Strange bug with shader program under Firefox 11.0 / Ubuntu ?

Hello Haehn !

I'm currently running the lessons on Firefox 11.0 under Ubuntu (a Wibu distribution installed from Windows), and they don't work. Firefox's console tells me :

Could not create shader program! Xtk.js:265
error uniform 'volumeScalarMax' declared as type 'float' and type 'vec3'

And with testing in local in development mode, it also shows this error & one more before :

goog.structs.Map is not a constructor tracer.js:53
Could not create shader program! renderer.js:868
error uniform 'volumeScalarMax' declared as type 'float' and type 'vec3'

In addition, webGL web examples works well here, so I don't understand why XTK doesn't ?!

X.loader use arraybuffer for all parsers

Right now the X.loader only uses arraybuffers for the X.parserIMAGE and string parsing for all other parsers (even binary). It should be faster to switch everything to arraybuffers.

@xtk

Error in renderer2/3D::render_()

Hey,

I post here because I've no idea of what is to change, but in the 2 sub-renderers classes there is written (at the beginning of the 'render_' methods) :

"// call the update_ method of the superclass
goog.base(this, 'render_', picking, invoked);"

So it says it calls 'update_' but it calls 'render_'. And renderer::render_() method is empty no ?

++

Ricola3D

build system shows errors+warnings twice

ce/pretoria/2/chb/users/daniel.haehn/Projects/X/objects/cylinder.js --js /net/pretoria/local_mount/space/pretoria/2/chb/users/daniel.haehn/Projects/X/lib/csg/cube.js --js /net/pretoria/local_mount/space/pretoria/2/chb/users/daniel.haehn/Projects/X/objects/cube.js --warning_level=VERBOSE --compilation_level=ADVANCED_OPTIMIZATIONS
/net/pretoria/local_mount/space/pretoria/2/chb/users/daniel.haehn/Projects/X/visualization/renderer.js:1616: ERROR - variable distanceFromEyeX2 is undeclared
distanceFromEyeX2 = goog.math.Vec3.distance(this._camera.focus(),
^

/net/pretoria/local_mount/space/pretoria/2/chb/users/daniel.haehn/Projects/X/visualization/renderer.js:1621: ERROR - variable distanceFromEyeY is undeclared
distanceFromEyeY = goog.math.Vec3.distance(this._camera.focus(),
^

/net/pretoria/local_mount/space/pretoria/2/chb/users/daniel.haehn/Projects/X/visualization/renderer.js:1625: ERROR - variable distanceFromEyeY2 is undeclared
distanceFromEyeY2 = goog.math.Vec3.distance(this._camera.focus(),
^

/net/pretoria/local_mount/space/pretoria/2/chb/users/daniel.haehn/Projects/X/visualization/renderer.js:1630: ERROR - variable distanceFromEyeZ is undeclared
distanceFromEyeZ = goog.math.Vec3.distance(this._camera.focus(),
^

/net/pretoria/local_mount/space/pretoria/2/chb/users/daniel.haehn/Projects/X/visualization/renderer.js:1634: ERROR - variable distanceFromEyeZ2 is undeclared
distanceFromEyeZ2 = goog.math.Vec3.distance(this._camera.focus(),
^

/net/pretoria/local_mount/space/pretoria/2/chb/users/daniel.haehn/Projects/X/visualization/renderer.js:1637: ERROR - variable lnu is undeclared
lnu = Math.max(distanceFromEyeX, distanceFromEyeY, distanceFromEyeZ,
^

6 error(s), 0 warning(s)
/net/pretoria/local_mount/space/pretoria/2/chb/users/daniel.haehn/Projects/X/lib/closure-library/closure/bin/build/closurebuilder.py: JavaScript compilation failed.

OUTPUT: xtk.js
/net/pretoria/local_mount/space/pretoria/2/chb/users/daniel.haehn/Projects/X/visualization/renderer.js:1616: ERROR - variable distanceFromEyeX2 is undeclared

/net/pretoria/local_mount/space/pretoria/2/chb/users/daniel.haehn/Projects/X/visualization/renderer.js:1621: ERROR - variable distanceFromEyeY is undeclared

/net/pretoria/local_mount/space/pretoria/2/chb/users/daniel.haehn/Projects/X/visualization/renderer.js:1625: ERROR - variable distanceFromEyeY2 is undeclared

/net/pretoria/local_mount/space/pretoria/2/chb/users/daniel.haehn/Projects/X/visualization/renderer.js:1630: ERROR - variable distanceFromEyeZ is undeclared

/net/pretoria/local_mount/space/pretoria/2/chb/users/daniel.haehn/Projects/X/visualization/renderer.js:1634: ERROR - variable distanceFromEyeZ2 is undeclared

/net/pretoria/local_mount/space/pretoria/2/chb/users/daniel.haehn/Projects/X/visualization/renderer.js:1637: ERROR - variable lnu is undeclared

xcode-select: Error: No Xcode folder is set. Run xcode-select -switch <xcode_folder_path> to set the path to the Xcode folder.
Cannot create directory /Testing/Temporary
Cannot create log file: LastSubmit.log
Submit files (using http)
Using HTTP submit method
Drop site:http://cdash.goxtk.com/submit.php?project=xtk
Uploaded: XTKBuild.xml
Submission successful
Error in read script: /chb/users/daniel.haehn/Projects/X/utils/xtk.cmake
Code Compiled

Add getter/setter for X.displayable._type

Right now it is not possible to set the object type externally. This can be fixed by just creating a getter/setter for the X.displayable._type property in injects/displayable.js.

ASCII STL Parsing not working ?

Hi,

I just discovered your API and its features seem to fit my needs, but earlier in the day i tried to simply load and render an ASCII stl file and nothing appeared in the renderer. I tried many stl files of different size and complexity, and I tried to move my camera in case my object was out of view, but there was no change. I tried the same way/code with a trk file and it did well.

I was testing under Chrome 18.0.1025.162 m, without any server emuled (like Wamp or other) and with opening a local file place in a subfolder.

Here is one of my stl examples, i read it and saw no error for an stl format :

"
SOLID TRI
FACET NORMAL 0.0 0.0 -1.0
OUTER LOOP
VERTEX -1.5 -1.5 1.4
VERTEX 0.0 1.7 1.4
VERTEX 1.5 -1.5 1.4
ENDLOOP
ENDFACET
FACET NORMAL 0.0 0.88148 0.472221
OUTER LOOP
VERTEX -1.5 -1.5 1.4
VERTEX 1.5 -1.5 1.4
VERTEX 0.0 0.0 -1.4
ENDLOOP
ENDFACET
FACET NORMAL -0.876814 -0.411007 0.24954
OUTER LOOP
VERTEX 1.5 -1.5 1.4
VERTEX 0.0 1.7 1.4
VERTEX 0.0 0.0 -1.4
ENDLOOP
ENDFACET
FACET NORMAL 0.876814 -0.411007 0.24954
OUTER LOOP
VERTEX 0.0 1.7 1.4
VERTEX -1.5 -1.5 1.4
VERTEX 0.0 0.0 -1.4
ENDLOOP
ENDFACET
ENDSOLID TRI
"

Thanks to the ones who will look after that !

.gitignore more stuff?

It's sometimes annoying when git status lists all the changed *doc and *-build..

Shall we add it to .gitignore?

Keyboard Events

it would be a great improvement if xtks keyboard events would be seperated in "keydown" "keypress" and "keyup".

a) if you want to do something while one key is pressed and held all the time, the onKey gets fired again and again and renders and renders. that's not a good way to do this regarding the performance, i guess.

b) you could bind another mousevent and unbind it by keyup. this gives it more flexibility

regards

Setting simple colors to volumes

Image viewing tools such as MRICRON, allow you to overlay several images and set color to each image individually. The color schemes can be a simple color or a lookup table. It'd nice for XTK to have the same feature.

Handle finger event on mobile browsers

Hi guys!

First, congratulations for your great job!
I would like to request a specific feature for mobiles. It would be great if XTK would be able to handle the interactions of the finger in a mobile browser.
I have found x3Dom that does the job but I prefer XTK by far for the rendering. It may be reimplemented in a same fashion as x3Dom?
I perhaps can do that by myself by I'm lacking some time...

Thanks,
Laurent.

update in cdash

Would be nice if the update field in cdash actually lists the files which were updated.

[Internal] Unused classes ?

Hey,

It's me again ! I've almost finished my UML (or pseudo UML as it's for javascript and it's not perfectly designed) and I've the feeling than X.indexer and X.parserHelper are unused, it that normal ? DId I miss something ? Indexer is required in object.js but never used.

Here also is a little list of things I found that didn't fit well with UML modeling that you probably done to shorten the code, but just to check if it's well the case :

  • HoverEvent and HoverEndEvent from interactor to renderer3D instead of interactor3D to renderer3D
  • RotateEvent from interactor to Camera3D instead of interactor3D to Camera3D
  • ZoomEvent from interactor3D
  • Loadable required in X.object while only used in its descendants
    ..

And finaly a little question : in base.js I found "this._id = window["X.counter"].uniqueId();" but didn't figure out what it was, could you plz tell me where it is defined ?

Sankyu !

Ricola3D

fix visualization tests

create new baseline images if required

also, try to reduce code duplication (dev vs. build)

Make sure everything is loaded in RAS space

.trk files should be converted to RAS by default

also freesurfer meshes are not in RAS afaik

also, is RAS the right one?

XTK is by default a left-handed coordinate space with the Z axis following the thumb and Y going up

Events handling and memory leak ?

Hi,

I wonder something at reading the renderer.js file. I may have misunderstood something (particularly because I'm near a "beginner" in JS), so tell me if I'm wrong :

In renderer.js, when we call init() for a render instance, it creates a new camera and a new render, the renderer now listen their events and then it put references to them in the renderer's attributes.

So every init() call creates a new camera and a new interactor, and while the renderer exists it listen each old interactor (I didn't see any unlisten) created so those variables aren't automatically destroyed at the end of init() no ?

"
// .. listen to resetViewEvents
goog.events.listen(interactor, X.event.events.RESETVIEW,
this.resetViewAndRender.bind(this));
// .. listen to hoverEvents
goog.events.listen(interactor, X.event.events.HOVER, this.onHover.bind(this));
"

Doesn't it provoque a memory leak ? Am I right or totaly wrong ?

Cheers

Don't abort mouse move events when outside of renderer in X.interactor

Right now, the mouse move events get stopped as soon as the mouse travels outside the canvas/viewport. This is not convenient when zooming f.e. a small 2D renderer with the right mouse click and moving the mouse up.

If possible, mouse outside should not cancel the event. It still has to work properly with multiple renderers so.

disable standard mouse events

hello,

how can i disable the mouse events? i want to use very simple mouse events on meshes and slices of a volume and use some ajax-calls there so the integrated events are not needed.

another question: how can i disable the progress bar? i've read it somewhere...
is there any kind of reference where i can see what commands are available?

thanks in advance

__defineGetter__ and __defineSetter__ : to standardize ?

Hey,

I'm back, I've figured my problem and it brought a new question. Just if it is of interest for someone : the setters and getters cannot be called in the source code and then compiled by google closure, it won't work. I think you (Haehn) have figured it out as in renderer3D.js the calls to camera's attributes are not done by the getters/setters but with directly accessing to the attributes "_attributename"

So my new question is : according to the doc, the 2 commands used to define getters and setters (see title) are deprecated and non-standard, so shouldn't we rewrite them with standard methods ?

Clean xtk.js

move stuff to fix safari issue in a function "test?" in base.js constructor
unique id counter would be incremented only when object added to the scene/renderer?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.