GithubHelp home page GithubHelp logo

neu3d's People

Contributors

chungheng avatar mkturkcan avatar tk-21st avatar vivvyk avatar yiyin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

neu3d's Issues

Dividers in settings

It might be useful to put some dividers (instead of folders which needs to unfold them to see them) to group, for example, opacity settings for highlight mode, opacity settings for pinned mode, size for radius, size for soma radius, size for synapse. This can make the settings for opacity and size a bit more understandable.

Update typing

As title, update typing definition in typings/index.d.ts

addJSON not resolving correctly

addJSON should only resolve when threejs objects have been rendered.

For example, in these lines, the this.loadObjCallback should return a promise. The promise of the addJSON callback should in turn depend on that promise.

The current side effect of this bug is that examples/activity.html bugs out.

Static vs Dynamic Rendering?

Since the scene only contains objects that do not necessarily need to be rendered in an activate animation frame, could we benefit from using static rendering?

The specific changes are:

  1. remove animate() function. Specifically, remove call to requestAnimationFrame().
  2. change TrackBallControl to OrbitControl.

A preliminary test suggests that the performance difference is minimal, but worth a look.

Mouse event changes

  • During Click-and-drag, disable raycaster such that the highlighted neurons remain unchanged as we pan/zoom the camera. Only update raycaster result after click-and-drag event is over
  • Disable adaptive resolution during trackball events to improve performance during zoom/pan

Remove dependency on container.id

This Code Block

    $('#' + this.container.id).on({
      'dragover dragenter': function (e) {
        e.preventDefault();
        e.stopPropagation();
      },
      'drop': function (e) {
        let dataTransfer = e.originalEvent.dataTransfer;
        if (dataTransfer && dataTransfer.files.length) {
          e.preventDefault();
          e.stopPropagation();
          $.each(dataTransfer.files, function (i, file) {
            let reader = new FileReader();
            reader.onload = $.proxy(function (file, event) {
              if (file.name.match('.+(\.swc)$')) {
                let name = file.name.split('.')[0];
                let json = {};
                json[name] = {
                  label: name,
                  dataStr: event.target.result,
                  filetype: 'swc'
                };
                ffbomesh.addJson({ ffbo_json: json });
              }
            }, this, file);
            reader.readAsText(file);
          });
        }
      }
    });

was written to enable drag-dropping files onto the neu3d widget relies on container.id being specified because it uses JQuery.

Change this to use JavaScript's native method, see here

Standarize Data Format

Neu3D currently handles loading data of a few formats, here we standardize the input data formats.

Input format

MorphologyData sent for multiple objects should be a dictionary with the rid of Morphology data as the key,
and each value is a dictionary with the following fields:

  • class: the type of data, e.g., 'Neuron', 'Synapse', 'Neuropil', etc.
  • orid: the rid of the parent node,
  • morph_type: the type of data
    and fields according to the morph_type.

MeshDict Object (output items in MeshDict)

  • ffbo_json: {[rid:string]: data_to_be_loaded}
  • type: 'morphology_json' | 'gltf' | string
  • highlight: boolean
  • visibility: boolean
  • background: boolean
  • color: THREE.Color | string (RGB hex)
  • label: string
  • colormap: string;
  • colororder: 'random' | 'order;
  • showAfterLoadAll: boolean;
  • reset: boolean

if loading from file

  • filename: string
  • filetype: 'json' | 'swc' | 'syn' | 'gltf'

if loading from Obj

  • dataStr: string

Morphology Transformations

The following attributes will be applied to all except gltf files.

  • radius_scale = 1.
  • x_scale = 1.
  • y_scale = 1.
  • z_scale = 1.
  • x_shift = 0.
  • y_shift = 0.
  • z_shift = 0.
  • xy_rot = 0.
  • yz_rot = 0.
  • xz_rot = 0.

Attributes added by _registerObject

  • rid: string
  • object: RenderObj
  • pinned = false
  • position: THREE.Vector3
  • opacity: float

SWC (loadSWCCallBack)

Each row of the swcString is assumed to be a length-7 array with each item corresponding to the following entries

sample type x y z radius parent
int int float float float float int

type

  • 0: undefined
  • 1: soma
  • 2: axon
  • 3: (basal) dendrite
  • 4: apical dendrite
  • 5: custom
  • 6: custom

parent = -1 indicates root

Mesh (loadMeshCallBack)

  • vertices: Array
  • faces: Array

MorphJSON (loadMorphJSONCallBack)

MorphJSON is assumed to be a json of 7 fields (as below) where each field is an array of corresponding items.

sample identifier x y z r parent
int int float float float float int

identifiers used for Neurons:

  • 0: undefined
  • 1: soma

Synapses need to take the special format to start listing all presynaptic sites with parent -1 and followed by postsynaptic sites using sample of its presynaptic sites as parent, e.g.

sample identifier x y z r parent
1 7 float float float float -1
2 7 float float float float -1
3 7 float float float float -1
4 8 float float float float 1
5 8 float float float float 2
6 8 float float float float 3

GLTF (loadGltfCallBack)

  • dataStr

Feature: multiple file upload

Change following code block to enable multiple file upload when clicking on the upload button.

    let fileUploadInput = document.createElement('input');
    fileUploadInput.id = "neu3d-file-upload";
    fileUploadInput.setAttribute("type", "file");
    fileUploadInput.style.visibility = 'hidden';
    fileUploadInput.onchange = (evt) => {
      $.each(evt.target.files, function (i, file) {
        let reader = new FileReader();
        reader.onload = $.proxy(function (file, event) {
          if (file.name.match('.+(\.swc)$')) {
            let name = file.name.split('.')[0];
            let json = {};
            json[name] = {
              label: name,
              dataStr: event.target.result,
              filetype: 'swc'
            };
            ffbomesh.addJson({ ffbo_json: json });
          }
        }, this, file);
        reader.readAsText(file);
      });
    }

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.