dicom-microscopy-viewer
Version:
Interactive web-based viewer for DICOM Microscopy Images
329 lines (285 loc) • 11.5 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: mapping.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: mapping.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>const _attrs = Symbol('attrs')
/**
* Transformation of a range of stored values into real world values in a
* defined unit. The transformation may either be described by a lookup table
* (LUT) or alternatively by the slope and intercept parameters if the
* transformation can be described by a linear function.
*
* @class
* @memberof mapping
*/
class Transformation {
/**
* @param {Object} options - Options
* @param {string} options.label - LUT Label
* @param {number} options.firstValueMapped - First value mapped by LUT
* @param {number} options.lastValueMapped - Last value mapped by LUT
* @param {lut} options.lut - LUT data
* @param {number} options.intercept - Intercept of linear function
* @param {number} options.slope - Slope of linear function
*/
constructor ({
label,
firstValueMapped,
lastValueMapped,
lut,
intercept,
slope
}) {
if (label === undefined) {
throw new Error('LUT Label is required.')
}
this[_attrs].label = label
if (firstValueMapped === undefined) {
throw new Error('Real World Value First Value Mapped is required.')
}
this[_attrs].firstValueMapped = firstValueMapped
if (lastValueMapped === undefined) {
throw new Error('Real World Value Last Value Mapped is required.')
}
this[_attrs].lastValueMapped = lastValueMapped
if ((intercept === undefined || slope === undefined) && lut === undefined) {
throw new Error(
'Either LUT Data or Real World Value Slope and ' +
'Real World Value Intercept must be provided.'
)
}
if (slope === undefined) {
throw new Error('Real World Value Slope is required.')
}
this[_attrs].slope = slope
if (intercept === undefined) {
throw new Error('Real World Value Intercept is required.')
}
this[_attrs].intercept = intercept
if (lut === undefined) {
throw new Error('LUT Data is required.')
}
this[_attrs].lut = lut
}
}
/**
* Parameter Mapping.
*
* Describes an individual parameter encoded in a DICOM Parametric Map instance.
*
* @class
* @memberof mapping
*/
class ParameterMapping {
/**
* @param {Object} options
* @param {string} options.uid - Unique tracking identifier
* @param {number} options.number - Parameter Number (one-based index value)
* @param {string} options.label - Parameter Label
* @param {string} options.description - Parameter Description
* @param {string} options.studyInstanceUID - Study Instance UID of DICOM
* Parametric Map instances
* @param {string} options.seriesInstanceUID - Series Instance UID of DICOM
* Parametric Map instances
* @param {string[]} options.sopInstanceUIDs - SOP Instance UIDs of DICOM
* Parametric Map instances
* @param {string|undefined} options.paletteColorLookupTableUID - Palette
* Color Lookup Table UID
*/
constructor ({
uid,
number,
label,
description,
studyInstanceUID,
seriesInstanceUID,
sopInstanceUIDs,
paletteColorLookupTableUID
}) {
this[_attrs] = {}
if (uid === undefined) {
throw new Error('Unique Tracking Identifier is required.')
} else {
this[_attrs].uid = uid
}
if (number === undefined) {
throw new Error('Parameter Number is required.')
}
this[_attrs].number = number
if (label === undefined) {
throw new Error('Parameter Label is required.')
}
this[_attrs].label = label
if (description === undefined) {
throw new Error('Parameter Description is required.')
}
this[_attrs].description = description
if (studyInstanceUID === undefined) {
throw new Error('Study Instance UID is required.')
}
this[_attrs].studyInstanceUID = studyInstanceUID
if (seriesInstanceUID === undefined) {
throw new Error('Series Instance UID is required.')
}
this[_attrs].seriesInstanceUID = seriesInstanceUID
if (sopInstanceUIDs === undefined) {
throw new Error('SOP Instance UIDs are required.')
}
this[_attrs].sopInstanceUIDs = sopInstanceUIDs
this[_attrs].paletteColorLookupTableUID = paletteColorLookupTableUID
Object.freeze(this)
}
/**
* Unique Tracking Identifier
*
* @type string
*/
get uid () {
return this[_attrs].uid
}
/**
* Parameter Number
*
* @type number
*/
get number () {
return this[_attrs].number
}
/**
* Parameter Label
*
* @type string
*/
get label () {
return this[_attrs].label
}
/**
* Parameter Description
*
* @type string
*/
get description () {
return this[_attrs].description
}
/**
* Study Instance UID of DICOM Parametric Map instances.
*
* @type string
*/
get studyInstanceUID () {
return this[_attrs].studyInstanceUID
}
/**
* Series Instance UID of DICOM Parametric Map instances.
*
* @type string
*/
get seriesInstanceUID () {
return this[_attrs].seriesInstanceUID
}
/**
* SOP Instance UIDs of DICOM Parametric Map instances.
*
* @type string[]
*/
get sopInstanceUIDs () {
return this[_attrs].sopInstanceUIDs
}
/**
* Palette Color Lookup Table UID.
*
* @type string
*/
get paletteColorLookupTableUID () {
return this[_attrs].paletteColorLookupTableUID
}
}
function _groupFramesPerMapping (metadata) {
const mappings = {}
const sharedItem = metadata.SharedFunctionalGroupsSequence[0]
if (sharedItem.RealWorldValueMappingSequence !== undefined) {
const labels = sharedItem.RealWorldValueMappingSequence.map(
item => item.LUTLabel
)
const key = labels.join('-')
const numFrames = Number(metadata.NumberOfFrames)
mappings[key] = {
frameNumbers: [...Array(numFrames).keys()].map(index => index + 1),
realWorldValueMappings: sharedItem.RealWorldValueMappingSequence
}
} else {
// Dimension Organization TILED_FULL is not defined for Parametric Map
if (metadata.PerFrameFunctionalGroupsSequence !== undefined) {
metadata.PerFrameFunctionalGroupsSequence.forEach((frameItem, i) => {
if (frameItem.RealWorldValueMappingSequence !== undefined) {
const labels = frameItem.RealWorldValueMappingSequence.map(
item => item.LUTLabel
)
const key = labels.join('-')
if (key in mappings) {
mappings[key].frameNumbers.push(i + 1)
} else {
mappings[key] = {
frameNumbers: [i + 1],
realWorldValueMappings: frameItem.RealWorldValueMappingSequence
}
}
}
})
}
}
const frameNumberToMappingNumber = {}
const mappingNumberToFrameNumbers = {}
const mappingNumberToDescriptions = {}
Object.values(mappings).forEach((mapping, mappingIndex) => {
const mappingNumber = mappingIndex + 1
mapping.frameNumbers.forEach(frameNumber => {
frameNumberToMappingNumber[frameNumber] = mappingNumber
if (mappingNumber in mappingNumberToFrameNumbers) {
mappingNumberToFrameNumbers[mappingNumber].push(frameNumber)
} else {
mappingNumberToFrameNumbers[mappingNumber] = [frameNumber]
}
})
mappingNumberToDescriptions[mappingNumber] = mapping.realWorldValueMappings
})
return {
frameNumberToMappingNumber,
mappingNumberToFrameNumbers,
mappingNumberToDescriptions
}
}
export {
_groupFramesPerMapping,
ParameterMapping,
Transformation
}
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Namespaces</h3><ul><li><a href="annotation.html">annotation</a></li><li><a href="api.html">api</a></li><li><a href="color.html">color</a></li><li><a href="events.html">events</a></li><li><a href="mapping.html">mapping</a></li><li><a href="metadata.html">metadata</a></li><li><a href="opticalPath.html">opticalPath</a></li><li><a href="roi.html">roi</a></li><li><a href="scoord3d.html">scoord3d</a></li><li><a href="segment.html">segment</a></li><li><a href="utils.html">utils</a></li><li><a href="viewer.html">viewer</a></li></ul><h3>Classes</h3><ul><li><a href="annotation.AnnotationGroup.html">AnnotationGroup</a></li><li><a href="color.PaletteColorLookupTable.html">PaletteColorLookupTable</a></li><li><a href="mapping.ParameterMapping.html">ParameterMapping</a></li><li><a href="mapping.Transformation.html">Transformation</a></li><li><a href="metadata.Comprehensive3DSR.html">Comprehensive3DSR</a></li><li><a href="metadata.MicroscopyBulkSimpleAnnotations.html">MicroscopyBulkSimpleAnnotations</a></li><li><a href="metadata.ParametricMap.html">ParametricMap</a></li><li><a href="metadata.Segmentation.html">Segmentation</a></li><li><a href="metadata.SOPClass.html">SOPClass</a></li><li><a href="metadata.VLWholeSlideMicroscopyImage.html">VLWholeSlideMicroscopyImage</a></li><li><a href="module.exports_module.exports.html">exports</a></li><li><a href="opticalPath.OpticalPath.html">OpticalPath</a></li><li><a href="roi.ROI.html">ROI</a></li><li><a href="scoord3d.Ellipse.html">Ellipse</a></li><li><a href="scoord3d.Ellipsoid.html">Ellipsoid</a></li><li><a href="scoord3d.Multipoint.html">Multipoint</a></li><li><a href="scoord3d.Point.html">Point</a></li><li><a href="scoord3d.Polygon.html">Polygon</a></li><li><a href="scoord3d.Polyline.html">Polyline</a></li><li><a href="scoord3d.Scoord3D.html">Scoord3D</a></li><li><a href="segment.Segment.html">Segment</a></li><li><a href="viewer.LabelImageViewer.html">LabelImageViewer</a></li><li><a href="viewer.OverviewImageViewer.html">OverviewImageViewer</a></li><li><a href="viewer.VolumeImageViewer.html">VolumeImageViewer</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addTask">addTask</a></li><li><a href="global.html#cancelTask">cancelTask</a></li><li><a href="global.html#decode">decode</a></li><li><a href="global.html#getStatistics">getStatistics</a></li><li><a href="global.html#handleMessageFromWorker">handleMessageFromWorker</a></li><li><a href="global.html#initialize">initialize</a></li><li><a href="global.html#loadWebWorkerTask">loadWebWorkerTask</a></li><li><a href="global.html#setTaskPriority">setTaskPriority</a></li><li><a href="global.html#spawnWebWorker">spawnWebWorker</a></li><li><a href="global.html#startTaskOnWebWorker">startTaskOnWebWorker</a></li><li><a href="global.html#terminateAllWebWorkers">terminateAllWebWorkers</a></li><li><a href="global.html#transform">transform</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.10</a> on Thu Sep 29 2022 16:54:54 GMT-0400 (Eastern Daylight Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>