Commit 243724bb authored by r03ert0's avatar r03ert0

fix case sensitivity

parent 0375b551
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"1.2.3.4": true,
"2.3.4.5": true
}
{
"1.2.3.4": true,
"2.3.4.5": true
}
/**
* @page AtlasMaker: Image Drawing
*/
var AtlasMakerDraw = {
/**
* @function resizeWindow
*/
resizeWindow: function resizeWindow() {
var me=AtlasMakerWidget;
var l=me.traceLog(resizeWindow,1);if(l)console.log.apply(undefined,l);
var wH=me.container.height();
var wW=me.container.width();
var wAspect=wW/wH;
var bAspect=me.brain_W*me.brain_Wdim/(me.brain_H*me.brain_Hdim);
/*
if(me.editMode==1) {
*/
// In edit mode width or height can be fixed to 100%
// depending on the slice and container aspect ratio
if(wAspect>bAspect)
$('#resizable').css({width:(100*bAspect/wAspect)+'%',height:'100%'});
else
$('#resizable').css({width:'100%',height:(100*wAspect/bAspect)+'%'});
/*
} else {
// In display mode slice width is always fixed to 100%
$('#resizable').css({width:'100%',height:(100*wAspect/bAspect)+'%'});
// Slice height cannot be larger than window's inner height:
var sliceH=me.container.height();
var windowH=window.innerHeight;
if(sliceH>windowH) {
var f=windowH/sliceH;
$('#resizable').css({width:(f*100)+'%',height:f*(100*wAspect/bAspect)+'%'});
}
}
*/
},
/**
* @function configureBrainImage
*/
configureBrainImage: function configureBrainImage() {
var me=AtlasMakerWidget;
var l=me.traceLog(configureBrainImage);if(l)console.log.apply(undefined,l);
if(me.User.view==null)
me.User.view="sag";
var s2v=me.User.s2v;
switch(me.User.view) {
case 'sag': me.brain_W=s2v.sdim[1]; me.brain_H=s2v.sdim[2]; me.brain_D=s2v.sdim[0]; me.brain_Wdim=s2v.wpixdim[1]; me.brain_Hdim=s2v.wpixdim[2]; break; // sagital
case 'cor': me.brain_W=s2v.sdim[0]; me.brain_H=s2v.sdim[2]; me.brain_D=s2v.sdim[1]; me.brain_Wdim=s2v.wpixdim[0]; me.brain_Hdim=s2v.wpixdim[2]; break; // coronal
case 'axi': me.brain_W=s2v.sdim[0]; me.brain_H=s2v.sdim[1]; me.brain_D=s2v.sdim[2]; me.brain_Wdim=s2v.wpixdim[0]; me.brain_Hdim=s2v.wpixdim[1]; break; // axial
}
me.canvas.width=me.brain_W;
me.canvas.height=me.brain_H*me.brain_Hdim/me.brain_Wdim;
me.brain_offcn.width=me.brain_W;
me.brain_offcn.height=me.brain_H;
me.brain_px=me.brain_offtx.getImageData(0,0,me.brain_offcn.width,me.brain_offcn.height);
if(me.User.slice==null || me.User.slice>=me.brain_D-1)
me.User.slice=parseInt(me.brain_D/2);
me.sendUserDataMessage(JSON.stringify({'view':me.User.view,'slice':me.User.slice}));
// configure toolbar slider
$(".slider#slice").data({max:me.brain_D-1,val:me.User.slice});
if($("#slice .thumb")[0]) $("#slice .thumb")[0].style.left=(me.User.slice/(me.brain_D-1)*100)+"%";
me.drawImages();
me.initCursor();
},
/**
* @function configureAtlasImage
*/
configureAtlasImage: function configureAtlasImage() {
var me=AtlasMakerWidget;
var l=me.traceLog(configureAtlasImage);if(l)console.log.apply(undefined,l);
// has to be run *after* configureBrainImage
me.atlas_offcn.width=me.brain_W;
me.atlas_offcn.height=me.brain_H;
me.atlas_px=me.atlas_offtx.getImageData(0,0,me.atlas_offcn.width,me.atlas_offcn.height);
},
/**
* @function nearestNeighbour
*/
nearestNeighbour: function nearestNeighbour(ctx) {
var me=AtlasMakerWidget;
var l=me.traceLog(nearestNeighbour,1);if(l)console.log.apply(undefined,l);
ctx.imageSmoothingEnabled = false;
ctx.mozImageSmoothingEnabled = false;
},
/**
* @function computeSegmentedVolume
*/
computeSegmentedVolume: function computeSegmentedVolume() {
var me=AtlasMakerWidget;
var l=me.traceLog(computeSegmentedVolume,1);if(l)console.log.apply(undefined,l);
var i,sum=0;
var data=me.atlas.data;
var dim=me.atlas.dim;
for(i=0;i<dim[0]*dim[1]*dim[2];i++) {
if(data[i]>0)
sum++;
}
return sum*me.User.pixdim[0]*me.User.pixdim[1]*me.User.pixdim[2];
},
/**
* @function displayInformation
* @desc Overlays text and vectorial information on top of the annotation volume slice. Text information is added from the AtlasMakerWidget.info object. Vectorial information is displayed using svg format
*/
displayInformation: function displayInformation() {
var me=AtlasMakerWidget;
var l=me.traceLog(displayInformation,1);if(l)console.log.apply(undefined,l);
me.info.slice=me.User.slice;
var i=0,str;
var text=me.container.find("#text-layer");
var vector=me.container.find("#vector-layer");
str="";
for(var k in me.info) {
str+="<span>"+k+": "+me.info[k]+"</span><br/>";
}
text.html(str);
str="";
if(me.User.measureLength) {
var W=parseFloat($('#atlasmaker canvas').css('width'));
var w=parseFloat($('#atlasmaker canvas').attr('width'));
var zx=W/w,zy=zx*me.brain_Hdim/me.brain_Wdim,p=me.User.measureLength,str1;
var W=parseFloat($('#atlasmaker canvas').css('width'));
var w=parseFloat($('#atlasmaker canvas').attr('width'));
str1="M"+zx*p[0].x+","+zy*p[0].y;
for(i=1;i<p.length;i++)
str1+="L"+zx*p[i].x+","+zy*p[i].y;
str+=[ "<circle fill='#00ff00' cx="+zx*p[0].x+" cy="+zy*p[0].y+" r=3 />",
"<path stroke='#00ff00' fill='none' d='"+str1+"'/>",
(i>0)?"<circle fill='#00ff00' cx="+zx*p[i-1].x+" cy="+zy*p[i-1].y+" r=3 />":""].join("\n");
}
vector.html(str);
},
/**
* @function drawImages
*/
drawImages: function drawImages() {
var me=AtlasMakerWidget;
var l=me.traceLog(drawImages,1);if(l)console.log.apply(undefined,l);
if(me.brain_img.img
&& me.flagLoadingImg.view
&& me.flagLoadingImg.slice) {
me.context.clearRect(0,0,me.context.canvas.width,me.canvas.height);
me.displayInformation();
me.nearestNeighbour(me.context);
me.context.drawImage(me.brain_img.img,0,0,me.brain_W,me.brain_H*me.brain_Hdim/me.brain_Wdim);
me.drawAtlasImage(me.flagLoadingImg.view,me.flagLoadingImg.slice);
}
if(!me.brain_img.img || me.brain_img.view!=me.User.view || me.brain_img.slice!=me.User.slice) {
me.sendRequestSliceMessage();
}
},
/**
* @function drawAtlasImage
*/
drawAtlasImage: function drawAtlasImage(view,slice) {
var me=AtlasMakerWidget;
var l=me.traceLog(drawAtlasImage,1);if(l)console.log.apply(undefined,l);
if(!me.atlas)
return;
var data=me.atlas.data;
var dim=me.atlas.dim;
var s,val;
ys=yc=ya=slice;
for(y=0;y<me.brain_H;y++)
for(x=0;x<me.brain_W;x++) {
switch(view) {
case 'sag':s=[ys,x,me.brain_H-1-y]; break;
case 'cor':s=[x,yc,me.brain_H-1-y]; break;
case 'axi':s=[x,me.brain_H-1-y,ya]; break;
}
i=me.S2I(s,me.User);
var c=me.ontologyValueToColor(data[i]);
var alpha=(data[i]>0)?255:0;
i=(y*me.atlas_offcn.width+x)*4;
me.atlas_px.data[ i ] =c[0];
me.atlas_px.data[ i+1 ]=c[1];
me.atlas_px.data[ i+2 ]=c[2];
me.atlas_px.data[ i+3 ]=alpha*me.alphaLevel;
}
me.atlas_offtx.putImageData(me.atlas_px, 0, 0);
me.nearestNeighbour(me.context);
me.context.drawImage(me.atlas_offcn,0,0,me.brain_W,me.brain_H*me.brain_Hdim/me.brain_Wdim);
}
};
This diff is collapsed.
This diff is collapsed.
/**
* @page AtlasMaker: User Interface Elements
*/
var AtlasMakerUI = {
/**
* @function slider
*/
slider: function slider(elem,callback) {
var me=AtlasMakerWidget;
var l=me.traceLog(slider,2);if(l)console.log.apply(undefined,l);
// Initialise a 'slider' control
$(elem).data({
drag:false,
val:0,
max:100
});
var movex=function(el,clientX) {
if ($(el).data("drag")==true) {
var R=$(el).find(".track")[0].getBoundingClientRect();
var x=(clientX-R.left)/R.width;
if(x<0) x=0;
if(x>1) x=1;
x=x*$(el).data("max");
if(x!=$(el).data("val")) {
callback(x);
}
}
};
$(document).on("mousemove",function from_slider(ev){movex(elem,ev.clientX);});
$(document).on("touchmove",function from_slider(ev){movex(elem,ev.originalEvent.changedTouches[0].pageX);});
$(document).on("mouseup touchend",function from_slider(){$(elem).data({drag:false})});
$(elem).on('mousedown touchstart',function from_slider(){$(elem).data({drag:true})});
},
/**
* @function chose
*/
chose: function chose(elem,callback) {
// Initialise a 'chose' control
var ch=$(elem).find(".a");
ch.each(function(c,d){
$(d).click(function(){
if($(this).hasClass("pressed")) {
callback($(this).attr('title'));
return;
}
ch.each(function(){$(this).removeClass("pressed")});
$(this).addClass("pressed");
if(callback)
callback($(this).attr('title'));
});
});
},
/**
* @function toggle
*/
toggle: function toggle(elem,callback) {
// Initialise a 'toggle' control
$(elem).click(function(){
$(this).hasClass("pressed")?$(this).removeClass("pressed"):$(this).addClass("pressed");
if(callback)
callback($(this).hasClass("pressed"));
});
},
/**
* @function push
*/
push: function push(elem,callback) {
// Initialise a 'push' control
$(elem).click(function(){
if(callback)
callback();
});
}
};
\ No newline at end of file
/*global AtlasMakerWidget $*/
/*! AtlasMaker: Image Drawing */
/**
* @page AtlasMaker: Image Drawing
* @returns object
*/
export var AtlasMakerDraw = {
/**
* @function resizeWindow
* @returns {void}
*/
resizeWindow: function resizeWindow() {
const me = AtlasMakerWidget;
const wH = me.container.height();
const wW = me.container.width();
const wAspect = wW/wH;
const bAspect = me.brain_W*me.brain_Wdim/(me.brain_H*me.brain_Hdim);
if(wAspect>bAspect) {
$('#resizable').css({ width:(100*bAspect/wAspect) + '%', height:'100%' });
} else {
$('#resizable').css({ width:'100%', height:(100*wAspect/bAspect) + '%' });
}
},
/**
* @function configureBrainImage
* @returns {void}
*/
configureBrainImage: function configureBrainImage() {
var me = AtlasMakerWidget;
if(me.User.view === null) { me.User.view = "sag"; }
const {s2v} = me.User;
switch(me.User.view) {
case 'sag': [me.brain_W, me.brain_H, me.brain_D, me.brain_Wdim, me.brain_Hdim] = [s2v.sdim[1], s2v.sdim[2], s2v.sdim[0], s2v.wpixdim[1], s2v.wpixdim[2]]; break; // sagital
case 'cor': [me.brain_W, me.brain_H, me.brain_D, me.brain_Wdim, me.brain_Hdim] = [s2v.sdim[0], s2v.sdim[2], s2v.sdim[1], s2v.wpixdim[0], s2v.wpixdim[2]]; break; // coronal
case 'axi': [me.brain_W, me.brain_H, me.brain_D, me.brain_Wdim, me.brain_Hdim] = [s2v.sdim[0], s2v.sdim[1], s2v.sdim[2], s2v.wpixdim[0], s2v.wpixdim[1]]; break; // axial
}
me.canvas.width = me.brain_W;
me.canvas.height = me.brain_H*me.brain_Hdim/me.brain_Wdim;
me.brain_offcn.width = me.brain_W;
me.brain_offcn.height = me.brain_H;
me.brain_px = me.brain_offtx.getImageData(0, 0, me.brain_offcn.width, me.brain_offcn.height);
if(me.User.slice === null || me.User.slice >= me.brain_D-1) { me.User.slice = parseInt(me.brain_D/2); }
me.sendUserDataMessage(JSON.stringify({ 'view':me.User.view, 'slice':me.User.slice }));
// configure toolbar slider
$(".slider#slice").data({ max:me.brain_D-1, val:me.User.slice });
if($("#slice .thumb")[0]) { $("#slice .thumb")[0].style.left = (me.User.slice/(me.brain_D-1)*100) + "%"; }
me.drawImages();
me.initCursor();
},
/**
* @function configureAtlasImage
* @returns {void}
*/
configureAtlasImage: function configureAtlasImage() {
var me = AtlasMakerWidget;
// has to be run *after* configureBrainImage
me.atlas_offcn.width = me.brain_W;
me.atlas_offcn.height = me.brain_H;
me.atlas_px = me.atlas_offtx.getImageData(0, 0, me.atlas_offcn.width, me.atlas_offcn.height);
},
/**
* @function nearestNeighbour
* @param {object} ctx Drawing context
* @returns {void}
*/
nearestNeighbour: function nearestNeighbour(ctx) {
ctx.imageSmoothingEnabled = false;
ctx.mozImageSmoothingEnabled = false;
},
/**
* @function computeSegmentedVolume
* @returns {number} Volume in voxel units
*/
computeSegmentedVolume: function computeSegmentedVolume() {
var me = AtlasMakerWidget;
let i;
let sum = 0;
const {data, dim} = me.atlas;
for(i = 0; i<dim[0]*dim[1]*dim[2]; i++) {
if(data[i]>0) { sum++; }
}
return sum*me.User.pixdim[0]*me.User.pixdim[1]*me.User.pixdim[2];
},
/**
* @function displayInformation
* @desc Overlays text and vectorial information on top of the annotation volume slice. Text information is added from the AtlasMakerWidget.info object. Vectorial information is displayed using svg format
* @returns {void}
*/
displayInformation: function displayInformation() {
var me = AtlasMakerWidget;
var text = me.container.find("#text-layer");
var vector = me.container.find("#vector-layer");
let i = 0;
let k, str;
me.info.slice = me.User.slice;
str = "";
for(k in me.info) {
if (Object.prototype.hasOwnProperty.call(me.info, k)) {
str += "<span>" + k + ": " + me.info[k] + "</span><br/>";
}
}
text.html(str);
str = "";
if(me.User.measureLength) {
var W = parseFloat($('#atlasmaker canvas').css('width'));
var w = parseFloat($('#atlasmaker canvas').attr('width'));
var zx = W/w;
var zy = zx*me.brain_Hdim/me.brain_Wdim;
var p = me.User.measureLength;
var str1 = "M" + zx*p[0].x + ", " + zy*p[0].y;
for(i = 1; i<p.length; i++) {
str1 += "L" + zx*p[i].x + ", " + zy*p[i].y;
}
str += [
"<circle fill='#00ff00' cx=" + zx*p[0].x + " cy=" + zy*p[0].y + " r=3 />",
"<path stroke='#00ff00' fill='none' d='" + str1 + "'/>",
(i>0)?"<circle fill='#00ff00' cx=" + zx*p[i-1].x + " cy=" + zy*p[i-1].y + " r=3 />":""
].join("\n");
}
vector.html(str);
},
/**
* @function drawImages
* @returns {void}
*/
drawImages: function drawImages() {
var me = AtlasMakerWidget;
if(me.brain_img.img
&& me.flagLoadingImg.view
&& me.flagLoadingImg.slice) {
me.context.clearRect(0, 0, me.context.canvas.width, me.canvas.height);
me.displayInformation();
me.nearestNeighbour(me.context);
me.context.drawImage(me.brain_img.img, 0, 0, me.brain_W, me.brain_H*me.brain_Hdim/me.brain_Wdim);
me.drawAtlasImage(me.flagLoadingImg.view, me.flagLoadingImg.slice);
}
if(!me.brain_img.img || me.brain_img.view !== me.User.view || me.brain_img.slice !== me.User.slice) {
me.sendRequestSliceMessage();
}
},
/**
* @function drawAtlasImage
* @param {string} view View string: 'sag', 'cor', or 'axi'
* @param {number} slice The slice number
* @returns {void}
*/
drawAtlasImage: function drawAtlasImage(view, slice) {
var me = AtlasMakerWidget;
if(!me.atlas) { return; }
const {data} = me.atlas;
let i, s, x, y;
const [ys, yc, ya] = [slice, slice, slice];
for(y = 0; y < me.brain_H; y++) {
for(x = 0; x < me.brain_W; x++) {
switch(view) {
case 'sag': s = [ys, x, me.brain_H-1-y]; break;
case 'cor': s = [x, yc, me.brain_H-1-y]; break;
case 'axi': s = [x, me.brain_H-1-y, ya]; break;
}
i = me.S2I(s, me.User);
var c = me.ontologyValueToColor(data[i]);
var alpha = (data[i]>0)?255:0;
i = (y*me.atlas_offcn.width + x)*4;
me.atlas_px.data[i] = c[0];
me.atlas_px.data[i + 1] = c[1];
me.atlas_px.data[i + 2] = c[2];
me.atlas_px.data[i + 3] = alpha*me.alphaLevel;
}
}
me.atlas_offtx.putImageData(me.atlas_px, 0, 0);
me.nearestNeighbour(me.context);
me.context.drawImage(me.atlas_offcn, 0, 0, me.brain_W, me.brain_H*me.brain_Hdim/me.brain_Wdim);
}
};
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* global $ */
/*! AtlasMaker: User Interface Elements */
/**
* @page AtlasMaker: User Interface Elements
*/
export var AtlasMakerUI = {
/**
* @function slider
* @param {object} elem DOM element
* @param {function} callback Function called after the slider position is updated
* @returns {void}
*/
slider: function slider(elem, callback) {
// Initialise a 'slider' control
$(elem).data({
drag:false,
val:0,
max:100
});
var movex = function (el, clientX) {
if ($(el).data("drag") === true) {
var R = $(el).find(".track")[0].getBoundingClientRect();
var x = (clientX-R.left)/R.width;
if(x<0) { x=0; }
if(x>1) { x=1; }
x *= $(el).data("max");
if(x !== $(el).data("val")) {
var max=$(el).data("max");
$(el).data("val", x);
$(el).find(".thumb")[0].style.left=(x*100/max)+"%";
return callback(x);
}
}
};
$(document).on("mousemove", (ev) => { movex(elem, ev.clientX); });
$(document).on("touchmove", (ev) => { movex(elem, ev.originalEvent.changedTouches[0].pageX); });
$(document).on("mouseup touchend", () => { $(elem).data({drag:false}); });
$(elem).on('mousedown touchstart', () => { $(elem).data({drag:true}); });
},
/**
* @function chose
* @param {object} elem DOM element
* @param {function} callback Function called after the slider position is updated
* @returns {void}
*/
chose: function chose(elem, callback) {
// Initialise a 'chose' control
var ch=$(elem).find(".a");
ch.each(function(c, d) {
$(d).click(function() {
if($(d).hasClass("pressed")) {
return callback($(d).attr('title'));
}
ch.each(function(c1, d1) { $(d1).removeClass("pressed"); });
$(d).addClass("pressed");
if(callback) {
return callback($(d).attr('title'));