diff --git a/site/js/brainspell-article.js b/site/js/brainspell-article.js index c2f378f..4f6d80d 100755 --- a/site/js/brainspell-article.js +++ b/site/js/brainspell-article.js @@ -4,7 +4,7 @@ var tasks; var cognitive; var behavioural; var concept; -var minVotes=0; // Minimum number of votes a tag must have to be displayed +var minVotes=0; // Minimum number of votes a tag must have to be displayed var meta; var exp; var ArticlePMID; @@ -13,7 +13,7 @@ var EmptyArticle; function updateArticle() { if(debug) console.log("[updateArticle] Login update at article level (Login: "+(loggedin?"Yes":"No")+")"); - + /* Article-level display --------------------- @@ -29,7 +29,7 @@ function updateArticle() var rtag=exp[-1].tags[j]; rtag.agree=(rtag.agree)?parseInt(rtag.agree):0; rtag.disagree=(rtag.disagree)?parseInt(rtag.disagree):0; - + var prevVote=findPreviousVoteByUser(-1,rtag); if(rtag.agree+rtag.disagree>=minVotes || prevVote!=0) addTagColor(iExp,rtag); @@ -40,7 +40,7 @@ function updateArticle() // New article warning $("#new-article-warning button").removeAttr('disabled'); - + // Metadata stereotaxic space $("span#Talairach").show(); $("span#MNI").show(); @@ -60,7 +60,7 @@ function updateArticle() $("span#MNI").html('('+meta.stereo.MNI+')'); } } - + // Metadata number of subjects $("input#nSubjects").removeAttr('disabled'); $("span#nSubjects").show(); @@ -95,7 +95,7 @@ function updateArticle() $('button#disagree').removeAttr('disabled'); $('.buttonsThing div#login-message').remove(); } - + // Discussion text area $("button#comment").removeAttr('disabled'); $("span#commentWarning").hide(); @@ -104,7 +104,7 @@ function updateArticle() { // New article warning $("#new-article-warning button").attr('disabled',true); - + // Metadata stereotaxic space $("input:radio[value='Talairach']").attr('disabled',true); $("input:radio[value='MNI']").attr('disabled',true); @@ -126,7 +126,7 @@ function updateArticle() $("span#Talairach").hide(); $("span#MNI").hide(); } - + // Metadata number of subjects $("input#nSubjects").attr('disabled',true); if(meta.nsubjects && meta.nsubjects.length>=minVotes) @@ -179,7 +179,7 @@ function findIndexOfExperimentByEID(eid) { function updateExperiment(eid/*iExp*/) { if(debug) console.log("[updateExperiment] Login update at experiment "+eid/*iExp*/+" (Login: "+(loggedin?"Yes":"No")+")"); - + /* Experiment-level display ------------------------ @@ -222,7 +222,7 @@ function updateExperiment(eid/*iExp*/) if(debug) console.log("[updateExperiment] eid:",eid/*iExp*/,"markbad:",markBadTable); $(".experiment#"+eid/*iExp*/+":first span#Yes").html('('+markBadTable.ok+')'); $(".experiment#"+eid/*iExp*/+":first span#No").html('('+markBadTable.bad+')'); - + if(markBadTable.bad>markBadTable.ok) $(".experiment#"+eid/*iExp*/+":first .tableAlert ").html('This table may be incorrect'); else @@ -231,7 +231,7 @@ function updateExperiment(eid/*iExp*/) else { $(".experiment#"+eid/*iExp*/+":first span#Yes").html(''); - $(".experiment#"+eid/*iExp*/+":first span#No").html(''); + $(".experiment#"+eid/*iExp*/+":first span#No").html(''); } if(prevMark>-1) { @@ -243,7 +243,7 @@ function updateExperiment(eid/*iExp*/) $(".experiment#"+eid/*iExp*/+" input:radio[value='Yes']").removeAttr('checked'); $(".experiment#"+eid/*iExp*/+" input:radio[value='No']").removeAttr('checked'); } - + // Experiment tags (specific) if(ex.tags) for(j=0;j") { if(debug) console.log("[initBrainSpellArticle] Article not in DB, search pubmed"); - $("#new-article-warning").show(); + $("#new-article-warning").show(); downloadArticleXML(); } else @@ -357,7 +357,7 @@ function downloadArticle() { "Abstract: "+$(".abstract").text(), "" ].join("\n"); - + for(i=0;i0) { $("#new-article-warning").hide(); @@ -484,7 +484,7 @@ function addEmptyExperiments(obj) exp=[]; for(i=0;i
"); } - + if(debug) console.log("[configureMetadata] metadata configured"); } function configureMeSHDescriptors() @@ -621,18 +621,21 @@ function addExperiment(eid/*iExp*/) ex.locations[j]={ x:coords[0], y:coords[1], - z:coords[2] + z:coords[2], + zScore:coords[3] } } else { coords[0]=ex.locations[j].x; coords[1]=ex.locations[j].y; coords[2]=ex.locations[j].z; + coords[3]=ex.locations[j].zScore; } var new_row = table.insertRow(j); new_row.innerHTML=[ ""+coords[0]+"", ""+coords[1]+"", ""+coords[2]+"", + ""+coords[3]+"", "", "" ].join("\n"); @@ -648,7 +651,7 @@ function addExperiment(eid/*iExp*/) parseTable(this,eid/*iExp*/); } }); - + // Table actions //-------------- // Split table @@ -669,7 +672,7 @@ function addExperiment(eid/*iExp*/) $(".experiment#"+eid/*iExp*/+" .ontologies").append(addOntology(eid/*iExp*/,"tasks")); $(".experiment#"+eid/*iExp*/+" .ontologies").append(addOntology(eid/*iExp*/,"cognitive")); $(".experiment#"+eid/*iExp*/+" .ontologies").append(addOntology(eid/*iExp*/,"behavioural")); - + // Configure radio button groups for table marks $(".experiment#"+eid/*iExp*/+" input:radio[value='Yes']").attr('name',"radio"+eid/*iExp*/); $(".experiment#"+eid/*iExp*/+" input:radio[value='No']").attr('name',"radio"+eid/*iExp*/); @@ -688,7 +691,7 @@ function clickOnTable(target) var div=$(target).closest(".experiment"); var eid/*iExp*/=div.attr('id'); var index=$(row).index(); - + if(index>=0 && targetClass!="del" && targetClass!="add") selectRow(row,eid/*iExp*/); } @@ -717,7 +720,7 @@ function enterRow(row,eid/*iExp*/) { } if(e.which==9) { // tab parseTable(row,eid/*iExp*/); - } + } }); } function delRow(row) @@ -726,7 +729,7 @@ function delRow(row) var eid/*iExp*/=par.attr('id'); var i=$(row).closest("tr").index(); var ex=findExperimentByEID(eid); - + $(".experiment#"+eid/*iExp*/+" .xyztable table")[0].deleteRow(i); ex.render.scene.remove(ex.locations[i].sph); @@ -744,20 +747,20 @@ function addRow(row) var table=$(".experiment#"+eid/*iExp*/+" .xyztable table")[0]; var inputType=$(row).attr("class"); var j,new_row; - + if(inputType=="addhead") // if the user clicked on the plus sign in the header, add at the top of the table j=0; else j=i+1; new_row=table.insertRow(j); - + new_row.innerHTML=[ "0", "0", "0", "", ""].join("\n"); - + // intercept enter $(new_row).find('td[contentEditable]').each(function(){enterRow(this,eid/*iExp*/);}); @@ -790,7 +793,7 @@ function splitTable(eid/*iExp*/,irow) { locations: newLocations }; exp.splice(iExp+1, 0, newExp); - + configureExperiments(); saveExperiments(); @@ -815,7 +818,7 @@ function importTable(eid) { // init text with current table data for(i=0;i\n"); - + var parse_button=$("#parse_button"); var import_button=$("#import_button"); var cancel_button=$("#cancel_button"); @@ -825,7 +828,7 @@ function importTable(eid) { var arr=$("#text").html().split(/
|<\/p>|
/); var i,j,k; var val,num; - + // (lines are easier to split from html(), // but values are easier to parse from text()) for(i=0;i",{class:'tag'}); tag.html(rtag.name); tag.click({rtag:rtag},function(e){openTagModal(eid/*iExp*/,e.data.rtag)}); @@ -1046,7 +1049,7 @@ function updateTagColor(tag,rtag) if(rtag.agree==0&&rtag.disagree==0) return; - + if(rtag.agree-rtag.disagree>0) tag.addClass('green'); else @@ -1059,7 +1062,7 @@ function findTag(tags,name,ontology) { var j,found=0; var ob; - + if(tags) for(j=0;j-1) { var ex=findExperimentByEID(eid); obj=findTag(ex.tags,rtag.name,rtag.ontology); @@ -1240,7 +1243,7 @@ function openTagModal(eid/*iExp*/,rtag) $('#boxfade').show(); $('#box #eid').html(eid/*iExp*/); $('#box #ontology').html(rtag.ontology); - + configureTagModal(rtag); resizeTagModal(); } @@ -1252,9 +1255,9 @@ function closeTagModal(vote) var name=$('#box h2.name').text(); var ontology=$('#box #ontology').text(); var tag; - + // Vote -2:retract, 0:cancel, -1:down-vote or 1:up-vote - if(vote!=0) + if(vote!=0) { // find the tag if(eid/*iExp*/>=0) // iExp is >=0 for tables, =-1 for article-level tags @@ -1264,7 +1267,7 @@ function closeTagModal(vote) // experiment if(!(ex.tags)) ex.tags=new Array; - + // check whether the currently voted tag was already among // the experiment's tags obj=findTag(ex.tags,name,ontology); @@ -1314,7 +1317,7 @@ function closeTagModal(vote) else rtag.disagree=disagree+1; } - + // Update tag display and save total tag votes (total agree/disagree stats) if(eid/*iExp*/>=0) { @@ -1521,7 +1524,7 @@ function initTranslucentBrain(eid/*iExp*/) // create a scene ex.render.scene = new THREE.Scene(); - + // create projector (for hit detection) ex.render.projector = new THREE.Projector(); ex.render.renderer.domElement.addEventListener( 'mousedown', function(e){onDocumentMouseDown(e,eid/*iExp*/);}, false ); @@ -1538,7 +1541,7 @@ function initTranslucentBrain(eid/*iExp*/) // allow 'p' to make screenshot //THREEx.Screenshot.bindKey(renderer); - + // Add lights var light = new THREE.AmbientLight( 0x3f3f3f); ex.render.scene.add(light ); @@ -1557,11 +1560,11 @@ function initTranslucentBrain(eid/*iExp*/) { var tmp=this.response; var modifier = new THREE.SubdivisionModifier(1); - + ex.render.material=new THREE.ShaderMaterial({ - uniforms: { + uniforms: { coeficient : { - type : "f", + type : "f", value : 1.0 }, power : { @@ -1599,10 +1602,10 @@ function initTranslucentBrain(eid/*iExp*/) transparent : true, depthWrite : false, }); - + ex.render.geometry=new THREE.PLYLoader().parse(tmp); ex.render.geometry.sourceType = "ply"; - + modifier.modify(ex.render.geometry); for(i=0;i/', '$1', $str); +} + +$result = mysqli_query($link, "SELECT * FROM ".$dbname.".Articles"); +while($record=mysqli_fetch_assoc($result)) +{ + $pmid=$record['PMID']; + $doi=$record['DOI']; + $exs=$record['Experiments']; + $title=$record['Title']; + + //Add Zscores to each experiment + $exs=json_decode(strip_cdata($exs)); + for($i=0;$ilocations) { + for ($j=0;$jlocations);$j++) { + //ONLY RUN THIS ONCE + // $ex->locations[$j].=",0"; + } + // echo implode(" ", $ex->locations); + $exs[$i] = $ex; + } + } + + + //Update database + $q="UPDATE ".$dbname.".Articles SET "; + $q.="Experiments='".mysqli_real_escape_string($link, json_encode($exs))."' "; + $q.= " WHERE PMID='".$pmid."'"; + $result2 = mysqli_query($link, $q); + if($result2) + echo "SUCCESS\n"; + else + { + // echo "ERROR: Unable to process query: ".$q."\n"; + // var_dump($record); + } + +} + +mysqli_free_result($result); +?> diff --git a/site/php/admin_numSubjects.php b/site/php/admin_numSubjects.php new file mode 100644 index 0000000..24f37f9 --- /dev/null +++ b/site/php/admin_numSubjects.php @@ -0,0 +1,43 @@ +/', '$1', $str); +} + + //Update database + $q="ALTER TABLE ".$dbname.".Articles ADD "; + $q.="NumSubjects int"; + $result2 = mysqli_query($link, $q); + if($result2) + echo "SUCCESS\n"; + else + { + // echo "ERROR: Unable to process query: ".$q."\n"; + // var_dump($record); + } + + $q="UPDATE ".$dbname.".Articles SET "; + $q.="NumSubjects=0"; + $result3 = mysqli_query($link, $q); + if($result3) + echo "SUCCESS\n"; + else + { + // echo "ERROR: Unable to process query: ".$q."\n"; + // var_dump($record); + } + +?>