Coder Social home page Coder Social logo

brainspriter's People

Contributors

oganm avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

brainspriter's Issues

Could you please help on abling pixel value?

Hi there,

Thank you very much for making this wrapper and it helps a lot for R users. I am trying to enable "flagValue" and "colormap" such that pixel values could be displayed like the demo here (https://brainsprite.github.io/auto_examples/plot_stat_map.html). However, it only shows "no value" no matter where I click.

image

What I did is just simply hacked brainsprite.R and add "flagValue" and "colormap" in the script. I also added "crosshair" and "colorCrosshair" which works. colormap input is just a png colorbar.

brainsprite_new = function(sprites,
                       spriteHeight = 233,
                       spriteWidth = 189,
                       inputId = tempfile('id') %>% basename,
                       spriteID = tempfile('id') %>% basename,
                       flagCoordinates = FALSE,
                       flagValue = TRUE,
                       crosshair = TRUE,
                       colormap = FALSE,
                       nanValue = T,
                       colorCrosshair = "black",
                       origin = c(0,0,0),
                       fontColor = "#FFFFFF",
                       background = "#000000",
                       overlay = NULL,
                       overlayHeight = NULL,
                       overlayWidth = NULL,
                       overlayID = tempfile('id') %>% basename,
                       overlayOpacity = 0.5,
                       height = NULL,
                       width = NULL){

  script = glue::glue(" $( <spriteID> ).load(function() {
                       var brain = brainsprite({
                       canvas: '<inputId>', // That is the ID of the canvas to build slices into
                       sprite: '<spriteID>', // That is the ID of the sprite image that includes all (sagital) brain slices
                       nbSlice: { 'Y':<spriteHeight> , 'Z':<spriteWidth> },
                       colorBackground: '<background>',
                       colorFont: '<fontColor>',
                       crosshair: '<tolower(crosshair)>',
                       colorCrosshair: '<colorCrosshair>',
                       flagValue: '<tolower(flagValue)>',
                       colormap: '<colormap>',
                       nanValue: '<nanValue>',
                       flagCoordinates: <tolower(flagCoordinates)>
                       "
                      ,.open = '<',.close = '>')

 script = glue::glue(" $( <spriteID> ).load(function() {
                       var brain = brainsprite({
                       canvas: '<inputId>', // That is the ID of the canvas to build slices into
                       sprite: '<spriteID>', // That is the ID of the sprite image that includes all (sagital) brain slices
                       nbSlice: { 'Y':<spriteHeight> , 'Z':<spriteWidth> },
                       colorBackground: '<background>',
                       colorFont: '<fontColor>',
                       crosshair: '<tolower(crosshair)>',
                       colorCrosshair: '<colorCrosshair>',
                       flagValue: '<tolower(flagValue)>',
                       colormap: '<colormap>',
                       nanValue: '<nanValue>',
                       flagCoordinates: <tolower(flagCoordinates)>
                       "
                      ,.open = '<',.close = '>')

I hasn't fully understood how brainspriteR works since I am not familiar with java scrip. It seems one needs to provide a colormap which is same as the one in the overlay image, and pixel value is extracted by reading the RGB value and corresponds to the colorbar range (see below function getValue from brainsprite.js). Could you please help? Thanks

  let getValue = function (rgb, colorMap) {
  // Extract the value associated with a voxel by looking up in a colormap.
    if (!colorMap) {
      return NaN
    }
    let ind = NaN
    let val = Infinity
    const nbColor = colorMap.canvas.width
    const cv = colorMap.context.getImageData(0, 0, nbColor, 1).data
    for (let xx = 0; xx < nbColor; xx++) {
      const dist = Math.abs(cv[xx * 4] - rgb[0]) + Math.abs(cv[xx * 4 + 1] - rgb[1]) + Math.abs(cv[xx * 4 + 2] - rgb[2])
      if (dist < val) {
        ind = xx
        val = dist
      }
    }

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.