GithubHelp home page GithubHelp logo

janeliascicomp / sharkviewer Goto Github PK

View Code? Open in Web Editor NEW
22.0 8.0 9.0 322.53 MB

SharkViewer is a web-based viewer for SWC neuron files. It is written entirely in JavaScript using Three.js.

License: Other

HTML 4.07% JavaScript 95.93%

sharkviewer's Introduction

SharkLogo

Badge

Shark Viewer

NEW

09-26-2014 - Synapse Annotations. Load annotations from a separate file with format "x y z\n" for each annotation. You can use annotation_parser(annotation_text) to parse it into the format [{'x': x, 'y': y, 'z':z}, {'x': x1, 'y': y1, 'z':z1}, ..., {'x': xn, 'y': yn, 'z':zn}] and load that into the annotation property of SharkViewer.

08-08-2014 - Three.js loader version: html/js/sharkviewer_loader.js If you want to use the neuron rendered from SharkViewer in another scene use this version. html/Shark_Viewer_Loader_Version.html shows an example of how to use it.

06-18-2014 - Serverless SharkViewer! Now the html/Shark_Viewer.html file allows you to load and view your own SWC files without a server. Simply download the repository and open Shark_Viewer.html in a browser, then use the form to view your own SWC files.

DESCRIPTION

SharkViewer is a web-based viewer for SWC neuron files. It is written entirely in JavaScript using Three.js. To view SWC format guidelines visit: http://research.mssm.edu/cnic/swc.html

EXAMPLE

http://janeliascicomp.github.io/SharkViewer/

QUICK START

  1. Install the dependencies
npm install
  1. Start up a test server
npm run start
  1. Click 'Choose File' button to load a SWC file.

USAGE

AS A MODULE

  1. fetch the package
npm install @janelia/sharkviewer
  1. import
import SharkViewer, { swcParser } from sharkViewer;
  1. Create a new SharkViewer object. At a minimum you need to give it a DOM element to attach a canvas to.
var s = new sharkViewer({ dom_element: 'container' });
  1. Initialize the SharkViewer
s.init();
  1. Animate the SharkViewer
s.animate();
  1. load in a neuron swc file.
const swcJSON = swcParser(swcText);
s.loadNeuron('neuron_name', '#ff0000', swcJSON);

AS A LIBRARY

  1. download this repository
  2. copy lib/shark_viewer.js and lib/three.min.js into your project
  3. Load the javascript files into your page
<script src="three.min.js"></script>
<script src="shark_viewer.js"></script>
  1. Create a new SharkViewer object. At a minimum you need to give it a DOM element to attach a canvas to.
var s = new sharkViewer.default({ swc: swc, dom_element: 'container' });
  1. Initialize the SharkViewer
s.init();
  1. Animate the SharkViewer
s.animate();
  1. Load an SWC file into json. There is a helper function swcParser(swcText) available, or you can write your own to process it server side and load via AJAX.
var swcJSON = sharkViewer.swcParser(swcTxt); ;
s.loadNeuron('neuron_name', '#ff0000', swcJSON);

lib/index.html shows an example of this setup.

sharkViewer.default()

Create a new SharkViewer instance to display a collection of neurons.

Arguments

  • dom_element - html element that will receive the webgl canvas

    • Default: 'container'
  • mode - sphere (full 3-D rendering for nodes and connections, slow), particle (uses particle system to speed rendering and make it look better), or skeleton (no nodes, just connections, very fast)

    • Default: 'particle'
  • show_cones - show cones between cylinders for particle and sphere mode

    • Default: true;
  • colors - color array for display, nodes of type 0 show as first color, etc.

    • Default:
      [
          0x00be9e,
          0x3919cb,
          0x7d0bc4,
          0xff6700,
          0x3eef00,
          0xffce00,
          0xf50027,
          0x606060,
      ]
      
  • metadata - array of javascript objects with labels and type numbers to display as legend (type number matches to type column in swc file) format:

    • Default: false
    • Example:
