1 | {"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap df4b22b327606a1b3dfa","webpack:///./externalModules.js","webpack:///./imageLoader/internal/index.js","webpack:///./shared/getMinMax.js","webpack:///./imageLoader/wadors/metaData/getValue.js","webpack:///./imageLoader/wadouri/parseImageId.js","webpack:///./imageLoader/wadors/metaDataManager.js","webpack:///./imageLoader/internal/options.js","webpack:///./imageLoader/createImage.js","webpack:///./imageLoader/wadouri/dataSetCacheManager.js","webpack:///./version.js","webpack:///./imageLoader/colorSpaceConverters/index.js","webpack:///./imageLoader/wadouri/index.js","webpack:///./imageLoader/wadouri/metaData/index.js","webpack:///./imageLoader/wadouri/metaData/getImagePixelModule.js","webpack:///./imageLoader/wadouri/metaData/getLUTs.js","webpack:///./imageLoader/wadouri/metaData/getModalityLUTOutputPixelRepresentation.js","webpack:///./imageLoader/wadouri/metaData/getNumberValues.js","webpack:///./imageLoader/wadors/index.js","webpack:///./imageLoader/wadors/metaData/index.js","webpack:///./imageLoader/wadors/metaData/getNumberValue.js","webpack:///./imageLoader/wadors/metaData/getNumberValues.js","webpack:///./imageLoader/wadors/findIndexOfString.js","webpack:///./imageLoader/wadors/getPixelData.js","webpack:///./imageLoader/wadors/loadImage.js","webpack:///./imageLoader/getImageFrame.js","webpack:///./imageLoader/decodeImageFrame.js","webpack:///./imageLoader/webWorkerManager.js","webpack:///./imageLoader/decodeJPEGBaseline8BitColor.js","webpack:///./imageLoader/isColorImage.js","webpack:///./imageLoader/convertColorSpace.js","webpack:///./imageLoader/isJPEGBaseline8BitColor.js","webpack:///./imageLoader/wadouri/fileManager.js","webpack:///./imageLoader/wadouri/getEncapsulatedImageFrame.js","webpack:///./imageLoader/wadouri/getUncompressedImageFrame.js","webpack:///./imageLoader/wadouri/unpackBinaryFrame.js","webpack:///./imageLoader/wadouri/loadFileRequest.js","webpack:///./imageLoader/wadouri/loadImage.js","webpack:///./imageLoader/index.js","webpack:///./imageLoader/colorSpaceConverters/convertRGBColorByPixel.js","webpack:///./imageLoader/colorSpaceConverters/convertRGBColorByPlane.js","webpack:///./imageLoader/colorSpaceConverters/convertYBRFullByPixel.js","webpack:///./imageLoader/colorSpaceConverters/convertYBRFullByPlane.js","webpack:///./imageLoader/colorSpaceConverters/convertPALETTECOLOR.js","webpack:///./imageLoader/wadouri/metaData/metaDataProvider.js","webpack:///external {\"commonjs\":\"dicom-parser\",\"commonjs2\":\"dicom-parser\",\"amd\":\"dicom-parser\",\"root\":\"dicomParser\"}","webpack:///./imageLoader/registerLoaders.js","webpack:///./imageLoader/wadors/metaData/getNumberString.js","webpack:///./imageLoader/wadors/metaData/metaDataProvider.js","webpack:///./imageLoader/internal/xhrRequest.js","webpack:///./imageLoader/wadors/register.js","webpack:///./imageLoader/wadouri/getPixelData.js","webpack:///./imageLoader/wadouri/register.js","webpack:///./imageLoader/configure.js"],"names":["dicomParser","cornerstone","external","cs","internal","xhrRequest","setOptions","getOptions","getMinMax","storedPixelData","min","max","storedPixel","numPixels","length","index","Math","getValue","element","defaultValue","Value","parseImageId","imageId","firstColonIndex","indexOf","url","substring","frameIndex","frame","frameStr","substr","parseInt","scheme","imageIds","add","metadata","get","remove","undefined","purge","options","beforeSend","imageCreated","strict","newOptions","lastImageIdDrawn","isModalityLUTForDisplay","sopClassUid","convertToIntPixelData","floatPixelData","floatMinMax","floatRange","abs","intRange","slope","intercept","intPixelData","Uint16Array","i","rescaledPixel","floor","setPixelDataType","imageFrame","bitsAllocated","pixelData","Float32Array","pixelRepresentation","Int16Array","Uint8Array","createImage","transferSyntax","Promise","reject","Error","canvas","document","createElement","decodePromise","getMetaData","metaData","key","resolve","then","imagePlaneModule","voiLutModule","modalityLutModule","sopCommonModule","isColorImage","photometricInterpretation","height","rows","width","columns","context","getContext","imageData","createImageData","data","minMax","smallestPixelValue","largestPixelValue","image","color","columnPixelSpacing","pixelSpacing","rescaleIntercept","invert","minPixelValue","maxPixelValue","render","rowPixelSpacing","sizeInBytes","rescaleSlope","windowCenter","windowWidth","decodeTimeInMS","results","getPixelData","renderColorImage","getCanvas","putImageData","renderGrayscaleImage","modalityLUTSequence","sopClassUID","modalityLUT","voiLUTSequence","voiLUT","maxVoi","minVoi","getInfo","cacheSizeInBytes","loadedDataSets","promises","isLoaded","uri","dataSet","load","loadRequest","cacheCount","loadDICOMPromise","promise","dicomPart10AsArrayBuffer","byteArray","parseDicom","error","triggerEvent","events","action","cacheInfo","unload","numberOfDataSetsCached","Object","keys","default","getImagePixelModule","getLUTs","getModalityLUTOutputPixelRepresentation","getNumberValues","metaDataProvider","dataSetCacheManager","fileManager","getEncapsulatedImageFrame","getUncompressedImageFrame","loadFileRequest","loadImageFromPromise","getLoaderForScheme","loadImage","unpackBinaryFrame","register","getLutDescriptor","tag","elements","uint16","getLutData","lutDataSet","lutDescriptor","lut","lutData","dataOffset","populatePaletteColorLut","imagePixelModule","redPaletteColorLookupTableDescriptor","greenPaletteColorLookupTableDescriptor","bluePaletteColorLookupTableDescriptor","numLutEntries","x00281201","lutBitsAllocated","redPaletteColorLookupTableData","greenPaletteColorLookupTableData","bluePaletteColorLookupTableData","populateSmallestLargestPixelValues","int16","samplesPerPixel","string","bitsStored","highBit","planarConfiguration","pixelAspectRatio","x00281101","getLUT","numLUTEntries","firstValueMapped","numBitsPerEntry","id","lutSequence","items","luts","push","getMinStoredPixelValue","floatString","minStoredPixelValue","minModalityLutValue","x00283000","minimumLength","values","valueAsString","split","parseFloat","getNumberString","getNumberValue","findIndexOfString","metaDataManager","value","checkToken","token","endIndex","stringToUint8Array","str","uint","j","charCodeAt","offset","findBoundary","header","findContentType","trim","uint8ArrayToString","String","fromCharCode","mediaType","headers","accept","loadPromise","imageFrameAsArrayBuffer","response","tokenIndex","boundary","contentType","getTransferSyntaxForContentType","parameters","parameterIndex","parameter","parameterValues","start","Date","getTime","result","imagePromise","end","loadTimeInMS","cancelFn","getImageFrame","addDecodeTask","priority","transferList","transferPixelData","buffer","addTask","decodeImageFrame","nextTaskId","tasks","webWorkers","defaultConfig","maxWebWorkers","navigator","hardwareConcurrency","startWebWorkersOnDemand","webWorkerPath","webWorkerTaskPaths","taskConfiguration","decodeTask","loadCodecsOnStartup","initializeCodecsOnStartup","codecsPath","usePDFJS","config","statistics","numWebWorkers","numTasksQueued","numTasksExecuting","numTasksCompleted","totalTaskTimeInMS","totalTimeDelayedInMS","startTaskOnWebWorker","status","task","shift","added","worker","postMessage","taskType","workerIndex","spawnWebWorker","handleMessageFromWorker","msg","deferred","Worker","addEventListener","initialize","configObject","loadWebWorkerTask","sourcePath","taskConfig","assign","taskId","splice","setTaskPriority","cancelTask","reason","getStatistics","arrayBufferToString","binaryToString","apply","Array","prototype","slice","binary","decodeURIComponent","escape","_error","URIError","decodeJPEGBaseline8BitColor","imgBlob","Blob","type","fileReader","FileReader","readAsBinaryString","readAsArrayBuffer","onload","img","Image","drawImage","getImageData","onerror","src","window","btoa","e","photoMetricInterpretation","convertColorSpace","convertRGB","rgbaBuffer","convertYBRFull","isJPEGBaseline8BitColor","files","file","fileIndex","framesAreFragmented","numberOfFrames","intString","pixelDataElement","x7fe00010","fragments","basicOffsetTable","readEncapsulatedImageFrame","createJPEGBasicOffsetTable","readEncapsulatedPixelDataFromFragments","x7fe00008","pixelDataOffset","pixelsPerFrame","frameOffset","isBitSet","byte","bitPos","bytePos","parsedImageId","target","addDecache","imageLoadObject","decache","dataSetPromise","sharedCacheKey","callbacks","loadEnd","totalTimeInMS","imageDoneCallback","loadImageFromDataSet","loader","rgbIndex","rgbaIndex","rIndex","gIndex","bIndex","ybrIndex","y","cb","cr","yIndex","cbIndex","crIndex","rData","gData","bData","len","palIndex","rDataCleaned","convertLUTto8Bit","gDataCleaned","bDataCleaned","numEntries","cleanedLUT","Uint8ClampedArray","modality","seriesInstanceUID","seriesNumber","studyInstanceUID","seriesDate","parseDA","seriesTime","parseTM","patientAge","patientSize","patientWeight","imageOrientationPatient","imagePositionPatient","rowCosines","columnCosines","frameOfReferenceUID","sliceThickness","sliceLocation","rescaleType","modalityLUTOutputPixelRepresentation","x00283010","sopInstanceUID","radiopharmaceuticalInfo","x00540016","firstRadiopharmaceuticalInfoDataSet","radiopharmaceuticalStartTime","radionuclideTotalDose","radionuclideHalfLife","registerLoaders","params","xhr","XMLHttpRequest","open","responseType","forEach","setRequestHeader","onloadstart","event","eventData","onloadend","onreadystatechange","readyState","onprogress","oProgress","loaded","total","percentComplete","lengthComputable","round","send","registerImageLoader","addProvider","encapsulatedPixelData","configure"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;;;;;;;;AC5DA;;IAAYA,W;;AACZ;;;;;;;;AAFA;AAIA,IAAIC,oBAAJ;;AAEA,IAAMC,WAAW;AACf,MAAID,WAAJ,CAAiBE,EAAjB,EAAqB;AACnBF,kBAAcE,EAAd;;AAEA,mCAAgBF,WAAhB;AACD,GALc;AAMf,MAAIA,WAAJ,GAAmB;AACjB,WAAOA,WAAP;AACD;AARc,CAAjB;;QAWSD,W,GAAAA,W;QAAaE,Q,GAAAA,Q;;;;;;;;;;;;;;ACjBtB;;;;AACA;;;;AAEA,IAAME,WAAW;AACfC,kCADe;AAEfC,iCAFe;AAGfC;AAHe,CAAjB;;QAMSD,U;QAAYC,U;QAAYF,U;QAAYD,Q,GAAAA,Q;;;;;;;;;;;;ACT7C,SAASI,SAAT,CAAoBC,eAApB,EAAqC;AACnC;AACA;AACA;AACA,MAAIC,MAAMD,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A,MAAhB5G,UAAgB,uEAAH,CAAG;;AAC9C,MAAM8U,mBAAmBlO,QAAQoC,QAAR,CAAiB+L,SAAjB,IAA8BnO,QAAQoC,QAAR,CAAiBqM,SAAxE;;AAEA,MAAI,CAACP,gBAAL,EAAuB;AACrB,WAAO,IAAP;AACD;;AAED,MAAIA,iBAAiBwG,qBAArB,EAA4C;AAC1C,WAAO,yCAA0B1U,OAA1B,EAAmC5G,UAAnC,CAAP;AACD;;AAED,SAAO,yCAA0B4G,OAA1B,EAAmC5G,UAAnC,CAAP;AACD;;kBAEc0F,Y;;;;;;;;;;;;;kBCdA,UAAUpH,WAAV,EAAuB;AACpC;AACAA,cAAY8c,mBAAZ,CAAgC,UAAhC;AACA9c,cAAY8c,mBAAZ,CAAgC,SAAhC;AACA9c,cAAY8c,mBAAZ,CAAgC,WAAhC;;AAEA;AACA9c,cAAY8E,QAAZ,CAAqBiY,WAArB;AACD,C;;AAXD;;AACA,qC;;;;;;;;;;;;;ACDA;;AAEA,SAASE,SAAT,CAAoB1a,OAApB,EAA6B;AAC3B,yBAAWA,OAAX;AACD;;kBAEc0a,S","file":"cornerstoneWADOImageLoader.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"dicom-parser\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"cornerstoneWADOImageLoader\", [\"dicom-parser\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"cornerstoneWADOImageLoader\"] = factory(require(\"dicom-parser\"));\n\telse\n\t\troot[\"cornerstoneWADOImageLoader\"] = factory(root[\"dicomParser\"]);\n})(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_46__) {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 39);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap df4b22b327606a1b3dfa","/* eslint import/extensions:0 */\nimport * as dicomParser from 'dicom-parser';\nimport registerLoaders from './imageLoader/registerLoaders.js';\n\nlet cornerstone;\n\nconst external = {\n set cornerstone (cs) {\n cornerstone = cs;\n\n registerLoaders(cornerstone);\n },\n get cornerstone () {\n return cornerstone;\n }\n};\n\nexport { dicomParser, external };\n\n\n\n// WEBPACK FOOTER //\n// ./externalModules.js","import { default as xhrRequest } from './xhrRequest.js';\nimport { setOptions, getOptions } from './options.js';\n\nconst internal = {\n xhrRequest,\n setOptions,\n getOptions\n};\n\nexport { setOptions, getOptions, xhrRequest, internal };\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/internal/index.js","function getMinMax (storedPixelData) {\n // we always calculate the min max values since they are not always\n // present in DICOM and we don't want to trust them anyway as cornerstone\n // depends on us providing reliable values for these\n let min = storedPixelData[0];\n let max = storedPixelData[0];\n let storedPixel;\n const numPixels = storedPixelData.length;\n\n for (let index = 1; index < numPixels; index++) {\n storedPixel = storedPixelData[index];\n min = Math.min(min, storedPixel);\n max = Math.max(max, storedPixel);\n }\n\n return {\n min,\n max\n };\n}\n\nexport default getMinMax;\n\n\n\n// WEBPACK FOOTER //\n// ./shared/getMinMax.js","\n\n/**\n * Returns the raw value\n *\n * @param element - The javascript object for the specified element in the metadata\n * @param [index] - the index of the value in a multi-valued element, default is 0\n * @param [defaultValue] - The default value to return if the element does not exist\n * @returns {*}\n */\nfunction getValue (element, index, defaultValue) {\n index = index || 0;\n if (!element) {\n return defaultValue;\n }\n // Value is not present if the attribute has a zero length value\n if (!element.Value) {\n return defaultValue;\n }\n // make sure we have the specified index\n if (element.Value.length <= index) {\n return defaultValue;\n }\n\n return element.Value[index];\n}\n\nexport default getValue;\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadors/metaData/getValue.js","function parseImageId (imageId) {\n // build a url by parsing out the url scheme and frame index from the imageId\n const firstColonIndex = imageId.indexOf(':');\n let url = imageId.substring(firstColonIndex + 1);\n const frameIndex = url.indexOf('frame=');\n let frame;\n\n if (frameIndex !== -1) {\n const frameStr = url.substr(frameIndex + 6);\n\n frame = parseInt(frameStr, 10);\n url = url.substr(0, frameIndex - 1);\n }\n\n return {\n scheme: imageId.substr(0, firstColonIndex),\n url,\n frame\n };\n}\n\nexport default parseImageId;\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadouri/parseImageId.js","\n\nlet imageIds = [];\n\nfunction add (imageId, metadata) {\n imageIds[imageId] = metadata;\n}\n\nfunction get (imageId) {\n return imageIds[imageId];\n}\n\nfunction remove (imageId) {\n imageIds[imageId] = undefined;\n}\n\nfunction purge () {\n imageIds = [];\n}\n\nexport default {\n add,\n get,\n remove,\n purge\n};\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadors/metaDataManager.js","let options = {\n // callback allowing customization of the xhr (e.g. adding custom auth headers, cors, etc)\n beforeSend (/* xhr, imageId */) {\n },\n // callback allowing modification of newly created image objects\n imageCreated (/* image */) {\n },\n strict: false\n};\n\nexport function setOptions (newOptions) {\n options = newOptions;\n}\n\nexport function getOptions () {\n return options;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/internal/options.js","import { external } from '../externalModules.js';\nimport getImageFrame from './getImageFrame.js';\nimport decodeImageFrame from './decodeImageFrame.js';\nimport isColorImageFn from './isColorImage.js';\nimport convertColorSpace from './convertColorSpace.js';\nimport getMinMax from '../shared/getMinMax.js';\nimport isJPEGBaseline8BitColor from './isJPEGBaseline8BitColor.js';\n\nlet lastImageIdDrawn = '';\n\nfunction isModalityLUTForDisplay(sopClassUid) {\n // special case for XA and XRF\n // https://groups.google.com/forum/#!searchin/comp.protocols.dicom/Modality$20LUT$20XA/comp.protocols.dicom/UBxhOZ2anJ0/D0R_QP8V2wIJ\n return (\n sopClassUid !== '1.2.840.10008.5.1.4.1.1.12.1' && // XA\n sopClassUid !== '1.2.840.10008.5.1.4.1.1.12.2.1'\n ); // XRF\n}\n\nfunction convertToIntPixelData(floatPixelData) {\n const floatMinMax = getMinMax(floatPixelData);\n const floatRange = Math.abs(floatMinMax.max - floatMinMax.min);\n const intRange = 65535;\n const slope = floatRange / intRange;\n const intercept = floatMinMax.min;\n const numPixels = floatPixelData.length;\n const intPixelData = new Uint16Array(numPixels);\n let min = 65535;\n let max = 0;\n\n for (let i = 0; i < numPixels; i++) {\n const rescaledPixel = Math.floor((floatPixelData[i] - intercept) / slope);\n\n intPixelData[i] = rescaledPixel;\n min = Math.min(min, rescaledPixel);\n max = Math.max(max, rescaledPixel);\n }\n\n return {\n min,\n max,\n intPixelData,\n slope,\n intercept\n };\n}\n\n/**\n * Helper function to set pixel data to the right typed array. This is needed because web workers\n * can transfer array buffers but not typed arrays\n * @param imageFrame\n */\nfunction setPixelDataType(imageFrame) {\n if (imageFrame.bitsAllocated === 32) {\n imageFrame.pixelData = new Float32Array(imageFrame.pixelData);\n } else if (imageFrame.bitsAllocated === 16) {\n if (imageFrame.pixelRepresentation === 0) {\n imageFrame.pixelData = new Uint16Array(imageFrame.pixelData);\n } else {\n imageFrame.pixelData = new Int16Array(imageFrame.pixelData);\n }\n } else {\n imageFrame.pixelData = new Uint8Array(imageFrame.pixelData);\n }\n}\n\nfunction createImage (imageId, pixelData, transferSyntax, options) {\n if (!pixelData || !pixelData.length) {\n return Promise.reject(new Error('The file does not contain image data.'));\n }\n\n const cornerstone = external.cornerstone;\n const canvas = document.createElement('canvas');\n const imageFrame = getImageFrame(imageId);\n const decodePromise = decodeImageFrame(\n imageFrame,\n transferSyntax,\n pixelData,\n canvas,\n options\n );\n const getMetaData = key => cornerstone.metaData.get(key, imageId) || {};\n\n return new Promise((resolve, reject) => {\n decodePromise.then(imageFrame => {\n const imagePlaneModule = getMetaData('imagePlaneModule');\n const voiLutModule = getMetaData('voiLutModule');\n const modalityLutModule = getMetaData('modalityLutModule');\n const sopCommonModule = getMetaData('sopCommonModule');\n const isColorImage = isColorImageFn(imageFrame.photometricInterpretation);\n\n // JPEGBaseline (8 bits) is already returning the pixel data in the right format (rgba)\n // because it's using a canvas to load and decode images.\n if (!isJPEGBaseline8BitColor(imageFrame, transferSyntax)) {\n setPixelDataType(imageFrame);\n\n // convert color space\n if (isColorImage) {\n // setup the canvas context\n canvas.height = imageFrame.rows;\n canvas.width = imageFrame.columns;\n\n const context = canvas.getContext('2d');\n const imageData = context.createImageData(\n imageFrame.columns,\n imageFrame.rows\n );\n\n convertColorSpace(imageFrame, imageData);\n imageFrame.imageData = imageData;\n imageFrame.pixelData = imageData.data;\n\n // calculate smallest and largest PixelValue of the converted pixelData\n const minMax = getMinMax(imageFrame.pixelData);\n\n imageFrame.smallestPixelValue = minMax.min;\n imageFrame.largestPixelValue = minMax.max;\n }\n }\n\n const image = {\n imageId,\n color: isColorImage,\n columnPixelSpacing: imagePlaneModule.pixelSpacing\n ? imagePlaneModule.pixelSpacing[1]\n : undefined,\n columns: imageFrame.columns,\n height: imageFrame.rows,\n intercept: modalityLutModule.rescaleIntercept\n ? modalityLutModule.rescaleIntercept\n : 0,\n invert: imageFrame.photometricInterpretation === 'MONOCHROME1',\n minPixelValue: imageFrame.smallestPixelValue,\n maxPixelValue: imageFrame.largestPixelValue,\n render: undefined, // set below\n rowPixelSpacing: imagePlaneModule.pixelSpacing\n ? imagePlaneModule.pixelSpacing[0]\n : undefined,\n rows: imageFrame.rows,\n sizeInBytes: imageFrame.pixelData.length,\n slope: modalityLutModule.rescaleSlope\n ? modalityLutModule.rescaleSlope\n : 1,\n width: imageFrame.columns,\n windowCenter: voiLutModule.windowCenter\n ? voiLutModule.windowCenter[0]\n : undefined,\n windowWidth: voiLutModule.windowWidth\n ? voiLutModule.windowWidth[0]\n : undefined,\n decodeTimeInMS: imageFrame.decodeTimeInMS,\n floatPixelData: undefined\n };\n\n // add function to return pixel data\n if (imageFrame.pixelData instanceof Float32Array) {\n const floatPixelData = imageFrame.pixelData;\n const results = convertToIntPixelData(floatPixelData);\n\n image.minPixelValue = results.min;\n image.maxPixelValue = results.max;\n image.slope = results.slope;\n image.intercept = results.intercept;\n image.floatPixelData = floatPixelData;\n image.getPixelData = () => results.intPixelData;\n } else {\n image.getPixelData = () => imageFrame.pixelData;\n }\n\n // Setup the renderer\n if (image.color) {\n image.render = cornerstone.renderColorImage;\n image.getCanvas = function() {\n if (lastImageIdDrawn === imageId) {\n return canvas;\n }\n\n canvas.height = image.rows;\n canvas.width = image.columns;\n const context = canvas.getContext('2d');\n\n context.putImageData(imageFrame.imageData, 0, 0);\n lastImageIdDrawn = imageId;\n\n return canvas;\n };\n } else {\n image.render = cornerstone.renderGrayscaleImage;\n }\n\n // Modality LUT\n if (\n modalityLutModule.modalityLUTSequence &&\n modalityLutModule.modalityLUTSequence.length > 0 &&\n isModalityLUTForDisplay(sopCommonModule.sopClassUID)\n ) {\n image.modalityLUT = modalityLutModule.modalityLUTSequence[0];\n }\n\n // VOI LUT\n if (\n voiLutModule.voiLUTSequence &&\n voiLutModule.voiLUTSequence.length > 0\n ) {\n image.voiLUT = voiLutModule.voiLUTSequence[0];\n }\n\n if (image.color) {\n image.windowWidth = 255;\n image.windowCenter = 127;\n }\n\n // set the ww/wc to cover the dynamic range of the image if no values are supplied\n if (image.windowCenter === undefined || image.windowWidth === undefined) {\n const maxVoi = image.maxPixelValue * image.slope + image.intercept;\n const minVoi = image.minPixelValue * image.slope + image.intercept;\n\n image.windowWidth = maxVoi - minVoi;\n image.windowCenter = (maxVoi + minVoi) / 2;\n }\n\n resolve(image);\n }, reject);\n });\n}\n\nexport default createImage;\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/createImage.js","import { dicomParser, external } from '../../externalModules.js';\nimport { xhrRequest } from '../internal/index.js';\n\n/**\n * This object supports loading of DICOM P10 dataset from a uri and caching it so it can be accessed\n * by the caller. This allows a caller to access the datasets without having to go through cornerstone's\n * image loader mechanism. One reason a caller may need to do this is to determine the number of frames\n * in a multiframe sop instance so it can create the imageId's correctly.\n */\nlet cacheSizeInBytes = 0;\n\nlet loadedDataSets = {};\nlet promises = {};\n\n// returns true if the wadouri for the specified index has been loaded\nfunction isLoaded (uri) {\n return loadedDataSets[uri] !== undefined;\n}\n\nfunction get (uri) {\n if (!loadedDataSets[uri]) {\n return;\n }\n\n return loadedDataSets[uri].dataSet;\n}\n\n\n// loads the dicom dataset from the wadouri sp\nfunction load (uri, loadRequest = xhrRequest, imageId) {\n const cornerstone = external.cornerstone;\n\n // if already loaded return it right away\n if (loadedDataSets[uri]) {\n // console.log('using loaded dataset ' + uri);\n return new Promise((resolve) => {\n loadedDataSets[uri].cacheCount++;\n resolve(loadedDataSets[uri].dataSet);\n });\n }\n\n // if we are currently loading this uri, increment the cacheCount and return its promise\n if (promises[uri]) {\n // console.log('returning existing load promise for ' + uri);\n promises[uri].cacheCount++;\n\n return promises[uri];\n }\n\n // This uri is not loaded or being loaded, load it via an xhrRequest\n const loadDICOMPromise = loadRequest(uri, imageId);\n\n // handle success and failure of the XHR request load\n const promise = new Promise((resolve, reject) => {\n loadDICOMPromise.then(function (dicomPart10AsArrayBuffer/* , xhr*/) {\n const byteArray = new Uint8Array(dicomPart10AsArrayBuffer);\n\n // Reject the promise if parsing the dicom file fails\n let dataSet;\n\n try {\n dataSet = dicomParser.parseDicom(byteArray);\n } catch (error) {\n return reject(error);\n }\n\n loadedDataSets[uri] = {\n dataSet,\n cacheCount: promise.cacheCount\n };\n cacheSizeInBytes += dataSet.byteArray.length;\n resolve(dataSet);\n\n cornerstone.triggerEvent(cornerstone.events, 'datasetscachechanged', {\n uri,\n action: 'loaded',\n cacheInfo: getInfo()\n });\n }, reject).then(() => {\n // Remove the promise if success\n delete promises[uri];\n }, () => {\n // Remove the promise if failure\n delete promises[uri];\n });\n });\n\n promise.cacheCount = 1;\n\n promises[uri] = promise;\n\n return promise;\n}\n\n// remove the cached/loaded dicom dataset for the specified wadouri to free up memory\nfunction unload (uri) {\n const cornerstone = external.cornerstone;\n\n // console.log('unload for ' + uri);\n if (loadedDataSets[uri]) {\n loadedDataSets[uri].cacheCount--;\n if (loadedDataSets[uri].cacheCount === 0) {\n // console.log('removing loaded dataset for ' + uri);\n cacheSizeInBytes -= loadedDataSets[uri].dataSet.byteArray.length;\n delete loadedDataSets[uri];\n\n cornerstone.triggerEvent(cornerstone.events, 'datasetscachechanged', {\n uri,\n action: 'unloaded',\n cacheInfo: getInfo()\n });\n }\n }\n}\n\nexport function getInfo () {\n return {\n cacheSizeInBytes,\n numberOfDataSetsCached: Object.keys(loadedDataSets).length\n };\n}\n\n// removes all cached datasets from memory\nfunction purge () {\n loadedDataSets = {};\n promises = {};\n}\n\nexport default {\n isLoaded,\n load,\n unload,\n getInfo,\n purge,\n get\n};\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadouri/dataSetCacheManager.js","export default '2.0.0';\n\n\n\n// WEBPACK FOOTER //\n// ./version.js","export { default as convertRGBColorByPixel } from './convertRGBColorByPixel.js';\nexport { default as convertRGBColorByPlane } from './convertRGBColorByPlane.js';\nexport { default as convertYBRFullByPixel } from './convertYBRFullByPixel.js';\nexport { default as convertYBRFullByPlane } from './convertYBRFullByPlane.js';\nexport { default as convertPALETTECOLOR } from './convertPALETTECOLOR.js';\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/colorSpaceConverters/index.js","import { getImagePixelModule,\n getLUTs,\n getModalityLUTOutputPixelRepresentation,\n getNumberValues,\n metaDataProvider } from './metaData/index.js';\n\nimport dataSetCacheManager from './dataSetCacheManager.js';\nimport fileManager from './fileManager.js';\nimport getEncapsulatedImageFrame from './getEncapsulatedImageFrame.js';\nimport getUncompressedImageFrame from './getUncompressedImageFrame.js';\nimport loadFileRequest from './loadFileRequest.js';\nimport { loadImageFromPromise,\n getLoaderForScheme,\n loadImage } from './loadImage.js';\nimport parseImageId from './parseImageId.js';\nimport unpackBinaryFrame from './unpackBinaryFrame.js';\nimport register from './register.js';\n\nconst metaData = {\n getImagePixelModule,\n getLUTs,\n getModalityLUTOutputPixelRepresentation,\n getNumberValues,\n metaDataProvider\n};\n\nexport default {\n metaData,\n dataSetCacheManager,\n fileManager,\n getEncapsulatedImageFrame,\n getUncompressedImageFrame,\n loadFileRequest,\n loadImageFromPromise,\n getLoaderForScheme,\n loadImage,\n parseImageId,\n unpackBinaryFrame,\n register\n};\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadouri/index.js","export { default as getImagePixelModule } from './getImagePixelModule.js';\nexport { default as getLUTs } from './getLUTs.js';\nexport { default as getModalityLUTOutputPixelRepresentation } from './getModalityLUTOutputPixelRepresentation.js';\nexport { default as getNumberValues } from './getNumberValues.js';\nexport { default as metaDataProvider } from './metaDataProvider.js';\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadouri/metaData/index.js","function getLutDescriptor (dataSet, tag) {\n if (!dataSet.elements[tag] || dataSet.elements[tag].length !== 6) {\n return;\n }\n\n return [dataSet.uint16(tag, 0), dataSet.uint16(tag, 1), dataSet.uint16(tag, 2)];\n}\n\nfunction getLutData (lutDataSet, tag, lutDescriptor) {\n const lut = [];\n const lutData = lutDataSet.elements[tag];\n\n for (let i = 0; i < lutDescriptor[0]; i++) {\n // Output range is always unsigned\n if (lutDescriptor[2] === 16) {\n lut[i] = lutDataSet.uint16(tag, i);\n } else {\n lut[i] = lutDataSet.byteArray[i + lutData.dataOffset];\n }\n }\n\n return lut;\n}\n\nfunction populatePaletteColorLut (dataSet, imagePixelModule) {\n imagePixelModule.redPaletteColorLookupTableDescriptor = getLutDescriptor(dataSet, 'x00281101');\n imagePixelModule.greenPaletteColorLookupTableDescriptor = getLutDescriptor(dataSet, 'x00281102');\n imagePixelModule.bluePaletteColorLookupTableDescriptor = getLutDescriptor(dataSet, 'x00281103');\n\n // The first Palette Color Lookup Table Descriptor value is the number of entries in the lookup table.\n // When the number of table entries is equal to 2ˆ16 then this value shall be 0.\n // See http://dicom.nema.org/MEDICAL/DICOM/current/output/chtml/part03/sect_C.7.6.3.html#sect_C.7.6.3.1.5\n if (imagePixelModule.redPaletteColorLookupTableDescriptor[0] === 0) {\n imagePixelModule.redPaletteColorLookupTableDescriptor[0] = 65536;\n imagePixelModule.greenPaletteColorLookupTableDescriptor[0] = 65536;\n imagePixelModule.bluePaletteColorLookupTableDescriptor[0] = 65536;\n }\n\n // The third Palette Color Lookup Table Descriptor value specifies the number of bits for each entry in the Lookup Table Data.\n // It shall take the value of 8 or 16.\n // The LUT Data shall be stored in a format equivalent to 8 bits allocated when the number of bits for each entry is 8, and 16 bits allocated when the number of bits for each entry is 16, where in both cases the high bit is equal to bits allocated-1.\n // The third value shall be identical for each of the Red, Green and Blue Palette Color Lookup Table Descriptors.\n //\n // Note: Some implementations have encoded 8 bit entries with 16 bits allocated, padding the high bits;\n // this can be detected by comparing the number of entries specified in the LUT Descriptor with the actual value length of the LUT Data entry.\n // The value length in bytes should equal the number of entries if bits allocated is 8, and be twice as long if bits allocated is 16.\n const numLutEntries = imagePixelModule.redPaletteColorLookupTableDescriptor[0];\n const lutData = dataSet.elements.x00281201;\n const lutBitsAllocated = lutData.length === numLutEntries ? 8 : 16;\n\n // If the descriptors do not appear to have the correct values, correct them\n if (imagePixelModule.redPaletteColorLookupTableDescriptor[2] !== lutBitsAllocated) {\n imagePixelModule.redPaletteColorLookupTableDescriptor[2] = lutBitsAllocated;\n imagePixelModule.greenPaletteColorLookupTableDescriptor[2] = lutBitsAllocated;\n imagePixelModule.bluePaletteColorLookupTableDescriptor[2] = lutBitsAllocated;\n }\n\n imagePixelModule.redPaletteColorLookupTableData = getLutData(dataSet, 'x00281201', imagePixelModule.redPaletteColorLookupTableDescriptor);\n imagePixelModule.greenPaletteColorLookupTableData = getLutData(dataSet, 'x00281202', imagePixelModule.greenPaletteColorLookupTableDescriptor);\n imagePixelModule.bluePaletteColorLookupTableData = getLutData(dataSet, 'x00281203', imagePixelModule.bluePaletteColorLookupTableDescriptor);\n}\n\nfunction populateSmallestLargestPixelValues (dataSet, imagePixelModule) {\n const pixelRepresentation = dataSet.uint16('x00280103');\n\n if (pixelRepresentation === 0) {\n imagePixelModule.smallestPixelValue = dataSet.uint16('x00280106');\n imagePixelModule.largestPixelValue = dataSet.uint16('x00280107');\n } else {\n imagePixelModule.smallestPixelValue = dataSet.int16('x00280106');\n imagePixelModule.largestPixelValue = dataSet.int16('x00280107');\n }\n}\n\nfunction getImagePixelModule (dataSet) {\n const imagePixelModule = {\n samplesPerPixel: dataSet.uint16('x00280002'),\n photometricInterpretation: dataSet.string('x00280004'),\n rows: dataSet.uint16('x00280010'),\n columns: dataSet.uint16('x00280011'),\n bitsAllocated: dataSet.uint16('x00280100'),\n bitsStored: dataSet.uint16('x00280101'),\n highBit: dataSet.uint16('x00280102'),\n pixelRepresentation: dataSet.uint16('x00280103'),\n planarConfiguration: dataSet.uint16('x00280006'),\n pixelAspectRatio: dataSet.string('x00280034')\n };\n\n populateSmallestLargestPixelValues(dataSet, imagePixelModule);\n\n if (imagePixelModule.photometricInterpretation === 'PALETTE COLOR' && dataSet.elements.x00281101) {\n populatePaletteColorLut(dataSet, imagePixelModule);\n }\n\n return imagePixelModule;\n}\n\nexport default getImagePixelModule;\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadouri/metaData/getImagePixelModule.js","function getLUT (pixelRepresentation, lutDataSet) {\n let numLUTEntries = lutDataSet.uint16('x00283002', 0);\n\n if (numLUTEntries === 0) {\n numLUTEntries = 65535;\n }\n let firstValueMapped = 0;\n\n if (pixelRepresentation === 0) {\n firstValueMapped = lutDataSet.uint16('x00283002', 1);\n } else {\n firstValueMapped = lutDataSet.int16('x00283002', 1);\n }\n const numBitsPerEntry = lutDataSet.uint16('x00283002', 2);\n // console.log('LUT(', numLUTEntries, ',', firstValueMapped, ',', numBitsPerEntry, ')');\n const lut = {\n id: '1',\n firstValueMapped,\n numBitsPerEntry,\n lut: []\n };\n\n // console.log(\"minValue=\", minValue, \"; maxValue=\", maxValue);\n for (let i = 0; i < numLUTEntries; i++) {\n if (pixelRepresentation === 0) {\n lut.lut[i] = lutDataSet.uint16('x00283006', i);\n } else {\n lut.lut[i] = lutDataSet.int16('x00283006', i);\n }\n }\n\n return lut;\n}\n\n\nfunction getLUTs (pixelRepresentation, lutSequence) {\n if (!lutSequence || !lutSequence.items.length) {\n return;\n }\n const luts = [];\n\n for (let i = 0; i < lutSequence.items.length; i++) {\n const lutDataSet = lutSequence.items[i].dataSet;\n const lut = getLUT(pixelRepresentation, lutDataSet);\n\n if (lut) {\n luts.push(lut);\n }\n }\n\n return luts;\n}\n\nexport default getLUTs;\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadouri/metaData/getLUTs.js","/* eslint no-bitwise: 0 */\n\nfunction getMinStoredPixelValue (dataSet) {\n const pixelRepresentation = dataSet.uint16('x00280103');\n const bitsStored = dataSet.uint16('x00280101');\n\n if (pixelRepresentation === 0) {\n return 0;\n }\n\n return -1 << (bitsStored - 1);\n}\n\n// 0 = unsigned / US, 1 = signed / SS\nfunction getModalityLUTOutputPixelRepresentation (dataSet) {\n\n // CT SOP Classes are always signed\n const sopClassUID = dataSet.string('x00080016');\n\n if (sopClassUID === '1.2.840.10008.5.1.4.1.1.2' ||\n sopClassUID === '1.2.840.10008.5.1.4.1.1.2.1') {\n return 1;\n }\n\n // if rescale intercept and rescale slope are present, pass the minimum stored\n // pixel value through them to see if we get a signed output range\n const rescaleIntercept = dataSet.floatString('x00281052');\n const rescaleSlope = dataSet.floatString('x00281053');\n\n if (rescaleIntercept !== undefined && rescaleSlope !== undefined) {\n const minStoredPixelValue = getMinStoredPixelValue(dataSet); //\n const minModalityLutValue = minStoredPixelValue * rescaleSlope + rescaleIntercept;\n\n if (minModalityLutValue < 0) {\n return 1;\n }\n\n return 0;\n\n }\n\n // Output of non linear modality lut is always unsigned\n if (dataSet.elements.x00283000 && dataSet.elements.x00283000.length > 0) {\n return 0;\n }\n\n // If no modality lut transform, output is same as pixel representation\n return dataSet.uint16('x00280103');\n}\n\nexport default getModalityLUTOutputPixelRepresentation;\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadouri/metaData/getModalityLUTOutputPixelRepresentation.js","function getNumberValues (dataSet, tag, minimumLength) {\n const values = [];\n const valueAsString = dataSet.string(tag);\n\n if (!valueAsString) {\n return;\n }\n const split = valueAsString.split('\\\\');\n\n if (minimumLength && split.length < minimumLength) {\n return;\n }\n for (let i = 0; i < split.length; i++) {\n values.push(parseFloat(split[i]));\n }\n\n return values;\n}\n\nexport default getNumberValues;\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadouri/metaData/getNumberValues.js","import { getNumberString,\n getNumberValue,\n getNumberValues,\n getValue,\n metaDataProvider } from './metaData/index.js';\n\nimport findIndexOfString from './findIndexOfString.js';\nimport getPixelData from './getPixelData.js';\nimport metaDataManager from './metaDataManager.js';\nimport loadImage from './loadImage.js';\nimport register from './register.js';\n\nconst metaData = {\n getNumberString,\n getNumberValue,\n getNumberValues,\n getValue,\n metaDataProvider\n};\n\nexport default {\n metaData,\n findIndexOfString,\n getPixelData,\n loadImage,\n metaDataManager,\n register\n};\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadors/index.js","export { default as getNumberString } from './getNumberString.js';\nexport { default as getNumberValue } from './getNumberValue.js';\nexport { default as getNumberValues } from './getNumberValues.js';\nexport { default as getValue } from './getValue.js';\nexport { default as metaDataProvider } from './metaDataProvider.js';\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadors/metaData/index.js","import getValue from './getValue.js';\n\nfunction getNumberValue (element, index) {\n const value = getValue(element, index);\n\n if (value === undefined) {\n return;\n }\n\n return parseFloat(value);\n}\n\nexport default getNumberValue;\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadors/metaData/getNumberValue.js","\n\n/**\n * Returns the values as an array of javascript numbers\n *\n * @param element - The javascript object for the specified element in the metadata\n * @param [minimumLength] - the minimum number of values\n * @returns {*}\n */\nfunction getNumberValues (element, minimumLength) {\n if (!element) {\n return;\n }\n // Value is not present if the attribute has a zero length value\n if (!element.Value) {\n return;\n }\n // make sure we have the expected length\n if (minimumLength && element.Value.length < minimumLength) {\n return;\n }\n\n const values = [];\n\n for (let i = 0; i < element.Value.length; i++) {\n values.push(parseFloat(element.Value[i]));\n }\n\n return values;\n}\n\nexport default getNumberValues;\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadors/metaData/getNumberValues.js","function checkToken (token, data, dataOffset) {\n\n if (dataOffset + token.length > data.length) {\n return false;\n }\n\n let endIndex = dataOffset;\n\n for (let i = 0; i < token.length; i++) {\n if (token[i] !== data[endIndex++]) {\n return false;\n }\n }\n\n return true;\n}\n\nfunction stringToUint8Array (str) {\n const uint = new Uint8Array(str.length);\n\n for (let i = 0, j = str.length; i < j; i++) {\n uint[i] = str.charCodeAt(i);\n }\n\n return uint;\n}\n\nfunction findIndexOfString (data, str, offset) {\n\n offset = offset || 0;\n\n const token = stringToUint8Array(str);\n\n for (let i = offset; i < data.length; i++) {\n if (token[0] === data[i]) {\n // console.log('match @', i);\n if (checkToken(token, data, i)) {\n return i;\n }\n }\n }\n\n return -1;\n}\nexport default findIndexOfString;\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadors/findIndexOfString.js","import { xhrRequest } from '../internal/index.js';\nimport findIndexOfString from './findIndexOfString.js';\n\nfunction findBoundary (header) {\n for (let i = 0; i < header.length; i++) {\n if (header[i].substr(0, 2) === '--') {\n return header[i];\n }\n }\n}\n\nfunction findContentType (header) {\n for (let i = 0; i < header.length; i++) {\n if (header[i].substr(0, 13) === 'Content-Type:') {\n return header[i].substr(13).trim();\n }\n }\n}\n\nfunction uint8ArrayToString (data, offset, length) {\n offset = offset || 0;\n length = length || data.length - offset;\n let str = '';\n\n for (let i = offset; i < offset + length; i++) {\n str += String.fromCharCode(data[i]);\n }\n\n return str;\n}\n\nfunction getPixelData (uri, imageId, mediaType = 'application/octet-stream') {\n const headers = {\n accept: mediaType\n };\n\n return new Promise((resolve, reject) => {\n const loadPromise = xhrRequest(uri, imageId, headers);\n\n loadPromise.then(function (imageFrameAsArrayBuffer/* , xhr*/) {\n\n // request succeeded, Parse the multi-part mime response\n const response = new Uint8Array(imageFrameAsArrayBuffer);\n\n // First look for the multipart mime header\n const tokenIndex = findIndexOfString(response, '\\r\\n\\r\\n');\n\n if (tokenIndex === -1) {\n reject(new Error('invalid response - no multipart mime header'));\n }\n const header = uint8ArrayToString(response, 0, tokenIndex);\n // Now find the boundary marker\n const split = header.split('\\r\\n');\n const boundary = findBoundary(split);\n\n if (!boundary) {\n reject(new Error('invalid response - no boundary marker'));\n }\n const offset = tokenIndex + 4; // skip over the \\r\\n\\r\\n\n\n // find the terminal boundary marker\n const endIndex = findIndexOfString(response, boundary, offset);\n\n if (endIndex === -1) {\n reject(new Error('invalid response - terminating boundary not found'));\n }\n\n // Remove \\r\\n from the length\n const length = endIndex - offset - 2;\n\n // return the info for this pixel data\n resolve({\n contentType: findContentType(split),\n imageFrame: {\n pixelData: new Uint8Array(imageFrameAsArrayBuffer, offset, length)\n }\n });\n });\n });\n}\n\nexport default getPixelData;\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadors/getPixelData.js","import metaDataManager from './metaDataManager.js';\nimport getPixelData from './getPixelData.js';\nimport createImage from '../createImage.js';\n\n/**\n * Helper method to extract the transfer-syntax from the response of the server.\n * @param {string} contentType The value of the content-type header as returned by the WADO-RS server.\n * @return The transfer-syntax as announced by the server, or Implicit Little Endian by default.\n */\nexport function getTransferSyntaxForContentType (contentType) {\n let transferSyntax = '1.2.840.10008.1.2'; // Default is Implicit Little Endian.\n\n if (contentType) {\n // Browse through the content type parameters\n const parameters = contentType.split(';');\n\n for (const parameterIndex in parameters) {\n let parameter = parameters[parameterIndex];\n \n // Look for a transfer-syntax=XXXX pair\n const parameterValues = parameter.split('=');\n\n if (parameterValues.length !== 2) {\n continue;\n }\n\n if (parameterValues[0].trim() === 'transfer-syntax') {\n transferSyntax = parameterValues[1].trim() || transferSyntax;\n }\n }\n }\n\n return transferSyntax;\n}\n\nfunction loadImage (imageId, options) {\n const start = new Date().getTime();\n const uri = imageId.substring(7);\n\n const promise = new Promise((resolve, reject) => {\n // check to make sure we have metadata for this imageId\n const metaData = metaDataManager.get(imageId);\n\n if (metaData === undefined) {\n const error = new Error(`no metadata for imageId ${imageId}`);\n\n return reject(error);\n }\n\n // TODO: load bulk data items that we might need\n const mediaType = 'multipart/related; type=\"application/octet-stream\"'; // 'image/dicom+jp2';\n\n // get the pixel data from the server\n getPixelData(uri, imageId, mediaType).then((result) => {\n const transferSyntax = getTransferSyntaxForContentType(result.contentType);\n const pixelData = result.imageFrame.pixelData;\n const imagePromise = createImage(imageId, pixelData, transferSyntax, options);\n\n imagePromise.then((image) => {\n // add the loadTimeInMS property\n const end = new Date().getTime();\n\n image.loadTimeInMS = end - start;\n resolve(image);\n }, reject);\n }, reject);\n });\n\n return {\n promise,\n cancelFn: undefined\n };\n}\n\nexport default loadImage;\n\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadors/loadImage.js","import { external } from '../externalModules.js';\n\nfunction getImageFrame (imageId) {\n const imagePixelModule = external.cornerstone.metaData.get('imagePixelModule', imageId);\n\n return {\n samplesPerPixel: imagePixelModule.samplesPerPixel,\n photometricInterpretation: imagePixelModule.photometricInterpretation,\n planarConfiguration: imagePixelModule.planarConfiguration,\n rows: imagePixelModule.rows,\n columns: imagePixelModule.columns,\n bitsAllocated: imagePixelModule.bitsAllocated,\n bitsStored: imagePixelModule.bitsStored,\n pixelRepresentation: imagePixelModule.pixelRepresentation, // 0 = unsigned,\n smallestPixelValue: imagePixelModule.smallestPixelValue,\n largestPixelValue: imagePixelModule.largestPixelValue,\n redPaletteColorLookupTableDescriptor: imagePixelModule.redPaletteColorLookupTableDescriptor,\n greenPaletteColorLookupTableDescriptor: imagePixelModule.greenPaletteColorLookupTableDescriptor,\n bluePaletteColorLookupTableDescriptor: imagePixelModule.bluePaletteColorLookupTableDescriptor,\n redPaletteColorLookupTableData: imagePixelModule.redPaletteColorLookupTableData,\n greenPaletteColorLookupTableData: imagePixelModule.greenPaletteColorLookupTableData,\n bluePaletteColorLookupTableData: imagePixelModule.bluePaletteColorLookupTableData,\n pixelData: undefined // populated later after decoding\n };\n}\n\nexport default getImageFrame;\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/getImageFrame.js","import webWorkerManager from './webWorkerManager.js';\nimport decodeJPEGBaseline8BitColor from './decodeJPEGBaseline8BitColor.js';\n\nfunction addDecodeTask (imageFrame, transferSyntax, pixelData, options) {\n const priority = options.priority || undefined;\n const transferList = options.transferPixelData ? [pixelData.buffer] : undefined;\n\n return webWorkerManager.addTask(\n 'decodeTask',\n {\n imageFrame,\n transferSyntax,\n pixelData,\n options\n }, priority, transferList).promise;\n}\n\nfunction decodeImageFrame (imageFrame, transferSyntax, pixelData, canvas, options = {}) {\n // TODO: Turn this into a switch statement instead\n if (transferSyntax === '1.2.840.10008.1.2') {\n // Implicit VR Little Endian\n return addDecodeTask(imageFrame, transferSyntax, pixelData, options);\n } else if (transferSyntax === '1.2.840.10008.1.2.1') {\n // Explicit VR Little Endian\n return addDecodeTask(imageFrame, transferSyntax, pixelData, options);\n } else if (transferSyntax === '1.2.840.10008.1.2.2') {\n // Explicit VR Big Endian (retired)\n return addDecodeTask(imageFrame, transferSyntax, pixelData, options);\n } else if (transferSyntax === '1.2.840.10008.1.2.1.99') {\n // Deflate transfer syntax (deflated by dicomParser)\n return addDecodeTask(imageFrame, transferSyntax, pixelData, options);\n } else if (transferSyntax === '1.2.840.10008.1.2.5') {\n // RLE Lossless\n return addDecodeTask(imageFrame, transferSyntax, pixelData, options);\n } else if (transferSyntax === '1.2.840.10008.1.2.4.50') {\n // JPEG Baseline lossy process 1 (8 bit)\n\n // Handle 8-bit JPEG Baseline color images using the browser's built-in\n // JPEG decoding\n if (imageFrame.bitsAllocated === 8 &&\n (imageFrame.samplesPerPixel === 3 || imageFrame.samplesPerPixel === 4)) {\n return decodeJPEGBaseline8BitColor(imageFrame, pixelData, canvas);\n }\n\n return addDecodeTask(imageFrame, transferSyntax, pixelData, options);\n } else if (transferSyntax === '1.2.840.10008.1.2.4.51') {\n // JPEG Baseline lossy process 2 & 4 (12 bit)\n return addDecodeTask(imageFrame, transferSyntax, pixelData, options);\n } else if (transferSyntax === '1.2.840.10008.1.2.4.57') {\n // JPEG Lossless, Nonhierarchical (Processes 14)\n return addDecodeTask(imageFrame, transferSyntax, pixelData, options);\n } else if (transferSyntax === '1.2.840.10008.1.2.4.70') {\n // JPEG Lossless, Nonhierarchical (Processes 14 [Selection 1])\n return addDecodeTask(imageFrame, transferSyntax, pixelData, options);\n } else if (transferSyntax === '1.2.840.10008.1.2.4.80') {\n // JPEG-LS Lossless Image Compression\n return addDecodeTask(imageFrame, transferSyntax, pixelData, options);\n } else if (transferSyntax === '1.2.840.10008.1.2.4.81') {\n // JPEG-LS Lossy (Near-Lossless) Image Compression\n return addDecodeTask(imageFrame, transferSyntax, pixelData, options);\n } else if (transferSyntax === '1.2.840.10008.1.2.4.90') {\n // JPEG 2000 Lossless\n return addDecodeTask(imageFrame, transferSyntax, pixelData, options);\n } else if (transferSyntax === '1.2.840.10008.1.2.4.91') {\n // JPEG 2000 Lossy\n return addDecodeTask(imageFrame, transferSyntax, pixelData, options);\n }\n\n /* Don't know if these work...\n // JPEG 2000 Part 2 Multicomponent Image Compression (Lossless Only)\n else if(transferSyntax === \"1.2.840.10008.1.2.4.92\")\n {\n return cornerstoneWADOImageLoader.decodeJPEG2000(dataSet, frame);\n }\n // JPEG 2000 Part 2 Multicomponent Image Compression\n else if(transferSyntax === \"1.2.840.10008.1.2.4.93\")\n {\n return cornerstoneWADOImageLoader.decodeJPEG2000(dataSet, frame);\n }\n */\n\n return new Promise((resolve, reject) => {\n reject(new Error(`No decoder for transfer syntax ${transferSyntax}`));\n });\n}\n\nexport default decodeImageFrame;\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/decodeImageFrame.js","import { getOptions } from './internal/options.js';\n\n// the taskId to assign to the next task added via addTask()\nlet nextTaskId = 0;\n\n// array of queued tasks sorted with highest priority task first\nconst tasks = [];\n\n// array of web workers to dispatch decode tasks to\nconst webWorkers = [];\n\n// The options for CornerstoneWADOImageLoader\nconst options = getOptions();\n\nconst defaultConfig = {\n maxWebWorkers: navigator.hardwareConcurrency || 1,\n startWebWorkersOnDemand: true,\n webWorkerPath: '../../dist/cornerstoneWADOImageLoaderWebWorker.js',\n webWorkerTaskPaths: [],\n taskConfiguration: {\n decodeTask: {\n loadCodecsOnStartup: true,\n initializeCodecsOnStartup: false,\n codecsPath: '../dist/cornerstoneWADOImageLoaderCodecs.js',\n usePDFJS: false,\n strict: options.strict\n }\n }\n};\n\nlet config;\n\nconst statistics = {\n maxWebWorkers: 0,\n numWebWorkers: 0,\n numTasksQueued: 0,\n numTasksExecuting: 0,\n numTasksCompleted: 0,\n totalTaskTimeInMS: 0,\n totalTimeDelayedInMS: 0\n};\n\n/**\n * Function to start a task on a web worker\n */\nfunction startTaskOnWebWorker() {\n // return immediately if no decode tasks to do\n if (!tasks.length) {\n return;\n }\n\n // look for a web worker that is ready\n for (let i = 0; i < webWorkers.length; i++) {\n if (webWorkers[i].status === 'ready') {\n // mark it as busy so tasks are not assigned to it\n webWorkers[i].status = 'busy';\n\n // get the highest priority task\n const task = tasks.shift();\n\n task.start = new Date().getTime();\n\n // update stats with how long this task was delayed (waiting in queue)\n const end = new Date().getTime();\n\n statistics.totalTimeDelayedInMS += end - task.added;\n\n // assign this task to this web worker and send the web worker\n // a message to execute it\n webWorkers[i].task = task;\n webWorkers[i].worker.postMessage(\n {\n taskType: task.taskType,\n workerIndex: i,\n data: task.data\n },\n task.transferList\n );\n statistics.numTasksExecuting++;\n\n return;\n }\n }\n\n // if no available web workers and we haven't started max web workers, start a new one\n if (webWorkers.length < config.maxWebWorkers) {\n spawnWebWorker();\n }\n}\n\n/**\n * Function to handle a message from a web worker\n * @param msg\n */\nfunction handleMessageFromWorker(msg) {\n const worker = webWorkers[msg.data.workerIndex];\n\n // console.log('handleMessageFromWorker', msg.data);\n if (msg.data.taskType === 'initialize') {\n worker.status = 'ready';\n startTaskOnWebWorker();\n } else {\n const start = worker.task.start;\n\n worker.task.deferred.resolve(msg.data.result);\n worker.task = undefined;\n\n statistics.numTasksExecuting--;\n worker.status = 'ready';\n statistics.numTasksCompleted++;\n\n const end = new Date().getTime();\n\n statistics.totalTaskTimeInMS += end - start;\n\n startTaskOnWebWorker();\n }\n}\n\n/**\n * Spawns a new web worker\n */\nfunction spawnWebWorker() {\n // prevent exceeding maxWebWorkers\n if (webWorkers.length >= config.maxWebWorkers) {\n return;\n }\n\n // spawn the webworker\n const worker = new Worker(config.webWorkerPath);\n\n webWorkers.push({\n worker,\n status: 'initializing'\n });\n worker.addEventListener('message', handleMessageFromWorker);\n worker.postMessage({\n taskType: 'initialize',\n workerIndex: webWorkers.length - 1,\n config\n });\n}\n\n/**\n * Initialization function for the web worker manager - spawns web workers\n * @param configObject\n */\nfunction initialize(configObject) {\n configObject = configObject || defaultConfig;\n\n // prevent being initialized more than once\n if (config) {\n throw new Error('WebWorkerManager already initialized');\n }\n\n config = configObject;\n\n config.maxWebWorkers =\n config.maxWebWorkers || (navigator.hardwareConcurrency || 1);\n\n // Spawn new web workers\n if (!config.startWebWorkersOnDemand) {\n for (let i = 0; i < config.maxWebWorkers; i++) {\n spawnWebWorker();\n }\n }\n}\n\n/**\n * dynamically loads a web worker task\n * @param sourcePath\n * @param taskConfig\n */\nfunction loadWebWorkerTask(sourcePath, taskConfig) {\n // add it to the list of web worker tasks paths so on demand web workers\n // load this properly\n config.webWorkerTaskPaths.push(sourcePath);\n\n // if a task specific configuration is provided, merge it into the config\n if (taskConfig) {\n config.taskConfiguration = Object.assign(\n config.taskConfiguration,\n taskConfig\n );\n }\n\n // tell each spawned web worker to load this task\n for (let i = 0; i < webWorkers.length; i++) {\n webWorkers[i].worker.postMessage({\n taskType: 'loadWebWorkerTask',\n workerIndex: webWorkers.length - 1,\n sourcePath,\n config\n });\n }\n}\n\n/**\n * Function to add a decode task to be performed\n *\n * @param taskType - the taskType for this task\n * @param data - data specific to the task\n * @param priority - optional priority of the task (defaults to 0), > 0 is higher, < 0 is lower\n * @param transferList - optional array of data to transfer to web worker\n * @returns {*}\n */\nfunction addTask(taskType, data, priority = 0, transferList) {\n if (!config) {\n initialize();\n }\n\n let deferred = {};\n const promise = new Promise((resolve, reject) => {\n deferred = {\n resolve,\n reject\n };\n });\n\n // find the right spot to insert this decode task (based on priority)\n let i;\n\n for (i = 0; i < tasks.length; i++) {\n if (tasks[i].priority < priority) {\n break;\n }\n }\n\n const taskId = nextTaskId++;\n\n // insert the decode task at position i\n tasks.splice(i, 0, {\n taskId,\n taskType,\n status: 'ready',\n added: new Date().getTime(),\n data,\n deferred,\n priority,\n transferList\n });\n\n // try to start a task on the web worker since we just added a new task and a web worker may be available\n startTaskOnWebWorker();\n\n return {\n taskId,\n promise\n };\n}\n\n/**\n * Changes the priority of a queued task\n * @param taskId - the taskId to change the priority of\n * @param priority - priority of the task (defaults to 0), > 0 is higher, < 0 is lower\n * @returns boolean - true on success, false if taskId not found\n */\nfunction setTaskPriority(taskId, priority = 0) {\n // search for this taskId\n for (let i = 0; i < tasks.length; i++) {\n if (tasks[i].taskId === taskId) {\n // taskId found, remove it\n const task = tasks.splice(i, 1)[0];\n\n // set its priority\n task.priority = priority;\n\n // find the right spot to insert this decode task (based on priority)\n for (i = 0; i < tasks.length; i++) {\n if (tasks[i].priority < priority) {\n break;\n }\n }\n\n // insert the decode task at position i\n tasks.splice(i, 0, task);\n\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * Cancels a queued task and rejects\n * @param taskId - the taskId to cancel\n * @param reason - optional reason the task was rejected\n * @returns boolean - true on success, false if taskId not found\n */\nfunction cancelTask(taskId, reason) {\n // search for this taskId\n for (let i = 0; i < tasks.length; i++) {\n if (tasks[i].taskId === taskId) {\n // taskId found, remove it\n const task = tasks.splice(i, 1);\n\n task.deferred.reject(reason);\n\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * Function to return the statistics on running web workers\n * @returns object containing statistics\n */\nfunction getStatistics() {\n statistics.maxWebWorkers = config.maxWebWorkers;\n statistics.numWebWorkers = webWorkers.length;\n statistics.numTasksQueued = tasks.length;\n\n return statistics;\n}\n\nexport default {\n initialize,\n loadWebWorkerTask,\n addTask,\n getStatistics,\n setTaskPriority,\n cancelTask\n};\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/webWorkerManager.js","import getMinMax from '../shared/getMinMax.js';\n\n/**\n * Special decoder for 8 bit jpeg that leverages the browser's built in JPEG decoder for increased performance\n */\n\nfunction arrayBufferToString (buffer) {\n return binaryToString(String.fromCharCode.apply(null, Array.prototype.slice.apply(new Uint8Array(buffer))));\n}\n\nfunction binaryToString (binary) {\n let error;\n\n try {\n return decodeURIComponent(escape(binary));\n } catch (_error) {\n error = _error;\n if (error instanceof URIError) {\n return binary;\n }\n throw error;\n\n }\n}\n\nfunction decodeJPEGBaseline8BitColor (imageFrame, pixelData, canvas) {\n const start = new Date().getTime();\n const imgBlob = new Blob([pixelData], { type: 'image/jpeg' });\n\n return new Promise((resolve, reject) => {\n const fileReader = new FileReader();\n\n if (fileReader.readAsBinaryString === undefined) {\n fileReader.readAsArrayBuffer(imgBlob);\n } else {\n fileReader.readAsBinaryString(imgBlob); // doesn't work on IE11\n }\n\n fileReader.onload = function () {\n const img = new Image();\n\n img.onload = function () {\n canvas.height = img.height;\n canvas.width = img.width;\n imageFrame.rows = img.height;\n imageFrame.columns = img.width;\n const context = canvas.getContext('2d');\n\n context.drawImage(this, 0, 0);\n const imageData = context.getImageData(0, 0, img.width, img.height);\n const end = new Date().getTime();\n\n imageFrame.pixelData = imageData.data;\n imageFrame.imageData = imageData;\n imageFrame.decodeTimeInMS = end - start;\n\n // calculate smallest and largest PixelValue\n const minMax = getMinMax(imageFrame.pixelData);\n\n imageFrame.smallestPixelValue = minMax.min;\n imageFrame.largestPixelValue = minMax.max;\n\n resolve(imageFrame);\n };\n\n img.onerror = function (error) {\n reject(error);\n };\n\n if (fileReader.readAsBinaryString === undefined) {\n img.src = `data:image/jpeg;base64,${window.btoa(arrayBufferToString(fileReader.result))}`;\n } else {\n img.src = `data:image/jpeg;base64,${window.btoa(fileReader.result)}`; // doesn't work on IE11\n }\n };\n\n fileReader.onerror = (e) => {\n reject(e);\n };\n });\n}\n\nexport default decodeJPEGBaseline8BitColor;\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/decodeJPEGBaseline8BitColor.js","export default function (photoMetricInterpretation) {\n return (photoMetricInterpretation === 'RGB' ||\n photoMetricInterpretation === 'PALETTE COLOR' ||\n photoMetricInterpretation === 'YBR_FULL' ||\n photoMetricInterpretation === 'YBR_FULL_422' ||\n photoMetricInterpretation === 'YBR_PARTIAL_422' ||\n photoMetricInterpretation === 'YBR_PARTIAL_420' ||\n photoMetricInterpretation === 'YBR_RCT' ||\n photoMetricInterpretation === 'YBR_ICT');\n}\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/isColorImage.js","import { convertRGBColorByPixel, convertRGBColorByPlane,\n convertYBRFullByPixel, convertYBRFullByPlane,\n convertPALETTECOLOR } from './colorSpaceConverters/index.js';\n\nfunction convertRGB (imageFrame, rgbaBuffer) {\n if (imageFrame.planarConfiguration === 0) {\n convertRGBColorByPixel(imageFrame.pixelData, rgbaBuffer);\n } else {\n convertRGBColorByPlane(imageFrame.pixelData, rgbaBuffer);\n }\n}\n\nfunction convertYBRFull (imageFrame, rgbaBuffer) {\n if (imageFrame.planarConfiguration === 0) {\n convertYBRFullByPixel(imageFrame.pixelData, rgbaBuffer);\n } else {\n convertYBRFullByPlane(imageFrame.pixelData, rgbaBuffer);\n }\n}\n\nexport default function convertColorSpace (imageFrame, imageData) {\n const rgbaBuffer = imageData.data;\n // convert based on the photometric interpretation\n\n if (imageFrame.photometricInterpretation === 'RGB') {\n convertRGB(imageFrame, rgbaBuffer);\n } else if (imageFrame.photometricInterpretation === 'YBR_RCT') {\n convertRGB(imageFrame, rgbaBuffer);\n } else if (imageFrame.photometricInterpretation === 'YBR_ICT') {\n convertRGB(imageFrame, rgbaBuffer);\n } else if (imageFrame.photometricInterpretation === 'PALETTE COLOR') {\n convertPALETTECOLOR(imageFrame, rgbaBuffer);\n } else if (imageFrame.photometricInterpretation === 'YBR_FULL_422') {\n convertRGB(imageFrame, rgbaBuffer);\n } else if (imageFrame.photometricInterpretation === 'YBR_FULL') {\n convertYBRFull(imageFrame, rgbaBuffer);\n } else {\n throw new Error(`No color space conversion for photometric interpretation ${imageFrame.photometricInterpretation}`);\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/convertColorSpace.js","function isJPEGBaseline8BitColor (imageFrame, transferSyntax) {\n transferSyntax = transferSyntax || imageFrame.transferSyntax;\n\n if (imageFrame.bitsAllocated === 8 &&\n transferSyntax === '1.2.840.10008.1.2.4.50' &&\n (imageFrame.samplesPerPixel === 3 || imageFrame.samplesPerPixel === 4)) {\n return true;\n }\n}\n\nexport default isJPEGBaseline8BitColor;\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/isJPEGBaseline8BitColor.js","let files = [];\n\nfunction add (file) {\n const fileIndex = files.push(file);\n\n return `dicomfile:${fileIndex - 1}`;\n}\n\nfunction get (index) {\n return files[index];\n}\n\nfunction remove (index) {\n files[index] = undefined;\n}\n\nfunction purge () {\n files = [];\n}\n\nexport default {\n add,\n get,\n remove,\n purge\n};\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadouri/fileManager.js","import { dicomParser } from '../../externalModules.js';\n\n/**\n * Function to deal with extracting an image frame from an encapsulated data set.\n */\n\n\nfunction framesAreFragmented (dataSet) {\n const numberOfFrames = dataSet.intString('x00280008');\n const pixelDataElement = dataSet.elements.x7fe00010;\n\n return (numberOfFrames !== pixelDataElement.fragments.length);\n}\n\nexport default function getEncapsulatedImageFrame (dataSet, frameIndex) {\n if (dataSet.elements.x7fe00010 && dataSet.elements.x7fe00010.basicOffsetTable.length) {\n // Basic Offset Table is not empty\n return dicomParser.readEncapsulatedImageFrame(dataSet, dataSet.elements.x7fe00010, frameIndex);\n }\n\n // Empty basic offset table\n\n if (framesAreFragmented(dataSet)) {\n const basicOffsetTable = dicomParser.createJPEGBasicOffsetTable(dataSet, dataSet.elements.x7fe00010);\n\n return dicomParser.readEncapsulatedImageFrame(dataSet, dataSet.elements.x7fe00010, frameIndex, basicOffsetTable);\n }\n\n return dicomParser.readEncapsulatedPixelDataFromFragments(dataSet, dataSet.elements.x7fe00010, frameIndex);\n}\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadouri/getEncapsulatedImageFrame.js","import unpackBinaryFrame from './unpackBinaryFrame.js';\n\n/**\n * Function to deal with extracting an image frame from an encapsulated data set.\n */\n\nfunction getUncompressedImageFrame (dataSet, frameIndex) {\n const pixelDataElement = dataSet.elements.x7fe00010 || dataSet.elements.x7fe00008;\n const bitsAllocated = dataSet.uint16('x00280100');\n const rows = dataSet.uint16('x00280010');\n const columns = dataSet.uint16('x00280011');\n const samplesPerPixel = dataSet.uint16('x00280002');\n\n const pixelDataOffset = pixelDataElement.dataOffset;\n const pixelsPerFrame = rows * columns * samplesPerPixel;\n\n let frameOffset;\n\n if (bitsAllocated === 8) {\n frameOffset = pixelDataOffset + frameIndex * pixelsPerFrame;\n if (frameOffset >= dataSet.byteArray.length) {\n throw new Error('frame exceeds size of pixelData');\n }\n\n return new Uint8Array(dataSet.byteArray.buffer, frameOffset, pixelsPerFrame);\n } else if (bitsAllocated === 16) {\n frameOffset = pixelDataOffset + frameIndex * pixelsPerFrame * 2;\n if (frameOffset >= dataSet.byteArray.length) {\n throw new Error('frame exceeds size of pixelData');\n }\n\n return new Uint8Array(dataSet.byteArray.buffer, frameOffset, pixelsPerFrame * 2);\n } else if (bitsAllocated === 1) {\n frameOffset = pixelDataOffset + frameIndex * pixelsPerFrame * 0.125;\n if (frameOffset >= dataSet.byteArray.length) {\n throw new Error('frame exceeds size of pixelData');\n }\n\n return unpackBinaryFrame(dataSet.byteArray, frameOffset, pixelsPerFrame);\n } else if (bitsAllocated === 32) {\n frameOffset = pixelDataOffset + frameIndex * pixelsPerFrame * 4;\n if (frameOffset >= dataSet.byteArray.length) {\n throw new Error('frame exceeds size of pixelData');\n }\n\n return new Uint8Array(dataSet.byteArray.buffer, frameOffset, pixelsPerFrame * 4);\n }\n\n throw new Error('unsupported pixel format');\n}\n\nexport default getUncompressedImageFrame;\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadouri/getUncompressedImageFrame.js","/* eslint no-bitwise: 0 */\n\nfunction isBitSet (byte, bitPos) {\n return byte & (1 << bitPos);\n}\n\n/**\n * Function to deal with unpacking a binary frame\n */\nfunction unpackBinaryFrame (byteArray, frameOffset, pixelsPerFrame) {\n // Create a new pixel array given the image size\n const pixelData = new Uint8Array(pixelsPerFrame);\n\n for (let i = 0; i < pixelsPerFrame; i++) {\n // Compute byte position\n const bytePos = Math.floor(i / 8);\n\n // Get the current byte\n const byte = byteArray[bytePos + frameOffset];\n\n // Bit position (0-7) within byte\n const bitPos = (i % 8);\n\n // Check whether bit at bitpos is set\n pixelData[i] = isBitSet(byte, bitPos) ? 1 : 0;\n }\n\n return pixelData;\n}\n\nexport default unpackBinaryFrame;\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadouri/unpackBinaryFrame.js","import parseImageId from './parseImageId.js';\nimport fileManager from './fileManager.js';\n\nfunction loadFileRequest (uri) {\n const parsedImageId = parseImageId(uri);\n const fileIndex = parseInt(parsedImageId.url, 10);\n const file = fileManager.get(fileIndex);\n\n return new Promise((resolve, reject) => {\n const fileReader = new FileReader();\n\n fileReader.onload = (e) => {\n const dicomPart10AsArrayBuffer = e.target.result;\n\n resolve(dicomPart10AsArrayBuffer);\n };\n\n fileReader.onerror = reject;\n\n fileReader.readAsArrayBuffer(file);\n });\n}\n\nexport default loadFileRequest;\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadouri/loadFileRequest.js","import createImage from '../createImage.js';\nimport parseImageId from './parseImageId.js';\nimport dataSetCacheManager from './dataSetCacheManager.js';\nimport loadFileRequest from './loadFileRequest.js';\nimport getPixelData from './getPixelData.js';\nimport { xhrRequest } from '../internal/index.js';\n\n// add a decache callback function to clear out our dataSetCacheManager\nfunction addDecache (imageLoadObject, imageId) {\n imageLoadObject.decache = function () {\n // console.log('decache');\n const parsedImageId = parseImageId(imageId);\n\n dataSetCacheManager.unload(parsedImageId.url);\n };\n}\n\nfunction loadImageFromPromise (dataSetPromise, imageId, frame = 0, sharedCacheKey, options, callbacks) {\n const start = new Date().getTime();\n const imageLoadObject = {\n cancelFn: undefined\n };\n\n imageLoadObject.promise = new Promise((resolve, reject) => {\n dataSetPromise.then((dataSet/* , xhr*/) => {\n const pixelData = getPixelData(dataSet, frame);\n const transferSyntax = dataSet.string('x00020010');\n const loadEnd = new Date().getTime();\n const imagePromise = createImage(imageId, pixelData, transferSyntax, options);\n\n addDecache(imageLoadObject, imageId);\n\n imagePromise.then((image) => {\n image.data = dataSet;\n image.sharedCacheKey = sharedCacheKey;\n const end = new Date().getTime();\n\n image.loadTimeInMS = loadEnd - start;\n image.totalTimeInMS = end - start;\n if (callbacks !== undefined && callbacks.imageDoneCallback !== undefined) {\n callbacks.imageDoneCallback(image);\n }\n resolve(image);\n }, function (error) {\n // Reject the error, and the dataSet\n reject({\n error,\n dataSet\n });\n });\n }, function (error) {\n // Reject the error\n reject({\n error\n });\n });\n });\n\n return imageLoadObject;\n}\n\nfunction loadImageFromDataSet (dataSet, imageId, frame = 0, sharedCacheKey, options) {\n const start = new Date().getTime();\n\n const promise = new Promise((resolve, reject) => {\n const loadEnd = new Date().getTime();\n let imagePromise;\n\n try {\n const pixelData = getPixelData(dataSet, frame);\n const transferSyntax = dataSet.string('x00020010');\n\n imagePromise = createImage(imageId, pixelData, transferSyntax, options);\n } catch (error) {\n // Reject the error, and the dataSet\n reject({\n error,\n dataSet\n });\n\n return;\n }\n\n imagePromise.then((image) => {\n image.data = dataSet;\n image.sharedCacheKey = sharedCacheKey;\n const end = new Date().getTime();\n\n image.loadTimeInMS = loadEnd - start;\n image.totalTimeInMS = end - start;\n resolve(image);\n }, reject);\n });\n\n return {\n promise,\n cancelFn: undefined\n };\n}\n\nfunction getLoaderForScheme (scheme) {\n if (scheme === 'dicomweb' || scheme === 'wadouri') {\n return xhrRequest;\n } else if (scheme === 'dicomfile') {\n return loadFileRequest;\n }\n}\n\nfunction loadImage (imageId, options) {\n const parsedImageId = parseImageId(imageId);\n const loader = getLoaderForScheme(parsedImageId.scheme);\n\n // if the dataset for this url is already loaded, use it\n if (dataSetCacheManager.isLoaded(parsedImageId.url)) {\n const dataSet = dataSetCacheManager.get(parsedImageId.url, loader, imageId);\n\n return loadImageFromDataSet(dataSet, imageId, parsedImageId.frame, parsedImageId.url, options);\n }\n\n // load the dataSet via the dataSetCacheManager\n const dataSetPromise = dataSetCacheManager.load(parsedImageId.url, loader, imageId);\n\n return loadImageFromPromise(dataSetPromise, imageId, parsedImageId.frame, parsedImageId.url, options);\n}\n\nexport { loadImageFromPromise, getLoaderForScheme, loadImage };\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadouri/loadImage.js","export * from './colorSpaceConverters/index.js';\n\nexport { default as wadouri } from './wadouri/index.js';\nexport { default as wadors } from './wadors/index.js';\nexport { default as configure } from './configure.js';\nexport { default as convertColorSpace } from './convertColorSpace.js';\nexport { default as createImage } from './createImage.js';\nexport { default as decodeImageFrame } from './decodeImageFrame.js';\nexport { default as decodeJPEGBaseline8BitColor } from './decodeJPEGBaseline8BitColor.js';\nexport { default as getImageFrame } from './getImageFrame.js';\nexport { default as getMinMax } from '../shared/getMinMax.js';\nexport { default as isColorImage } from './isColorImage.js';\nexport { default as isJPEGBaseline8BitColor } from './isJPEGBaseline8BitColor.js';\nexport { default as webWorkerManager } from './webWorkerManager.js';\nexport { default as version } from '../version.js';\nexport { internal } from './internal/index.js';\nexport { external } from '../externalModules.js';\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/index.js","export default function (imageFrame, rgbaBuffer) {\n if (imageFrame === undefined) {\n throw new Error('decodeRGB: rgbBuffer must not be undefined');\n }\n if (imageFrame.length % 3 !== 0) {\n throw new Error('decodeRGB: rgbBuffer length must be divisible by 3');\n }\n\n const numPixels = imageFrame.length / 3;\n let rgbIndex = 0;\n let rgbaIndex = 0;\n\n for (let i = 0; i < numPixels; i++) {\n rgbaBuffer[rgbaIndex++] = imageFrame[rgbIndex++]; // red\n rgbaBuffer[rgbaIndex++] = imageFrame[rgbIndex++]; // green\n rgbaBuffer[rgbaIndex++] = imageFrame[rgbIndex++]; // blue\n rgbaBuffer[rgbaIndex++] = 255; // alpha\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/colorSpaceConverters/convertRGBColorByPixel.js","export default function (imageFrame, rgbaBuffer) {\n if (imageFrame === undefined) {\n throw new Error('decodeRGB: rgbBuffer must not be undefined');\n }\n if (imageFrame.length % 3 !== 0) {\n throw new Error('decodeRGB: rgbBuffer length must be divisible by 3');\n }\n\n const numPixels = imageFrame.length / 3;\n let rgbaIndex = 0;\n let rIndex = 0;\n let gIndex = numPixels;\n let bIndex = numPixels * 2;\n\n for (let i = 0; i < numPixels; i++) {\n rgbaBuffer[rgbaIndex++] = imageFrame[rIndex++]; // red\n rgbaBuffer[rgbaIndex++] = imageFrame[gIndex++]; // green\n rgbaBuffer[rgbaIndex++] = imageFrame[bIndex++]; // blue\n rgbaBuffer[rgbaIndex++] = 255; // alpha\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/colorSpaceConverters/convertRGBColorByPlane.js","export default function (imageFrame, rgbaBuffer) {\n if (imageFrame === undefined) {\n throw new Error('decodeRGB: ybrBuffer must not be undefined');\n }\n if (imageFrame.length % 3 !== 0) {\n throw new Error('decodeRGB: ybrBuffer length must be divisble by 3');\n }\n\n const numPixels = imageFrame.length / 3;\n let ybrIndex = 0;\n let rgbaIndex = 0;\n\n for (let i = 0; i < numPixels; i++) {\n const y = imageFrame[ybrIndex++];\n const cb = imageFrame[ybrIndex++];\n const cr = imageFrame[ybrIndex++];\n\n rgbaBuffer[rgbaIndex++] = y + 1.40200 * (cr - 128);// red\n rgbaBuffer[rgbaIndex++] = y - 0.34414 * (cb - 128) - 0.71414 * (cr - 128); // green\n rgbaBuffer[rgbaIndex++] = y + 1.77200 * (cb - 128); // blue\n rgbaBuffer[rgbaIndex++] = 255; // alpha\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/colorSpaceConverters/convertYBRFullByPixel.js","export default function (imageFrame, rgbaBuffer) {\n if (imageFrame === undefined) {\n throw new Error('decodeRGB: ybrBuffer must not be undefined');\n }\n if (imageFrame.length % 3 !== 0) {\n throw new Error('decodeRGB: ybrBuffer length must be divisble by 3');\n }\n\n const numPixels = imageFrame.length / 3;\n let rgbaIndex = 0;\n let yIndex = 0;\n let cbIndex = numPixels;\n let crIndex = numPixels * 2;\n\n for (let i = 0; i < numPixels; i++) {\n const y = imageFrame[yIndex++];\n const cb = imageFrame[cbIndex++];\n const cr = imageFrame[crIndex++];\n\n rgbaBuffer[rgbaIndex++] = y + 1.40200 * (cr - 128);// red\n rgbaBuffer[rgbaIndex++] = y - 0.34414 * (cb - 128) - 0.71414 * (cr - 128); // green\n rgbaBuffer[rgbaIndex++] = y + 1.77200 * (cb - 128); // blue\n rgbaBuffer[rgbaIndex++] = 255; // alpha\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/colorSpaceConverters/convertYBRFullByPlane.js","/* eslint no-bitwise: 0 */\n\nfunction convertLUTto8Bit (lut, shift) {\n const numEntries = lut.length;\n const cleanedLUT = new Uint8ClampedArray(numEntries);\n\n for (let i = 0; i < numEntries; ++i) {\n cleanedLUT[i] = lut[i] >> shift;\n }\n\n return cleanedLUT;\n}\n\n/**\n * Convert pixel data with PALETTE COLOR Photometric Interpretation to RGBA\n *\n * @param {ImageFrame} imageFrame\n * @param {Uint8ClampedArray} rgbaBuffer\n * @returns {void}\n */\nexport default function (imageFrame, rgbaBuffer) {\n const numPixels = imageFrame.columns * imageFrame.rows;\n const pixelData = imageFrame.pixelData;\n const rData = imageFrame.redPaletteColorLookupTableData;\n const gData = imageFrame.greenPaletteColorLookupTableData;\n const bData = imageFrame.bluePaletteColorLookupTableData;\n const len = imageFrame.redPaletteColorLookupTableData.length;\n let palIndex = 0;\n let rgbaIndex = 0;\n\n const start = imageFrame.redPaletteColorLookupTableDescriptor[1];\n const shift = imageFrame.redPaletteColorLookupTableDescriptor[2] === 8 ? 0 : 8;\n\n const rDataCleaned = convertLUTto8Bit(rData, shift);\n const gDataCleaned = convertLUTto8Bit(gData, shift);\n const bDataCleaned = convertLUTto8Bit(bData, shift);\n\n for (let i = 0; i < numPixels; ++i) {\n let value = pixelData[palIndex++];\n\n if (value < start) {\n value = 0;\n } else if (value > start + len - 1) {\n value = len - 1;\n } else {\n value -= start;\n }\n\n rgbaBuffer[rgbaIndex++] = rDataCleaned[value];\n rgbaBuffer[rgbaIndex++] = gDataCleaned[value];\n rgbaBuffer[rgbaIndex++] = bDataCleaned[value];\n rgbaBuffer[rgbaIndex++] = 255;\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/colorSpaceConverters/convertPALETTECOLOR.js","import { dicomParser } from '../../../externalModules.js';\nimport getNumberValues from './getNumberValues.js';\nimport parseImageId from '../parseImageId.js';\nimport dataSetCacheManager from '../dataSetCacheManager.js';\nimport getImagePixelModule from './getImagePixelModule.js';\nimport getLUTs from './getLUTs.js';\nimport getModalityLUTOutputPixelRepresentation from './getModalityLUTOutputPixelRepresentation.js';\n\nfunction metaDataProvider (type, imageId) {\n const parsedImageId = parseImageId(imageId);\n\n const dataSet = dataSetCacheManager.get(parsedImageId.url);\n\n if (!dataSet) {\n return;\n }\n\n if (type === 'generalSeriesModule') {\n return {\n modality: dataSet.string('x00080060'),\n seriesInstanceUID: dataSet.string('x0020000e'),\n seriesNumber: dataSet.intString('x00200011'),\n studyInstanceUID: dataSet.string('x0020000d'),\n seriesDate: dicomParser.parseDA(dataSet.string('x00080021')),\n seriesTime: dicomParser.parseTM(dataSet.string('x00080031') || '')\n };\n }\n\n if (type === 'patientStudyModule') {\n return {\n patientAge: dataSet.intString('x00101010'),\n patientSize: dataSet.floatString('x00101020'),\n patientWeight: dataSet.floatString('x00101030')\n };\n }\n\n if (type === 'imagePlaneModule') {\n\n const imageOrientationPatient = getNumberValues(dataSet, 'x00200037', 6);\n const imagePositionPatient = getNumberValues(dataSet, 'x00200032', 3);\n const pixelSpacing = getNumberValues(dataSet, 'x00280030', 2);\n\n let columnPixelSpacing = 1.0;\n let rowPixelSpacing = 1.0;\n\n if (pixelSpacing) {\n rowPixelSpacing = pixelSpacing[0];\n columnPixelSpacing = pixelSpacing[1];\n }\n\n let rowCosines = null;\n let columnCosines = null;\n\n if (imageOrientationPatient) {\n rowCosines = [parseFloat(imageOrientationPatient[0]), parseFloat(imageOrientationPatient[1]), parseFloat(imageOrientationPatient[2])];\n columnCosines = [parseFloat(imageOrientationPatient[3]), parseFloat(imageOrientationPatient[4]), parseFloat(imageOrientationPatient[5])];\n }\n\n return {\n frameOfReferenceUID: dataSet.string('x00200052'),\n rows: dataSet.uint16('x00280010'),\n columns: dataSet.uint16('x00280011'),\n imageOrientationPatient,\n rowCosines,\n columnCosines,\n imagePositionPatient,\n sliceThickness: dataSet.floatString('x00180050'),\n sliceLocation: dataSet.floatString('x00201041'),\n pixelSpacing,\n rowPixelSpacing,\n columnPixelSpacing\n };\n }\n\n if (type === 'imagePixelModule') {\n return getImagePixelModule(dataSet);\n }\n\n if (type === 'modalityLutModule') {\n return {\n rescaleIntercept: dataSet.floatString('x00281052'),\n rescaleSlope: dataSet.floatString('x00281053'),\n rescaleType: dataSet.string('x00281054'),\n modalityLUTSequence: getLUTs(dataSet.uint16('x00280103'), dataSet.elements.x00283000)\n };\n }\n\n if (type === 'voiLutModule') {\n const modalityLUTOutputPixelRepresentation = getModalityLUTOutputPixelRepresentation(dataSet);\n\n\n return {\n windowCenter: getNumberValues(dataSet, 'x00281050', 1),\n windowWidth: getNumberValues(dataSet, 'x00281051', 1),\n voiLUTSequence: getLUTs(modalityLUTOutputPixelRepresentation, dataSet.elements.x00283010)\n };\n }\n\n if (type === 'sopCommonModule') {\n return {\n sopClassUID: dataSet.string('x00080016'),\n sopInstanceUID: dataSet.string('x00080018')\n };\n }\n\n if (type === 'petIsotopeModule') {\n const radiopharmaceuticalInfo = dataSet.elements.x00540016;\n\n if (radiopharmaceuticalInfo === undefined) {\n return;\n }\n\n const firstRadiopharmaceuticalInfoDataSet = radiopharmaceuticalInfo.items[0].dataSet;\n\n\n return {\n radiopharmaceuticalInfo: {\n radiopharmaceuticalStartTime: dicomParser.parseTM(firstRadiopharmaceuticalInfoDataSet.string('x00181072') || ''),\n radionuclideTotalDose: firstRadiopharmaceuticalInfoDataSet.floatString('x00181074'),\n radionuclideHalfLife: firstRadiopharmaceuticalInfoDataSet.floatString('x00181075')\n }\n };\n }\n}\n\nexport default metaDataProvider;\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadouri/metaData/metaDataProvider.js","module.exports = __WEBPACK_EXTERNAL_MODULE_46__;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external {\"commonjs\":\"dicom-parser\",\"commonjs2\":\"dicom-parser\",\"amd\":\"dicom-parser\",\"root\":\"dicomParser\"}\n// module id = 46\n// module chunks = 0","import wadors from './wadors/index.js';\nimport wadouri from './wadouri/index.js';\n\n/**\n * Register the WADO-URI and WADO-RS image loaders and metaData providers\n * with an instance of Cornerstone Core.\n *\n * @param cornerstone The Cornerstone Core library to register the image loaders with\n */\nfunction registerLoaders (cornerstone) {\n wadors.register(cornerstone);\n wadouri.register(cornerstone);\n}\n\nexport default registerLoaders;\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/registerLoaders.js","import getValue from './getValue.js';\n\n/**\n * Returns the first string value as a Javascript number\n *\n * @param element - The javascript object for the specified element in the metadata\n * @param [index] - the index of the value in a multi-valued element, default is 0\n * @param [defaultValue] - The default value to return if the element does not exist\n * @returns {*}\n */\nfunction getNumberString (element, index, defaultValue) {\n const value = getValue(element, index, defaultValue);\n\n if (value === undefined) {\n return;\n }\n\n return parseFloat(value);\n}\n\nexport default getNumberString;\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadors/metaData/getNumberString.js","import { dicomParser } from '../../../externalModules.js';\nimport getNumberValues from './getNumberValues.js';\nimport getValue from './getValue.js';\nimport getNumberValue from './getNumberValue.js';\nimport metaDataManager from '../metaDataManager.js';\n\nfunction metaDataProvider (type, imageId) {\n const metaData = metaDataManager.get(imageId);\n\n if (!metaData) {\n return;\n }\n\n if (type === 'generalSeriesModule') {\n return {\n modality: getValue(metaData['00080060']),\n seriesInstanceUID: getValue(metaData['0020000e']),\n seriesNumber: getNumberValue(metaData['00200011']),\n studyInstanceUID: getValue(metaData['0020000d']),\n seriesDate: dicomParser.parseDA(getValue(metaData['00080021'])),\n seriesTime: dicomParser.parseTM(getValue(metaData['00080031'], 0, ''))\n };\n }\n\n if (type === 'patientStudyModule') {\n return {\n patientAge: getNumberValue(metaData['00101010']),\n patientSize: getNumberValue(metaData['00101020']),\n patientWeight: getNumberValue(metaData['00101030'])\n };\n }\n\n if (type === 'imagePlaneModule') {\n const imageOrientationPatient = getNumberValues(metaData['00200037'], 6);\n const imagePositionPatient = getNumberValues(metaData['00200032'], 3);\n const pixelSpacing = getNumberValues(metaData['00280030'], 2);\n let columnPixelSpacing = 1.0;\n let rowPixelSpacing = 1.0;\n\n if (pixelSpacing) {\n rowPixelSpacing = pixelSpacing[0];\n columnPixelSpacing = pixelSpacing[1];\n }\n\n let rowCosines = null;\n let columnCosines = null;\n\n if (imageOrientationPatient) {\n rowCosines = [parseFloat(imageOrientationPatient[0]), parseFloat(imageOrientationPatient[1]), parseFloat(imageOrientationPatient[2])];\n columnCosines = [parseFloat(imageOrientationPatient[3]), parseFloat(imageOrientationPatient[4]), parseFloat(imageOrientationPatient[5])];\n }\n\n return {\n frameOfReferenceUID: getValue(metaData['00200052']),\n rows: getNumberValue(metaData['00280010']),\n columns: getNumberValue(metaData['00280011']),\n imageOrientationPatient,\n rowCosines,\n columnCosines,\n imagePositionPatient,\n sliceThickness: getNumberValue(metaData['00180050']),\n sliceLocation: getNumberValue(metaData['00201041']),\n pixelSpacing,\n rowPixelSpacing,\n columnPixelSpacing\n };\n }\n\n if (type === 'imagePixelModule') {\n return {\n samplesPerPixel: getNumberValue(metaData['00280002']),\n photometricInterpretation: getValue(metaData['00280004']),\n rows: getNumberValue(metaData['00280010']),\n columns: getNumberValue(metaData['00280011']),\n bitsAllocated: getNumberValue(metaData['00280100']),\n bitsStored: getNumberValue(metaData['00280101']),\n highBit: getValue(metaData['00280102']),\n pixelRepresentation: getNumberValue(metaData['00280103']),\n planarConfiguration: getNumberValue(metaData['00280006']),\n pixelAspectRatio: getValue(metaData['00280034']),\n smallestPixelValue: getNumberValue(metaData['00280106']),\n largestPixelValue: getNumberValue(metaData['00280107']),\n redPaletteColorLookupTableDescriptor: getNumberValues(metaData['00281101']),\n greenPaletteColorLookupTableDescriptor: getNumberValues(metaData['00281102']),\n bluePaletteColorLookupTableDescriptor: getNumberValues(metaData['00281103']),\n redPaletteColorLookupTableData: getNumberValues(metaData['00281201']),\n greenPaletteColorLookupTableData: getNumberValues(metaData['00281202']),\n bluePaletteColorLookupTableData: getNumberValues(metaData['00281203'])\n };\n }\n\n if (type === 'voiLutModule') {\n return {\n // TODO VOT LUT Sequence\n windowCenter: getNumberValues(metaData['00281050'], 1),\n windowWidth: getNumberValues(metaData['00281051'], 1)\n };\n }\n\n if (type === 'modalityLutModule') {\n return {\n // TODO VOT LUT Sequence\n rescaleIntercept: getNumberValue(metaData['00281052']),\n rescaleSlope: getNumberValue(metaData['00281053']),\n rescaleType: getValue(metaData['00281054'])\n };\n }\n\n if (type === 'sopCommonModule') {\n return {\n sopClassUID: getValue(metaData['00080016']),\n sopInstanceUID: getValue(metaData['00080018'])\n };\n }\n\n if (type === 'petIsotopeModule') {\n const radiopharmaceuticalInfo = getValue(metaData['00540016']);\n\n if (radiopharmaceuticalInfo === undefined) {\n return;\n }\n\n return {\n radiopharmaceuticalInfo: {\n radiopharmaceuticalStartTime: dicomParser.parseTM(getValue(radiopharmaceuticalInfo['00181072'], 0, '')),\n radionuclideTotalDose: getNumberValue(radiopharmaceuticalInfo['00181074']),\n radionuclideHalfLife: getNumberValue(radiopharmaceuticalInfo['00181075'])\n }\n };\n }\n\n}\n\nexport default metaDataProvider;\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadors/metaData/metaDataProvider.js","import { external } from '../../externalModules.js';\nimport { getOptions } from './options.js';\n\nfunction xhrRequest (url, imageId, headers = {}, params = {}) {\n const cornerstone = external.cornerstone;\n const options = getOptions();\n\n // Make the request for the DICOM P10 SOP Instance\n return new Promise((resolve, reject) => {\n const xhr = new XMLHttpRequest();\n\n xhr.open('get', url, true);\n xhr.responseType = 'arraybuffer';\n options.beforeSend(xhr, imageId);\n Object.keys(headers).forEach(function (key) {\n xhr.setRequestHeader(key, headers[key]);\n });\n\n params.deferred = {\n resolve,\n reject\n };\n params.url = url;\n params.imageId = imageId;\n\n // Event triggered when downloading an image starts\n xhr.onloadstart = function (event) {\n // Action\n if (options.onloadstart) {\n options.onloadstart(event, params);\n }\n\n // Event\n const eventData = {\n url,\n imageId\n };\n\n cornerstone.triggerEvent(cornerstone.events, 'cornerstoneimageloadstart', eventData);\n };\n\n // Event triggered when downloading an image ends\n xhr.onloadend = function (event) {\n // Action\n if (options.onloadend) {\n options.onloadend(event, params);\n }\n\n const eventData = {\n url,\n imageId\n };\n\n // Event\n cornerstone.triggerEvent(cornerstone.events, 'cornerstoneimageloadend', eventData);\n };\n\n // handle response data\n xhr.onreadystatechange = function (event) {\n // Action\n if (options.onreadystatechange) {\n options.onreadystatechange(event, params);\n\n return;\n }\n\n // Default action\n // TODO: consider sending out progress messages here as we receive the pixel data\n if (xhr.readyState === 4) {\n if (xhr.status === 200) {\n resolve(xhr.response, xhr);\n } else {\n // request failed, reject the Promise\n reject(xhr);\n }\n }\n };\n\n // Event triggered when downloading an image progresses\n xhr.onprogress = function (oProgress) {\n // console.log('progress:',oProgress)\n const loaded = oProgress.loaded; // evt.loaded the bytes browser receive\n let total;\n let percentComplete;\n\n if (oProgress.lengthComputable) {\n total = oProgress.total; // evt.total the total bytes seted by the header\n percentComplete = Math.round((loaded / total) * 100);\n }\n\n // Action\n if (options.onprogress) {\n options.onprogress(oProgress, params);\n }\n\n // Event\n const eventData = {\n url,\n imageId,\n loaded,\n total,\n percentComplete\n };\n\n cornerstone.triggerEvent(cornerstone.events, 'cornerstoneimageloadprogress', eventData);\n };\n\n xhr.send();\n });\n}\n\nexport default xhrRequest;\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/internal/xhrRequest.js","import loadImage from './loadImage.js';\nimport { metaDataProvider } from './metaData/index.js';\n\nexport default function (cornerstone) {\n // register wadors scheme and metadata provider\n cornerstone.registerImageLoader('wadors', loadImage);\n cornerstone.metaData.addProvider(metaDataProvider);\n}\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadors/register.js","import getEncapsulatedImageFrame from './getEncapsulatedImageFrame.js';\nimport getUncompressedImageFrame from './getUncompressedImageFrame.js';\n\nfunction getPixelData (dataSet, frameIndex = 0) {\n const pixelDataElement = dataSet.elements.x7fe00010 || dataSet.elements.x7fe00008;\n\n if (!pixelDataElement) {\n return null;\n }\n\n if (pixelDataElement.encapsulatedPixelData) {\n return getEncapsulatedImageFrame(dataSet, frameIndex);\n }\n\n return getUncompressedImageFrame(dataSet, frameIndex);\n}\n\nexport default getPixelData;\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadouri/getPixelData.js","import { loadImage } from './loadImage.js';\nimport { metaDataProvider } from './metaData/index.js';\n\nexport default function (cornerstone) {\n // register dicomweb and wadouri image loader prefixes\n cornerstone.registerImageLoader('dicomweb', loadImage);\n cornerstone.registerImageLoader('wadouri', loadImage);\n cornerstone.registerImageLoader('dicomfile', loadImage);\n\n // add wadouri metadata provider\n cornerstone.metaData.addProvider(metaDataProvider);\n}\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/wadouri/register.js","import { setOptions } from './internal/index.js';\n\nfunction configure (options) {\n setOptions(options);\n}\n\nexport default configure;\n\n\n\n// WEBPACK FOOTER //\n// ./imageLoader/configure.js"],"sourceRoot":""} |