NIH | National Cancer Institute | NCI Wiki  

WIKI MAINTENANCE NOTICE

Please be advised that NCI Wiki will be undergoing maintenance Monday, July 22nd between 1700 ET and 1800 ET and will be unavailable during this period.
Please ensure all work is saved before said time.

If you have any questions or concerns, please contact the CBIIT Atlassian Management Team.


1) Cronicle DB view

{
  "_id": "_design/instances",
  "_rev": "9-171fb9cdc0a7fe5f9e0c2cd4f2b1d7ca",
  "language": "javascript",
  "views": {
    "instanceReferences": {
      "map": "\n              // TODO: this needs to be generalized to instance->instance reference\n              // for now this is specific to instancePoints\n              function(doc) {\n                if (doc.instancePoints) {\n                  instanceUIDs = Object.keys(doc.instancePoints);\n                  for (var i in instanceUIDs) {\n                    emit( instanceUIDs[i], doc._id );\n                  }\n                }\n              }\n            ",
      "reduce": "_count()"
    },
    "seriesInstances": {
      "map": "\n              function(doc) {\n                var tags = [\n                  ['seriesUID', '0020000E', 'UnspecifiedSeriesUID'],\n                  ['classUID', '00080016', 'UnspecifiedClassUID'],\n                  ['instanceUID', '00080018', 'UnspecifiedInstanceUID'],\n                ];\n                var key = {};\n                if (doc.dataset) {\n                  var i;\n                  for (i = 0; i < tags.length; i++) {\n                    var tag = tags[i];\n                    var name     = tag[0];\n                    var t        = tag[1];\n                    var fallback = tag[2];\n                    key[name] = fallback;\n                    if (doc.dataset[t] && doc.dataset[t].Value) {\n                      key[name] = doc.dataset[t].Value || fallback;\n                    }\n                  }\n                  emit( key.seriesUID, [key.classUID, key.instanceUID] );\n                }\n              }\n            ",
      "reduce": "_count()"
    },
    "context": {
      "map": "\n              function(doc) {\n                var tags = [\n                  ['institution', '00080080', 'UnspecifiedInstitution'],\n                  ['patientID', '00100020', 'UnspecifiedPatientID'],\n                  ['studyUID', '0020000D', 'UnspecifiedStudyUID'],\n                  ['studyDescription', '00081030', 'UnspecifiedStudyDescription'],\n                  ['seriesUID', '0020000E', 'UnspecifiedSeriesUID'],\n                  ['seriesDescription', '0008103E', 'UnspecifiedSeriesDescription'],\n                  ['instanceUID', '00080018', 'UnspecifiedInstanceUID'],\n                  ['modality', '00080060', 'UnspecifiedModality'],\n                ];\n                var key = {};\n                if (doc.dataset) {\n                  var i;\n                  for (i = 0; i < tags.length; i++) {\n                    var tag = tags[i];\n                    var name     = tag[0];\n                    var t        = tag[1];\n                    var fallback = tag[2];\n                    key[name] = fallback;\n                    if (doc.dataset[t] && doc.dataset[t].Value) {\n                      key[name] = doc.dataset[t].Value || fallback;\n                    }\n                  }\n                  emit([\n                      [key.institution,key.patientID],\n                      [key.studyDescription,key.studyUID],\n                      [key.modality,key.seriesDescription,key.seriesUID],\n                      key.instanceUID\n                    ],\n                    1\n                  );\n                }\n              }\n            ",
      "reduce": "_count()"
    },
    "byCollection": {
      "reduce": "_count",
      "map": "function (doc) {\n  emit([doc.fileNamePath.split('/')[1],doc.dataset['0020000E'].Value], 1);\n}"
    },
    "bySeriesUID": {
      "reduce": "_count",
      "map": "function (doc) {\n  emit([doc.dataset['0020000E'].Value,doc.fileNamePath.split('/')[1]], 1);\n}"
    },
    "bySeriesUID_j": {
      "reduce": "_count",
      "map": "function (doc) {\n  emit([doc.dataset['0020000E'].Value,doc.fileNamePath.split('/')[1]], 1);\n}"
    }
  }
}

2) Anotator DB View


{
  "_id": "_design/instances",
  "_rev": "4-e13f6a6c29ce8c29a336de511e7279dc",
  "views": {
    "anatomyChoices": {
      "reduce": "_count",
      "map": "function (doc) {\n  emit(doc. username, doc.anatomyChoices);\n}"
    }
  },
  "language": "javascript"
}

3) Measurement DB View

a) First View {
  "_id": "_design/d72bdb9e558e0db519b0643e2ffc05108d379d56",
  "_rev": "1-f84404b39883a968f3d1804e4f3f007a",
  "language": "query",
  "views": {
    "annotator": {
      "map": {
        "fields": {
          "annotator": "asc"
        }
      },
      "reduce": "_count",
      "options": {
        "def": {
          "fields": [
            "annotator"
          ]
        }
      }
    }
  }
}

b) Second view

{
  "_id": "_design/by",
  "_rev": "17-5464b460aec7e2f534849a1b7bfdec80",
  "views": {
    "annotators": {
      "reduce": "_count",
      "map": "function (doc) {\n  emit(doc.annotator, 1);\n}"
    },
    "annotators_map": {
      "map": "function (doc) {\n  emit(doc.annotator, 1);\n}"
    },
    "seriesUID": {
      "reduce": "_count",
      "map": "function (doc) {\n  emit(doc.seriesUID, 1);\n}"
    },
    "seriesUIDNoSkip": {
      "reduce": "_count",
      "map": "function (doc) {\n  if (!doc.skip) {\n    emit(doc.seriesUID, 1);\n  }\n}"
    }
  },
  "lists": {
    "csvformat": "function(head, req) {\r\n  var row,\r\n    first = true;\r\n \r\n  // output HTTP headers\r\n  start({\r\n    headers: {  'Content-Type': 'text/csv'  },\r\n  });\r\n \r\n \r\n  // iterate through the result set\r\n  while(row = getRow()) {\r\n \r\n    // get the doc (include_docs=true)\r\n    var doc = row.doc;\r\n \r\n    // if this is the first row\r\n    if (first) {\r\n \r\n      // output column headers\r\n      send(Object.keys(doc).join(',') + '\\n');\r\n      first = false;\r\n    }\r\n \r\n    // build up a line of output\r\n    var line = '';\r\n \r\n    // iterate through each row\r\n    for(var i in doc) {\r\n \r\n      // comma separator\r\n      if (line.length > 0) {\r\n        line += ',';\r\n      }\r\n \r\n      // output the value, ensuring values that themselves\r\n      // contain commas are enclosed in double quotes\r\n      var val = doc[i];\r\n      if (typeof val == 'string' && val.indexOf(',') >  -1) {\r\n        line += '\"' + val.replace(/\"/g,'\"\"') + '\"';\r\n      } else {\r\n        line += val;\r\n      }\r\n    }\r\n    line += '\\n';\r\n \r\n    // send  the line\r\n    send(line);\r\n  }\r\n};"
  },
  "language": "javascript"
}


  • No labels