[{"label":"undefined","type":0},{"label":"soma","type":1}]
  • annotation - array of javascript objects with x, y, z coordinates to display as synapse annotations.
    • Default: false
    • Example:
[{'x': x, 'y': y, 'z':z}, {'x': x1, 'y': y1, 'z':z1}, ..., {'x': xn, 'y': yn, 'z':zn}]
  • annotation_color - color to display annotations

    Default 0x111111

sharkViewer.swcParser(swcText)

Parse SWC files into a JSON format for loading into the viewer.

Arguments

sharkViewer.loadNeuron(name, color, swcJSON, updateCamera)

Load a neuron SWC JSON object into the viewer and center the camera around it.

Arguments

  • name [string]: A simple text string used to identify the object. Used by other functions to remove or hide it.
  • color [string]: Hexadecimal string to determine the color of the neuron.
  • swcJSON [JSON]: JSON string representation of the SWC file. A description of the expected format is shown below.
swc json object: {
    id : {
        type: <type number of node (string)>,
        x: <x position of node (float)>,
        y: <y position of node (float)>,
        z: <z position of node (float)>,
        parent: <id number of node parent (-1 if no parent)>,
        radius: <radius of node (float)>,
    }
}
  • updateCamera [boolean]: If false the camera will not center around the newly added object.

unloadNeuron(name)

Remove the neuron from memory and stop displaying it.

Arguments

  • name [string]: The name used when loading the neuron.

setNeuronVisible(name, visible)

Show or hide the neuron object, without removing it from the scene.

Arguments

  • name [string]: The name used when loading the neuron.
  • visible [boolean]: true to show the neuron, false to hide it.

Author Information

SharkViewer was originally written by Charlotte Weaver ([email protected]) and Christopher Bruns ([email protected])

Contributors

  • Patrick Edson
  • Jody Clements
  • Phillip Hubbard

Janelia Research Campus

Scientific Computing

Janelia Research Campus

Howard Hughes Medical Institute

sharkviewer's People

Contributors

cmbruns avatar csweaver avatar dependabot[bot] avatar hubbardp avatar mhelvens avatar neomorphic avatar wvangeit avatar

Stargazers

 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

sharkviewer's Issues

Color blending no longer working with modular code

The original version of the code would blend the colors of adjoining sections into each other as can be seen in the attached screenshot.
shark_viewer

The new version is no longer doing this. Most likely something in the shader has changed.
shark_viewer

Cyclinders degenerate to planes for certain views

Something seems to be wrong with the "proxies" being used to render the cylinders connecting the spherical nodes in SWC models. For some camera views, the cylinders get squashed, and can even become planes.

screen shot 2019-02-05 at 12 10 11 pm

Cannot render different parts with different colors

When I load test cases old\swc\test.swc in https://janeliascicomp.github.io/SharkViewer/, all parts of the rendered neurons are red, while the default rendered example neurons on the homepage can be marked with different parts using different colors. The content of the test SWC file is as follows:

# ORIGINAL_SOURCE NeuronStudio 0.8.80
# CREATURE
# REGION
# FIELD/LAYER
# TYPE
# CONTRIBUTOR
# REFERENCE
# RAW
# EXTRAS
# SOMA_AREA
# SHINKAGE_CORRECTION 1.0 1.0 1.0
# VERSION_NUMBER 1.0
# VERSION_DATE 2007-07-24
# SCALE 1.0 1.0 1.0
1 1 14.566132 34.873772 7.857000 0.717830 -1
2 0 16.022520 33.760513 7.047000 0.463378 1
3 5 17.542000 32.604973 6.885001 0.638007 2
4 0 19.163984 32.022469 5.913000 0.602284 3
5 0 20.448090 30.822802 4.860000 0.436025 4
6 6 21.897903 28.881084 3.402000 0.471886 5
7 0 18.461960 30.289471 8.586000 0.447463 3
8 6 19.420759 28.730757 9.558000 0.496217 7

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.