npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ui-tractview

v1.0.2

Published

tracts viewer

Readme

ui-tractview

HTML5 Tract Viewer - Used to visualize output from AFQ

Preview Image

Install

Install for general purpose use

npm install ui-tractview

Include script dependencies in your index.html file:

<!-- Dep Scripts -->
<script type="text/javascript" src="node_modules/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="node_modules/three/build/three.min.js"></script>
<script type="text/javascript" src="node_modules/three/examples/js/loaders/VTKLoader.js"></script>
<script type="text/javascript" src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>

<!-- Main Scripts -->
<script type="text/javascript" src="node_modules/ui-tractview/js/OrbitControls.js"></script>
<script type="text/javascript" src="node_modules/ui-tractview/js/tractview.js"></script>

<!-- Dep Styles -->
<link rel="stylesheet" type="text/css" href="node_modules/bootstrap/dist/css/bootstrap.min.css" />

Include your main.js file inside index.html:

<script type="text/javascript" src="js/main.js"></script>

Create an element to append tractview controls to:

<div id='tractviewer' style='position:relative; width:100vw; height: 100vh;'></div>

An explicit width/height for this element is not required, notice that above we just set it to the full window width/height.

Inside main.js, on window load, init the tract viewer:

$(function(){
    TractView.init({
        selector: '#tractviewer',
        num_tracts: 20,
        preview_scene_path: 'node_modules/ui-tractview/models/brain.json',
        
        get_json_file: function(tractNumber) {
            return 'path_to_json_files/' + encodeURIComponent(tractNumber + ".json");
        }
    });
});

selector represents the query selector for the element that will contain the tract viewer.

num_tracts is the number of tracts that your model contains.

preview_scene_path is the (optional) path to a json scene which displays the orientation of the model. You can either not use previewing by not including this parameter, use ours which is node_modules/ui-tractview/models/brain.json (displayed as the tiny brain in the above image, in the lower left hand corner), or include your own.

get_json_file is a function that takes in a tract number to load, and returns the path to that respective tract. A tract's JSON file should have the following layout:

{
    "name": "Left Thalamic Radiation",      // If a name begins with Left/Right, it will be respectively prioritized in the tract viewer controls
    "color": [0.2081, 0.1663, 0.5292],      // [r, g, b] ranging from 0 to 1 each
    "coords": [                             // list of tracts
        [
            [-21.69491386, -21.64446831, -21.4675293, ...],  // list of x coordinates
            [43.13895035, 42.14380264, 41.15979385, ...],    // list of y coordinates
            [1.224040627, 1.165375113, 1.165637732, ...]     // list of z coordinates
        ],
        [
            ...
        ],
        ...
    ]
}

If you are generating an output from AFQ in Matlab, you can use savejson and a script similar to the following in order to create a list of output json files:

[fg_classified,~,classification] = AFQ_SegmentFiberGroups(config.dt6, fg, [], [], false);
tracts = fg2Array(fg_classified);
mkdir('tracts');
cm = parula(length(tracts));
for it = 1:length(tracts)
  tract.name   = tracts(it).name;
  tract.color  = cm(it,:);
  tract.coords = tracts(it).fibers;
  savejson('', tract, fullfile('tracts',sprintf('%i.json',it)));
end