Open davclark opened 8 years ago
Hey @kevinyu927 and @hny221 - have you asked @r03ert0 to explain about the javascript that generates the existing tables? It's been quite a while, and I don't want this to stall out. At the end of our last meeting, your task was to communicate with @r03ert0 - sorry if that was not clear!
We are so close!
Hi @r03ert0 , I and Frank are trying to figure out how the javascript uses the existing article data to generate the existing tables under the page of each article. Could you give us some instructions? Thanks!
Hello, sorry for the silence. The table data is passed from the server to the client in the exp_string JSON string. This JSON string is parsed, and an array with experiments is stored in the global variable 'exp'. The function that launches all the experiment-level display is configureExperiments. This function calls addExperiment for each of the experiments in the array. The experiment HTML (table, 3D canvas, ontology section, table flags) is in template/experiment.html. addExperiment loads this template and fills it with the data in exp. It also configures all the interactivity (edition/annotation) and connects the table data with the 3D brain data. I wrote some quick descriptions of the first functions in the code, which may be the most relevant for what you want to do. The main complexity is that the display is not the same if the user is logged in or not, and they are also different if a logged in user has already provided annotations for this article (in which case his/her own annotations are displayed) or not (in which case the annotations done by other users are displayed). Here it is:
function updateArticle()
{
/*
Updates article display based on whether the user is logged in or not.
If the login status changes, this function is called to reflect those
changes.
There are two levels of display in an article, the article level (header)
and experiment level (each table). The data displayed at each level
depends on whether the user is logged in or not.
This function controls the display of the article-level data
* User logged in:
- possible to add a new article manually
- possible to edit stereotaxic space and number of subjects
- if the logged user has already annotated this article, display own annotations
- possible to add comments to the discussion thread
* User not logged in:
- can't create new articles
- can't annotate stereotaxic space nor number of subjects
- sees average number of subjects and most frequent stereotaxic space
- can't add to discussion thread
*/
}
function findExperimentByEID(eid) {
/*
Each experiment in an article has a unique experiment ID (EID).
All experiments in an article are stored in the array 'exp'.
This function scans the exp array to find an experiment with given EID,
and returns that experiment (or an error)
*/
}
function findIndexOfExperimentByEID(eid) {
/*
Each experiment in an article has a unique experiment ID (EID).
All experiments in an article are stored in the array 'exp'.
This function scans the exp array to find an experiment with given EID,
and returns the index of that experiment in the experiment array exp,
or an error if not found.
*/
}
function updateExperiment(eid/*iExp*/)
{
/*
This function controls the display of experiment-level data (data associated
to each table) depending on whether the user is logged in or not.
* user logged in:
- user can edit title, caption, mark table as ok or not, modify the
table coordinates, add or remove rows, split a table in two, or
parse a text file to import coordinates.
- the text fields that can be edited use the 'contentEditable' property
of HTML5, and use the class 'store'
- if the user has annotated this experiment, own data will be displayed
- it is possible to condition the display of data to a minimum number of
votes (i.e., only if a minimum number of different users have provided
a vote, such vote will be displayed). Although this looked like a good
idea at some point, minVotes has been now set to 0. The functionality is
kept in case we change our mind in the future.
- of the user has annotated an experiment, his/her own annotations are
displayed, otherwise the consensus of the other annotators is displayed.
- the display of ontology tags can depend on the presence of a minimum number
of votes, but for the moment minVotes=0
* user not logged in:
- can't edit
- can see an alert if the table has been flagged as incorrect, but cannot flag
The function also adjust the geometry of the table to fit the different amount
of data displayed to logged and not logged users
*/
}
function initBrainSpellArticle()
{
/*
init function, called only once
* loads the ontologies
* configures the update of display relative to logged and not logged status
* configures the links to display the article in pubmed, full text, neurosynth
and to download a text version of the article data
* provides the opportunity to manually enter a paper that's not in the DB
* calls the function that displays the experiment data: configureExperiments
* calls the function that displays article level data: configureArticle
The experiment data is provided by the server in the exp_string variable as a
JSON string. This parses this string and puts the data in the experiment array
variable 'exp'.
The article-level data is provided by the server in the meta_string variable as
a JSON string. This function parses the string and puts the data in the meta
object. In particular, this article level data contains the MeSH descriptors
added by PubMed (these are the tags manually added by PubMed to all papers). Some
recent papers don't have MeSH descriptors yet. If a paper in the DB does not have
MeSH descriptors, this function queries PubMed to see if they have been added.
*/
}
function downloadArticle() {
/*
Download article in CSV format to local hard disk
*/
}
function downloadArticleXML(callback)
{
/*
Download article metadata from PubMed.
For some recent papers the folks at PubMed have not had time to add MeSH
descriptors. This function checks with PubMed to see if the MeSH descriptors
have been added since the last time. If they have become available, they are
added to the DB
*/
}
function parseArticleXML(xml)
{
/*
Parses the xml data provided by PubMed to find meta data for a paper that
didn't have it previously (this includes in particular the MeSH descriptors
but also sometimes the DOI, page numbers, volume, etc.)
*/
}
function addEmptyExperiments(obj)
{
/*
In case a user is manually adding an article, this is the function that
adds new empty experiments to it
*/
}
/*
---------------------------------------------------------
Configuration of the article page
---------------------------------------------------------
*/
function configureMetadata()
{
/*
Load and configure article-level metadata: stereotaxic space, mesh headings,
number of subjects, discussion
*/
}
function configureMeSHDescriptors()
{
/*
Adds MeSH descriptor tags to the article page, with tag colors corresponding
to the number of positive/negative votes
*/
}
function configureExperiments()
{
/*
Adds experiments to the article page. The html for each experiment is in the
experiment.html template. Once this template is loaded, the function calls
'addExperiment' to configure the table data and link it to the 3D brain model
*/
}
function addExperiment(eid/*iExp*/)
{
/*
Configures the data of one experiment, its coordinate table, ontology tags,
votes, table flags, link with 3D brain spheres. It also configures the
edition functions: add/delete rows, split/import table. It adds the
updateExperiment function to the list of functions that have to be called if
the log in status changes
*/
}
If these doc strings are not yet in the code, you should totally copy them there!
On Thu, Nov 19, 2015 at 12:32 PM, Roberto Toro notifications@github.com wrote:
Hello, sorry for the silence. The table data is passed from the server to the client in the exp_string JSON string. This JSON string is parsed, and an array with experiments is stored in the global variable 'exp'. The function that launches all the experiment-level display is configureExperiments. This function calls addExperiment for each of the experiments in the array. The experiment HTML (table, 3D canvas, ontology section, table flags) is in template/experiment.html. addExperiment loads this template and fills it with the data in exp. It also configures all the interactivity (edition/annotation) and connects the table data with the 3D brain data. I wrote some quick descriptions of the first functions in the code, which may be the most relevant for what you want to do. The main complexity is that the display is not the same if the user is logged in or not, and they are also different if a logged in user has already provided annotations for this article (in which case his/her own annotations are displayed) or not (in which case the annotations done by other users are displayed). Here it is:
function updateArticle() { /* Updates article display based on whether the user is logged in or not. If the login status changes, this function is called to reflect those changes. There are two levels of display in an article, the article level (header) and experiment level (each table). The data displayed at each level depends on whether the user is logged in or not. This function controls the display of the article-level data
* User logged in: - possible to add a new article manually - possible to edit stereotaxic space and number of subjects - if the logged user has already annotated this article, display own annotations - possible to add comments to the discussion thread * User not logged in: - can't create new articles - can't annotate stereotaxic space nor number of subjects - sees average number of subjects and most frequent stereotaxic space - can't add to discussion thread */
} function findExperimentByEID(eid) { / Each experiment in an article has a unique experiment ID (EID). All experiments in an article are stored in the array 'exp'. This function scans the exp array to find an experiment with given EID, and returns that experiment (or an error) / } function findIndexOfExperimentByEID(eid) { / Each experiment in an article has a unique experiment ID (EID). All experiments in an article are stored in the array 'exp'. This function scans the exp array to find an experiment with given EID, and returns the index of that experiment in the experiment array exp, or an error if not found. _/ } function updateExperiment(eid/_iExp/) {
/* This function controls the display of experiment-level data (data associated to each table) depending on whether the user is logged in or not. * user logged in: - user can edit title, caption, mark table as ok or not, modify the table coordinates, add or remove rows, split a table in two, or parse a text file to import coordinates. - the text fields that can be edited use the 'contentEditable' property of HTML5, and use the class 'store' - if the user has annotated this experiment, own data will be displayed - it is possible to condition the display of data to a minimum number of votes (i.e., only if a minimum number of different users have provided a vote, such vote will be displayed). Although this looked like a good idea at some point, minVotes has been now set to 0. The functionality is kept in case we change our mind in the future. - of the user has annotated an experiment, his/her own annotations are displayed, otherwise the consensus of the other annotators is displayed. - the display of ontology tags can depend on the presence of a minimum number of votes, but for the moment minVotes=0 * user not logged in: - can't edit - can see an alert if the table has been flagged as incorrect, but cannot flag The function also adjust the geometry of the table to fit the different amount of data displayed to logged and not logged users */
} function initBrainSpellArticle() { / init function, called only once * loads the ontologies * configures the update of display relative to logged and not logged status * configures the links to display the article in pubmed, full text, neurosynth and to download a text version of the article data * provides the opportunity to manually enter a paper that's not in the DB * calls the function that displays the experiment data: configureExperiments \ calls the function that displays article level data: configureArticle
The experiment data is provided by the server in the exp_string variable as a JSON string. This parses this string and puts the data in the experiment array variable 'exp'. The article-level data is provided by the server in the meta_string variable as a JSON string. This function parses the string and puts the data in the meta object. In particular, this article level data contains the MeSH descriptors added by PubMed (these are the tags manually added by PubMed to all papers). Some recent papers don't have MeSH descriptors yet. If a paper in the DB does not have MeSH descriptors, this function queries PubMed to see if they have been added. */
} function downloadArticle() { / Download article in CSV format to local hard disk / } function downloadArticleXML(callback) { / Download article metadata from PubMed. For some recent papers the folks at PubMed have not had time to add MeSH descriptors. This function checks with PubMed to see if the MeSH descriptors have been added since the last time. If they have become available, they are added to the DB / } function parseArticleXML(xml) { / Parses the xml data provided by PubMed to find meta data for a paper that didn't have it previously (this includes in particular the MeSH descriptors but also sometimes the DOI, page numbers, volume, etc.) / } function addEmptyExperiments(obj) { / In case a user is manually adding an article, this is the function that adds new empty experiments to it / }
/*
Configuration of the article page
/ function configureMetadata() { / Load and configure article-level metadata: stereotaxic space, mesh headings, number of subjects, discussion */
} function configureMeSHDescriptors() { / Adds MeSH descriptor tags to the article page, with tag colors corresponding to the number of positive/negative votes / } function configureExperiments() { / Adds experiments to the article page. The html for each experiment is in the experiment.html template. Once this template is loaded, the function calls 'addExperiment' to configure the table data and link it to the 3D brain model _/ } function addExperiment(eid/iExp/) { /_ Configures the data of one experiment, its coordinate table, ontology tags, votes, table flags, link with 3D brain spheres. It also configures the edition functions: add/delete rows, split/import table. It adds the updateExperiment function to the list of functions that have to be called if the log in status changes / }
— Reply to this email directly or view it on GitHub https://github.com/BIDS-collaborative/brainspell/issues/19#issuecomment-158189308 .
Dav Clark Data Scientist Berkeley D-Lab + BIDS bead.glass 917-544-8408
They don't need to be correct yet! Just come up with a mechanism.
cc @kevinyu927