dwv 0.31.0-beta.0 → 0.31.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dwv.js +799 -199
- package/dist/dwv.min.js +2 -2
- package/package.json +4 -4
- package/readme.md +9 -21
package/dist/dwv.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! dwv 0.31.0-beta.
|
|
1
|
+
/*! dwv 0.31.0-beta.3 2022-03-22 16:38:42 */
|
|
2
2
|
// Inspired from umdjs
|
|
3
3
|
// See https://github.com/umdjs/umd/blob/master/templates/returnExports.js
|
|
4
4
|
(function (root, factory) {
|
|
@@ -627,9 +627,9 @@ dwv.App = function () {
|
|
|
627
627
|
// initialise or add view
|
|
628
628
|
if (layerGroup.getViewLayersByDataIndex(dataIndex).length === 0) {
|
|
629
629
|
if (layerGroup.getNumberOfLayers() === 0) {
|
|
630
|
-
initialiseBaseLayers(dataIndex, config
|
|
630
|
+
initialiseBaseLayers(dataIndex, config);
|
|
631
631
|
} else {
|
|
632
|
-
addViewLayer(dataIndex, config
|
|
632
|
+
addViewLayer(dataIndex, config);
|
|
633
633
|
}
|
|
634
634
|
}
|
|
635
635
|
// draw
|
|
@@ -1210,25 +1210,12 @@ dwv.App = function () {
|
|
|
1210
1210
|
* To be called once the DICOM data has been loaded.
|
|
1211
1211
|
*
|
|
1212
1212
|
* @param {number} dataIndex The data index.
|
|
1213
|
-
* @param {
|
|
1213
|
+
* @param {object} dataViewConfig The data view config.
|
|
1214
1214
|
* @private
|
|
1215
1215
|
*/
|
|
1216
|
-
function initialiseBaseLayers(dataIndex,
|
|
1217
|
-
var data = dataController.get(dataIndex);
|
|
1218
|
-
if (!data) {
|
|
1219
|
-
throw new Error('Cannot initialise layers with data id: ' + dataIndex);
|
|
1220
|
-
}
|
|
1221
|
-
var layerGroup = stage.getLayerGroupWithElementId(layerGroupElementId);
|
|
1222
|
-
if (!layerGroup) {
|
|
1223
|
-
throw new Error('Cannot initialise layers with group id: ' +
|
|
1224
|
-
layerGroupElementId);
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1216
|
+
function initialiseBaseLayers(dataIndex, dataViewConfig) {
|
|
1227
1217
|
// add layers
|
|
1228
|
-
addViewLayer(dataIndex,
|
|
1229
|
-
|
|
1230
|
-
// update style
|
|
1231
|
-
//style.setBaseScale(layerGroup.getBaseScale());
|
|
1218
|
+
addViewLayer(dataIndex, dataViewConfig);
|
|
1232
1219
|
|
|
1233
1220
|
// initialise the toolbox
|
|
1234
1221
|
if (toolboxController) {
|
|
@@ -1239,18 +1226,19 @@ dwv.App = function () {
|
|
|
1239
1226
|
/**
|
|
1240
1227
|
* Get the data max size for a layer group.
|
|
1241
1228
|
*
|
|
1242
|
-
* @
|
|
1243
|
-
* @param {object} lg The layer group.
|
|
1229
|
+
* @param {object} layerGroup The layer group.
|
|
1244
1230
|
* @returns {object} The max size as {x,y}.
|
|
1245
1231
|
*/
|
|
1246
|
-
function getLayerGroupMaxSize(
|
|
1232
|
+
function getLayerGroupMaxSize(layerGroup) {
|
|
1247
1233
|
var maxSize = {x: 0, y: 0};
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1234
|
+
// loop through layer group data
|
|
1235
|
+
var indices = layerGroup.getViewDataIndices();
|
|
1236
|
+
for (var i = 0; i < indices.length; ++i) {
|
|
1237
|
+
var data = dataController.get(indices[i]);
|
|
1238
|
+
var geometry = data.image.getGeometry();
|
|
1251
1239
|
var viewOrient = dwv.gui.getViewOrientation(
|
|
1252
1240
|
geometry,
|
|
1253
|
-
|
|
1241
|
+
layerGroup.getTargetOrientation()
|
|
1254
1242
|
);
|
|
1255
1243
|
var size = geometry.getSize(viewOrient).get2D();
|
|
1256
1244
|
var spacing = geometry.getSpacing(viewOrient).get2D();
|
|
@@ -1270,17 +1258,17 @@ dwv.App = function () {
|
|
|
1270
1258
|
* Add a view layer.
|
|
1271
1259
|
*
|
|
1272
1260
|
* @param {number} dataIndex The data index.
|
|
1273
|
-
* @param {
|
|
1261
|
+
* @param {object} dataViewConfig The data view config.
|
|
1274
1262
|
*/
|
|
1275
|
-
function addViewLayer(dataIndex,
|
|
1263
|
+
function addViewLayer(dataIndex, dataViewConfig) {
|
|
1276
1264
|
var data = dataController.get(dataIndex);
|
|
1277
1265
|
if (!data) {
|
|
1278
|
-
throw new Error('Cannot initialise
|
|
1266
|
+
throw new Error('Cannot initialise layer with data id: ' + dataIndex);
|
|
1279
1267
|
}
|
|
1280
|
-
var layerGroup = stage.getLayerGroupWithElementId(
|
|
1268
|
+
var layerGroup = stage.getLayerGroupWithElementId(dataViewConfig.divId);
|
|
1281
1269
|
if (!layerGroup) {
|
|
1282
|
-
throw new Error('Cannot initialise
|
|
1283
|
-
|
|
1270
|
+
throw new Error('Cannot initialise layer with group id: ' +
|
|
1271
|
+
dataViewConfig.divId);
|
|
1284
1272
|
}
|
|
1285
1273
|
var imageGeometry = data.image.getGeometry();
|
|
1286
1274
|
|
|
@@ -1298,11 +1286,35 @@ dwv.App = function () {
|
|
|
1298
1286
|
);
|
|
1299
1287
|
view.setOrientation(viewOrientation);
|
|
1300
1288
|
|
|
1301
|
-
//
|
|
1289
|
+
// make pixel of value 0 transparent for segmentation
|
|
1290
|
+
// (assuming RGB data)
|
|
1291
|
+
if (data.image.getMeta().Modality === 'SEG') {
|
|
1292
|
+
view.setAlphaFunction(function (value) {
|
|
1293
|
+
if (value[0] === 0 &&
|
|
1294
|
+
value[1] === 0 &&
|
|
1295
|
+
value[2] === 0) {
|
|
1296
|
+
return 1;
|
|
1297
|
+
} else {
|
|
1298
|
+
return 0xff;
|
|
1299
|
+
}
|
|
1300
|
+
});
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
// colour map
|
|
1304
|
+
if (typeof dataViewConfig.colourMap !== 'undefined') {
|
|
1305
|
+
view.setColourMap(dataViewConfig.colourMap);
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
// opacity
|
|
1302
1309
|
var opacity = 1;
|
|
1303
|
-
|
|
1304
|
-
|
|
1310
|
+
// do we have more than one layer
|
|
1311
|
+
// (the layer has not been added to the layer group yet)
|
|
1312
|
+
if (layerGroup.getNumberOfLayers() !== 0) {
|
|
1305
1313
|
opacity = 0.5;
|
|
1314
|
+
// set color map if non was provided
|
|
1315
|
+
if (typeof dataViewConfig.colourMap === 'undefined') {
|
|
1316
|
+
view.setColourMap(dwv.image.lut.rainbow);
|
|
1317
|
+
}
|
|
1306
1318
|
}
|
|
1307
1319
|
|
|
1308
1320
|
// view layer
|
|
@@ -1315,12 +1327,16 @@ dwv.App = function () {
|
|
|
1315
1327
|
|
|
1316
1328
|
// compensate origin difference
|
|
1317
1329
|
var diff = null;
|
|
1318
|
-
if (
|
|
1319
|
-
var
|
|
1320
|
-
var
|
|
1321
|
-
|
|
1330
|
+
if (layerGroup.getNumberOfLayers() !== 1) {
|
|
1331
|
+
var firstDataIndex = layerGroup.getViewDataIndices()[0];
|
|
1332
|
+
var data0 = dataController.get(firstDataIndex);
|
|
1333
|
+
// offset from the top, use first origin
|
|
1334
|
+
var origin0 = data0.image.getGeometry().getOrigins()[0];
|
|
1335
|
+
var origin1 = imageGeometry.getOrigins()[0];
|
|
1322
1336
|
diff = origin0.minus(origin1);
|
|
1323
|
-
|
|
1337
|
+
// TODO: check why -z...
|
|
1338
|
+
viewLayer.setBaseOffset(new dwv.math.Vector3D(
|
|
1339
|
+
diff.getX(), diff.getY(), -1 * diff.getZ()));
|
|
1324
1340
|
}
|
|
1325
1341
|
|
|
1326
1342
|
// listen to image changes
|
|
@@ -1343,8 +1359,8 @@ dwv.App = function () {
|
|
|
1343
1359
|
];
|
|
1344
1360
|
layerGroup.updateLayersToPositionChange({value: value});
|
|
1345
1361
|
|
|
1346
|
-
// compensate origin difference
|
|
1347
|
-
if (
|
|
1362
|
+
// compensate origin difference if needed
|
|
1363
|
+
if (diff) {
|
|
1348
1364
|
dl.setBaseOffset(diff);
|
|
1349
1365
|
}
|
|
1350
1366
|
}
|
|
@@ -2744,9 +2760,11 @@ dwv.ctrl.ViewController = function (view) {
|
|
|
2744
2760
|
* Generate display image data to be given to a canvas.
|
|
2745
2761
|
*
|
|
2746
2762
|
* @param {Array} array The array to fill in.
|
|
2763
|
+
* @param {dwv.math.Point} position Optional position at which to generate,
|
|
2764
|
+
* otherwise generates at current position.
|
|
2747
2765
|
*/
|
|
2748
|
-
this.generateImageData = function (array) {
|
|
2749
|
-
view.generateImageData(array);
|
|
2766
|
+
this.generateImageData = function (array, position) {
|
|
2767
|
+
view.generateImageData(array, position);
|
|
2750
2768
|
};
|
|
2751
2769
|
|
|
2752
2770
|
/**
|
|
@@ -4353,6 +4371,26 @@ dwv.dicom.DicomElementsWrapper.prototype.getFromName = function (name) {
|
|
|
4353
4371
|
return value;
|
|
4354
4372
|
};
|
|
4355
4373
|
|
|
4374
|
+
/**
|
|
4375
|
+
* Extract a size from dicom elements.
|
|
4376
|
+
*
|
|
4377
|
+
* @returns {object} The size.
|
|
4378
|
+
*/
|
|
4379
|
+
dwv.dicom.DicomElementsWrapper.prototype.getImageSize = function () {
|
|
4380
|
+
// rows
|
|
4381
|
+
var rows = this.getFromKey('x00280010');
|
|
4382
|
+
if (!rows) {
|
|
4383
|
+
throw new Error('Missing or empty DICOM image number of rows');
|
|
4384
|
+
}
|
|
4385
|
+
// columns
|
|
4386
|
+
var columns = this.getFromKey('x00280011');
|
|
4387
|
+
if (!columns) {
|
|
4388
|
+
throw new Error('Missing or empty DICOM image number of columns');
|
|
4389
|
+
}
|
|
4390
|
+
return new dwv.image.Size([columns, rows, 1]);
|
|
4391
|
+
};
|
|
4392
|
+
|
|
4393
|
+
|
|
4356
4394
|
/**
|
|
4357
4395
|
* Get the pixel spacing from the different spacing tags.
|
|
4358
4396
|
*
|
|
@@ -4468,7 +4506,7 @@ dwv.dicom = dwv.dicom || {};
|
|
|
4468
4506
|
* @returns {string} The version of the library.
|
|
4469
4507
|
*/
|
|
4470
4508
|
dwv.getVersion = function () {
|
|
4471
|
-
return '0.31.0-beta.
|
|
4509
|
+
return '0.31.0-beta.3';
|
|
4472
4510
|
};
|
|
4473
4511
|
|
|
4474
4512
|
/**
|
|
@@ -5935,11 +5973,15 @@ dwv.dicom = dwv.dicom || {};
|
|
|
5935
5973
|
* @returns {string} The dwv UID prefix.
|
|
5936
5974
|
*/
|
|
5937
5975
|
dwv.dicom.getDwvUIDPrefix = function () {
|
|
5938
|
-
return '1.2.826.0.1.3680043.9.7278.1
|
|
5976
|
+
return '1.2.826.0.1.3680043.9.7278.1';
|
|
5939
5977
|
};
|
|
5940
5978
|
|
|
5979
|
+
// local generated uid counter
|
|
5980
|
+
var _uidCount = 0;
|
|
5981
|
+
|
|
5941
5982
|
/**
|
|
5942
5983
|
* Get a UID for a DICOM tag.
|
|
5984
|
+
* Note: Use https://github.com/uuidjs/uuid?
|
|
5943
5985
|
*
|
|
5944
5986
|
* @see http://dicom.nema.org/dicom/2013/output/chtml/part05/chapter_9.html
|
|
5945
5987
|
* @see http://dicomiseasy.blogspot.com/2011/12/chapter-4-dicom-objects-in-chapter-3.html
|
|
@@ -5948,17 +5990,34 @@ dwv.dicom.getDwvUIDPrefix = function () {
|
|
|
5948
5990
|
* @returns {string} The corresponding UID.
|
|
5949
5991
|
*/
|
|
5950
5992
|
dwv.dicom.getUID = function (tagName) {
|
|
5951
|
-
var
|
|
5993
|
+
var prefix = dwv.dicom.getDwvUIDPrefix() + '.';
|
|
5994
|
+
var uid = '';
|
|
5952
5995
|
if (tagName === 'ImplementationClassUID') {
|
|
5953
|
-
uid
|
|
5954
|
-
} else if (tagName === 'SOPInstanceUID') {
|
|
5955
|
-
for (var i = 0; i < tagName.length; ++i) {
|
|
5956
|
-
uid += tagName.charCodeAt(i);
|
|
5957
|
-
}
|
|
5958
|
-
// add date (only numbers)
|
|
5959
|
-
uid += '.' + (new Date()).toISOString().replace(/\D/g, '');
|
|
5996
|
+
uid = prefix + dwv.getVersion();
|
|
5960
5997
|
} else {
|
|
5961
|
-
|
|
5998
|
+
// date (only numbers), do not keep milliseconds
|
|
5999
|
+
var date = (new Date()).toISOString().replace(/\D/g, '');
|
|
6000
|
+
var datePart = '.' + date.substring(0, 14);
|
|
6001
|
+
// count
|
|
6002
|
+
_uidCount += 1;
|
|
6003
|
+
var countPart = '.' + _uidCount;
|
|
6004
|
+
|
|
6005
|
+
// uid = prefix . tag . date . count
|
|
6006
|
+
uid = prefix;
|
|
6007
|
+
|
|
6008
|
+
// limit tag part to not exceed 64 length
|
|
6009
|
+
var nonTagLength = prefix.length + countPart.length + datePart.length;
|
|
6010
|
+
var leni = Math.min(tagName.length, 64 - nonTagLength);
|
|
6011
|
+
if (leni > 1) {
|
|
6012
|
+
var tagNumber = '';
|
|
6013
|
+
for (var i = 0; i < leni; ++i) {
|
|
6014
|
+
tagNumber += tagName.charCodeAt(i);
|
|
6015
|
+
}
|
|
6016
|
+
uid += tagNumber.substring(0, leni);
|
|
6017
|
+
}
|
|
6018
|
+
|
|
6019
|
+
// finish
|
|
6020
|
+
uid += datePart + countPart;
|
|
5962
6021
|
}
|
|
5963
6022
|
return uid;
|
|
5964
6023
|
};
|
|
@@ -11997,6 +12056,21 @@ dwv.gui.LayerGroup = function (containerDiv, groupId) {
|
|
|
11997
12056
|
return res;
|
|
11998
12057
|
};
|
|
11999
12058
|
|
|
12059
|
+
/**
|
|
12060
|
+
* Get the view layers data indices.
|
|
12061
|
+
*
|
|
12062
|
+
* @returns {Array} The list of indices.
|
|
12063
|
+
*/
|
|
12064
|
+
this.getViewDataIndices = function () {
|
|
12065
|
+
var res = [];
|
|
12066
|
+
for (var i = 0; i < layers.length; ++i) {
|
|
12067
|
+
if (layers[i] instanceof dwv.gui.ViewLayer) {
|
|
12068
|
+
res.push(layers[i].getDataIndex());
|
|
12069
|
+
}
|
|
12070
|
+
}
|
|
12071
|
+
return res;
|
|
12072
|
+
};
|
|
12073
|
+
|
|
12000
12074
|
/**
|
|
12001
12075
|
* Get the active draw layer.
|
|
12002
12076
|
*
|
|
@@ -13050,6 +13124,14 @@ dwv.gui.ViewLayer = function (containerDiv) {
|
|
|
13050
13124
|
*/
|
|
13051
13125
|
var context = null;
|
|
13052
13126
|
|
|
13127
|
+
/**
|
|
13128
|
+
* Flag to know if the context has been cleared.
|
|
13129
|
+
*
|
|
13130
|
+
* @private
|
|
13131
|
+
* @type {boolean}
|
|
13132
|
+
*/
|
|
13133
|
+
var isContextClear = true;
|
|
13134
|
+
|
|
13053
13135
|
/**
|
|
13054
13136
|
* The image data array.
|
|
13055
13137
|
*
|
|
@@ -13398,14 +13480,8 @@ dwv.gui.ViewLayer = function (containerDiv) {
|
|
|
13398
13480
|
// context opacity
|
|
13399
13481
|
context.globalAlpha = opacity;
|
|
13400
13482
|
|
|
13401
|
-
// clear
|
|
13402
|
-
|
|
13403
|
-
context.save();
|
|
13404
|
-
// use the identity matrix while clearing the canvas
|
|
13405
|
-
context.setTransform(1, 0, 0, 1, 0, 0);
|
|
13406
|
-
context.clearRect(0, 0, canvas.width, canvas.height);
|
|
13407
|
-
// restore the transform
|
|
13408
|
-
context.restore();
|
|
13483
|
+
// clear context
|
|
13484
|
+
this.clear();
|
|
13409
13485
|
|
|
13410
13486
|
// draw the cached canvas on the context
|
|
13411
13487
|
// transform takes as input a, b, c, d, e, f to create
|
|
@@ -13427,6 +13503,9 @@ dwv.gui.ViewLayer = function (containerDiv) {
|
|
|
13427
13503
|
// draw image
|
|
13428
13504
|
context.drawImage(offscreenCanvas, 0, 0);
|
|
13429
13505
|
|
|
13506
|
+
// set clear flag
|
|
13507
|
+
isContextClear = false;
|
|
13508
|
+
|
|
13430
13509
|
/**
|
|
13431
13510
|
* Render end event.
|
|
13432
13511
|
*
|
|
@@ -13621,6 +13700,11 @@ dwv.gui.ViewLayer = function (containerDiv) {
|
|
|
13621
13700
|
function onPositionChange(event) {
|
|
13622
13701
|
if (typeof event.skipGenerate === 'undefined' ||
|
|
13623
13702
|
event.skipGenerate === false) {
|
|
13703
|
+
// clear for non valid events
|
|
13704
|
+
if (typeof event.valid !== 'undefined' && !event.valid) {
|
|
13705
|
+
self.clear();
|
|
13706
|
+
return;
|
|
13707
|
+
}
|
|
13624
13708
|
// 3D dimensions
|
|
13625
13709
|
var dims3D = [0, 1, 2];
|
|
13626
13710
|
// remove scroll index
|
|
@@ -13663,12 +13747,22 @@ dwv.gui.ViewLayer = function (containerDiv) {
|
|
|
13663
13747
|
};
|
|
13664
13748
|
|
|
13665
13749
|
/**
|
|
13666
|
-
* Clear the context
|
|
13750
|
+
* Clear the context.
|
|
13667
13751
|
*/
|
|
13668
13752
|
this.clear = function () {
|
|
13669
|
-
|
|
13670
|
-
|
|
13671
|
-
|
|
13753
|
+
if (!isContextClear) {
|
|
13754
|
+
// clear the context: reset the transform first
|
|
13755
|
+
// store the current transformation matrix
|
|
13756
|
+
context.save();
|
|
13757
|
+
// use the identity matrix while clearing the canvas
|
|
13758
|
+
context.setTransform(1, 0, 0, 1, 0, 0);
|
|
13759
|
+
context.clearRect(0, 0, canvas.width, canvas.height);
|
|
13760
|
+
// restore the transform
|
|
13761
|
+
context.restore();
|
|
13762
|
+
|
|
13763
|
+
// update clear flag
|
|
13764
|
+
isContextClear = true;
|
|
13765
|
+
}
|
|
13672
13766
|
};
|
|
13673
13767
|
|
|
13674
13768
|
/**
|
|
@@ -14130,11 +14224,20 @@ dwv.image.DicomBufferToView = function () {
|
|
|
14130
14224
|
* @param {string} origin The data origin.
|
|
14131
14225
|
*/
|
|
14132
14226
|
function generateImage(index, origin) {
|
|
14227
|
+
var dicomElements = dicomParserStore[index].getDicomElements();
|
|
14228
|
+
|
|
14229
|
+
var modality = dwv.dicom.cleanString(dicomElements.getFromKey('x00080060'));
|
|
14230
|
+
var factory;
|
|
14231
|
+
if (modality && modality === 'SEG') {
|
|
14232
|
+
factory = new dwv.image.MaskFactory();
|
|
14233
|
+
} else {
|
|
14234
|
+
factory = new dwv.image.ImageFactory();
|
|
14235
|
+
}
|
|
14236
|
+
|
|
14133
14237
|
// create the image
|
|
14134
14238
|
try {
|
|
14135
|
-
var
|
|
14136
|
-
|
|
14137
|
-
dicomParserStore[index].getDicomElements(),
|
|
14239
|
+
var image = factory.create(
|
|
14240
|
+
dicomElements,
|
|
14138
14241
|
finalBufferStore[index],
|
|
14139
14242
|
options.numberOfFiles);
|
|
14140
14243
|
// call onloaditem
|
|
@@ -15150,8 +15253,16 @@ dwv.image.Geometry.prototype.equals = function (rhs) {
|
|
|
15150
15253
|
* @returns {boolean} True if the given coordinates are within bounds.
|
|
15151
15254
|
*/
|
|
15152
15255
|
dwv.image.Geometry.prototype.isInBounds = function (point) {
|
|
15153
|
-
|
|
15154
|
-
|
|
15256
|
+
return this.isIndexInBounds(this.worldToIndex(point));
|
|
15257
|
+
};
|
|
15258
|
+
|
|
15259
|
+
/**
|
|
15260
|
+
* Check that a index is within bounds.
|
|
15261
|
+
*
|
|
15262
|
+
* @param {dwv.math.Index} index The index to check.
|
|
15263
|
+
* @returns {boolean} True if the given coordinates are within bounds.
|
|
15264
|
+
*/
|
|
15265
|
+
dwv.image.Geometry.prototype.isIndexInBounds = function (index) {
|
|
15155
15266
|
return this.getSize().isInBounds(index);
|
|
15156
15267
|
};
|
|
15157
15268
|
|
|
@@ -16858,10 +16969,10 @@ dwv.image.rangeRegions = function (
|
|
|
16858
16969
|
* @param {boolean} isPlanar A flag to know if the data is planar
|
|
16859
16970
|
* (RRRR...GGGG...BBBB...) or not (RGBRGBRGBRGB...), defaults to false.
|
|
16860
16971
|
* @returns {object} A 3 components iterator folowing the iterator and iterable
|
|
16861
|
-
* protocol,
|
|
16862
|
-
* third component.
|
|
16972
|
+
* protocol, the value is an array of size 3 with each component.
|
|
16863
16973
|
*/
|
|
16864
|
-
dwv.image.
|
|
16974
|
+
dwv.image.simpleRange3d = function (
|
|
16975
|
+
dataAccessor, start, end, increment, isPlanar) {
|
|
16865
16976
|
if (typeof increment === 'undefined') {
|
|
16866
16977
|
increment = 1;
|
|
16867
16978
|
}
|
|
@@ -16903,6 +17014,84 @@ dwv.image.range3d = function (dataAccessor, start, end, increment, isPlanar) {
|
|
|
16903
17014
|
};
|
|
16904
17015
|
};
|
|
16905
17016
|
|
|
17017
|
+
/**
|
|
17018
|
+
* Get an iterator for a given range for a 3 components data.
|
|
17019
|
+
*
|
|
17020
|
+
* Using 'maxIter' and not an 'end' index since it fails in some edge cases
|
|
17021
|
+
* (for ex coronal2, ie zxy)
|
|
17022
|
+
*
|
|
17023
|
+
* @param {Function} dataAccessor Function to access data.
|
|
17024
|
+
* @param {number} start Zero-based index at which to start the iteration.
|
|
17025
|
+
* @param {number} maxIter The maximum number of iterations.
|
|
17026
|
+
* @param {number} increment Increment between indicies.
|
|
17027
|
+
* @param {number} blockMaxIter Number of applied increment after which
|
|
17028
|
+
* blockIncrement is applied.
|
|
17029
|
+
* @param {number} blockIncrement Increment after blockMaxIter is reached,
|
|
17030
|
+
* the value is from block start to the next block start.
|
|
17031
|
+
* @param {boolean} reverse1 If true, loop from end to start.
|
|
17032
|
+
* WARN: don't forget to set the value of start as the last index!
|
|
17033
|
+
* @param {boolean} reverse2 If true, loop from block end to block start.
|
|
17034
|
+
* @param {boolean} isPlanar A flag to know if the data is planar
|
|
17035
|
+
* (RRRR...GGGG...BBBB...) or not (RGBRGBRGBRGB...), defaults to false.
|
|
17036
|
+
* @returns {object} An iterator folowing the iterator and iterable protocol.
|
|
17037
|
+
*/
|
|
17038
|
+
dwv.image.range3d = function (dataAccessor, start, maxIter, increment,
|
|
17039
|
+
blockMaxIter, blockIncrement, reverse1, reverse2, isPlanar) {
|
|
17040
|
+
var iters = [];
|
|
17041
|
+
if (isPlanar) {
|
|
17042
|
+
iters.push(dwv.image.range(
|
|
17043
|
+
dataAccessor, start, maxIter, increment,
|
|
17044
|
+
blockMaxIter, blockIncrement, reverse1, reverse2
|
|
17045
|
+
));
|
|
17046
|
+
iters.push(dwv.image.range(
|
|
17047
|
+
dataAccessor, start + maxIter * increment, maxIter, increment,
|
|
17048
|
+
blockMaxIter, blockIncrement, reverse1, reverse2
|
|
17049
|
+
));
|
|
17050
|
+
iters.push(dwv.image.range(
|
|
17051
|
+
dataAccessor, start + 2 * maxIter * increment, maxIter, increment,
|
|
17052
|
+
blockMaxIter, blockIncrement, reverse1, reverse2
|
|
17053
|
+
));
|
|
17054
|
+
} else {
|
|
17055
|
+
increment *= 3;
|
|
17056
|
+
blockIncrement *= 3;
|
|
17057
|
+
iters.push(dwv.image.range(
|
|
17058
|
+
dataAccessor, start, maxIter, increment,
|
|
17059
|
+
blockMaxIter, blockIncrement, reverse1, reverse2
|
|
17060
|
+
));
|
|
17061
|
+
iters.push(dwv.image.range(
|
|
17062
|
+
dataAccessor, start + 1, maxIter, increment,
|
|
17063
|
+
blockMaxIter, blockIncrement, reverse1, reverse2
|
|
17064
|
+
));
|
|
17065
|
+
iters.push(dwv.image.range(
|
|
17066
|
+
dataAccessor, start + 2, maxIter, increment,
|
|
17067
|
+
blockMaxIter, blockIncrement, reverse1, reverse2
|
|
17068
|
+
));
|
|
17069
|
+
}
|
|
17070
|
+
|
|
17071
|
+
// result
|
|
17072
|
+
return {
|
|
17073
|
+
next: function () {
|
|
17074
|
+
var r0 = iters[0].next();
|
|
17075
|
+
var r1 = iters[1].next();
|
|
17076
|
+
var r2 = iters[2].next();
|
|
17077
|
+
if (!r0.done) {
|
|
17078
|
+
return {
|
|
17079
|
+
value: [
|
|
17080
|
+
r0.value,
|
|
17081
|
+
r1.value,
|
|
17082
|
+
r2.value
|
|
17083
|
+
],
|
|
17084
|
+
done: false
|
|
17085
|
+
};
|
|
17086
|
+
}
|
|
17087
|
+
return {
|
|
17088
|
+
done: true,
|
|
17089
|
+
index: r2.index
|
|
17090
|
+
};
|
|
17091
|
+
}
|
|
17092
|
+
};
|
|
17093
|
+
};
|
|
17094
|
+
|
|
16906
17095
|
/**
|
|
16907
17096
|
* Get a list of values for a given iterator.
|
|
16908
17097
|
*
|
|
@@ -16964,70 +17153,82 @@ dwv.image.getSliceIterator = function (
|
|
|
16964
17153
|
var nslices = size.get(2);
|
|
16965
17154
|
var sliceSize = size.getDimSize(2);
|
|
16966
17155
|
|
|
17156
|
+
var ncomp = image.getNumberOfComponents();
|
|
17157
|
+
var isPlanar = image.getPlanarConfiguration() === 1;
|
|
17158
|
+
var getRange = function (
|
|
17159
|
+
dataAccessor, start, maxIter, increment,
|
|
17160
|
+
blockMaxIter, blockIncrement, reverse1, reverse2) {
|
|
17161
|
+
if (ncomp === 1) {
|
|
17162
|
+
return dwv.image.range(dataAccessor, start, maxIter, increment,
|
|
17163
|
+
blockMaxIter, blockIncrement, reverse1, reverse2);
|
|
17164
|
+
} else if (ncomp === 3) {
|
|
17165
|
+
return dwv.image.range3d(dataAccessor, 3 * start, maxIter, increment,
|
|
17166
|
+
blockMaxIter, blockIncrement, reverse1, reverse2, isPlanar);
|
|
17167
|
+
}
|
|
17168
|
+
};
|
|
17169
|
+
|
|
16967
17170
|
var range = null;
|
|
16968
|
-
if (
|
|
16969
|
-
|
|
16970
|
-
|
|
16971
|
-
|
|
16972
|
-
|
|
16973
|
-
|
|
16974
|
-
|
|
16975
|
-
|
|
16976
|
-
|
|
16977
|
-
|
|
16978
|
-
|
|
16979
|
-
|
|
16980
|
-
|
|
16981
|
-
|
|
16982
|
-
|
|
16983
|
-
|
|
16984
|
-
|
|
16985
|
-
|
|
16986
|
-
|
|
16987
|
-
|
|
16988
|
-
|
|
16989
|
-
|
|
16990
|
-
|
|
16991
|
-
|
|
16992
|
-
|
|
16993
|
-
|
|
16994
|
-
|
|
16995
|
-
|
|
16996
|
-
|
|
16997
|
-
|
|
16998
|
-
|
|
16999
|
-
|
|
17000
|
-
|
|
17001
|
-
|
|
17002
|
-
|
|
17003
|
-
|
|
17004
|
-
|
|
17005
|
-
|
|
17006
|
-
|
|
17007
|
-
|
|
17008
|
-
start, maxIter, 1, ncols, sliceSize, reverse1, reverse2);
|
|
17009
|
-
} else {
|
|
17010
|
-
// zxy
|
|
17011
|
-
range = dwv.image.range(dataAccessor,
|
|
17012
|
-
start, maxIter, sliceSize, nslices, 1, reverse1, reverse2);
|
|
17013
|
-
}
|
|
17171
|
+
if (viewOrientation && typeof viewOrientation !== 'undefined') {
|
|
17172
|
+
var dirMax0 = viewOrientation.getColAbsMax(0);
|
|
17173
|
+
var dirMax2 = viewOrientation.getColAbsMax(2);
|
|
17174
|
+
|
|
17175
|
+
// default reverse
|
|
17176
|
+
var reverse1 = false;
|
|
17177
|
+
var reverse2 = false;
|
|
17178
|
+
|
|
17179
|
+
var maxIter = null;
|
|
17180
|
+
if (dirMax2.index === 2) {
|
|
17181
|
+
// axial
|
|
17182
|
+
maxIter = ncols * nrows;
|
|
17183
|
+
if (dirMax0.index === 0) {
|
|
17184
|
+
// xyz
|
|
17185
|
+
range = getRange(dataAccessor,
|
|
17186
|
+
start, maxIter, 1, ncols, ncols, reverse1, reverse2);
|
|
17187
|
+
} else {
|
|
17188
|
+
// yxz
|
|
17189
|
+
range = getRange(dataAccessor,
|
|
17190
|
+
start, maxIter, ncols, nrows, 1, reverse1, reverse2);
|
|
17191
|
+
}
|
|
17192
|
+
} else if (dirMax2.index === 0) {
|
|
17193
|
+
// sagittal
|
|
17194
|
+
maxIter = nslices * nrows;
|
|
17195
|
+
if (dirMax0.index === 1) {
|
|
17196
|
+
// yzx
|
|
17197
|
+
range = getRange(dataAccessor,
|
|
17198
|
+
start, maxIter, ncols, nrows, sliceSize, reverse1, reverse2);
|
|
17199
|
+
} else {
|
|
17200
|
+
// zyx
|
|
17201
|
+
range = getRange(dataAccessor,
|
|
17202
|
+
start, maxIter, sliceSize, nslices, ncols, reverse1, reverse2);
|
|
17203
|
+
}
|
|
17204
|
+
} else if (dirMax2.index === 1) {
|
|
17205
|
+
// coronal
|
|
17206
|
+
maxIter = nslices * ncols;
|
|
17207
|
+
if (dirMax0.index === 0) {
|
|
17208
|
+
// xzy
|
|
17209
|
+
range = getRange(dataAccessor,
|
|
17210
|
+
start, maxIter, 1, ncols, sliceSize, reverse1, reverse2);
|
|
17014
17211
|
} else {
|
|
17015
|
-
|
|
17212
|
+
// zxy
|
|
17213
|
+
range = getRange(dataAccessor,
|
|
17214
|
+
start, maxIter, sliceSize, nslices, 1, reverse1, reverse2);
|
|
17016
17215
|
}
|
|
17017
17216
|
} else {
|
|
17018
|
-
|
|
17019
|
-
range = dwv.image.simpleRange(dataAccessor, start, start + sliceSize);
|
|
17217
|
+
throw new Error('Unknown direction: ' + dirMax2.index);
|
|
17020
17218
|
}
|
|
17021
|
-
} else if (image.getNumberOfComponents() === 3) {
|
|
17022
|
-
// 3 times bigger...
|
|
17023
|
-
start *= 3;
|
|
17024
|
-
sliceSize *= 3;
|
|
17025
|
-
var isPlanar = image.getPlanarConfiguration() === 1;
|
|
17026
|
-
range = dwv.image.range3d(
|
|
17027
|
-
dataAccessor, start, start + sliceSize, 1, isPlanar);
|
|
17028
17219
|
} else {
|
|
17029
|
-
|
|
17030
|
-
image.
|
|
17220
|
+
if (image.getNumberOfComponents() === 1) {
|
|
17221
|
+
range = dwv.image.simpleRange(dataAccessor, start, start + sliceSize);
|
|
17222
|
+
} else if (image.getNumberOfComponents() === 3) {
|
|
17223
|
+
// 3 times bigger...
|
|
17224
|
+
start *= 3;
|
|
17225
|
+
sliceSize *= 3;
|
|
17226
|
+
range = dwv.image.simpleRange3d(
|
|
17227
|
+
dataAccessor, start, start + sliceSize, 1, isPlanar);
|
|
17228
|
+
} else {
|
|
17229
|
+
throw new Error('Unsupported number of components: ' +
|
|
17230
|
+
image.getNumberOfComponents());
|
|
17231
|
+
}
|
|
17031
17232
|
}
|
|
17032
17233
|
|
|
17033
17234
|
return range;
|
|
@@ -17409,6 +17610,358 @@ dwv.image.lut.test = {
|
|
|
17409
17610
|
var dwv = dwv || {};
|
|
17410
17611
|
dwv.image = dwv.image || {};
|
|
17411
17612
|
|
|
17613
|
+
/**
|
|
17614
|
+
* Mask {@link dwv.image.Image} factory.
|
|
17615
|
+
*
|
|
17616
|
+
* @class
|
|
17617
|
+
*/
|
|
17618
|
+
dwv.image.MaskFactory = function () {};
|
|
17619
|
+
|
|
17620
|
+
/**
|
|
17621
|
+
* Get an {@link dwv.image.Image} object from the read DICOM file.
|
|
17622
|
+
*
|
|
17623
|
+
* @param {object} dicomElements The DICOM tags.
|
|
17624
|
+
* @param {Array} pixelBuffer The pixel buffer.
|
|
17625
|
+
* @returns {dwv.image.Image} A new Image.
|
|
17626
|
+
*/
|
|
17627
|
+
dwv.image.MaskFactory.prototype.create = function (
|
|
17628
|
+
dicomElements, pixelBuffer) {
|
|
17629
|
+
// columns
|
|
17630
|
+
var columns = dicomElements.getFromKey('x00280011');
|
|
17631
|
+
if (!columns) {
|
|
17632
|
+
throw new Error('Missing or empty DICOM image number of columns');
|
|
17633
|
+
}
|
|
17634
|
+
// rows
|
|
17635
|
+
var rows = dicomElements.getFromKey('x00280010');
|
|
17636
|
+
if (!rows) {
|
|
17637
|
+
throw new Error('Missing or empty DICOM image number of rows');
|
|
17638
|
+
}
|
|
17639
|
+
var sliceSize = columns * rows;
|
|
17640
|
+
|
|
17641
|
+
// frames
|
|
17642
|
+
var frames = dicomElements.getFromKey('x00280008');
|
|
17643
|
+
if (!frames) {
|
|
17644
|
+
frames = 1;
|
|
17645
|
+
} else {
|
|
17646
|
+
frames = parseInt(frames, 10);
|
|
17647
|
+
}
|
|
17648
|
+
|
|
17649
|
+
if (frames !== pixelBuffer.length / sliceSize) {
|
|
17650
|
+
throw new Error(
|
|
17651
|
+
'Buffer and numberOfFrames meta are not equal.');
|
|
17652
|
+
}
|
|
17653
|
+
|
|
17654
|
+
// Segmentation Type
|
|
17655
|
+
var segType = dicomElements.getFromKey('x00620001');
|
|
17656
|
+
if (!segType) {
|
|
17657
|
+
throw new Error('Missing or empty DICOM segmentation type');
|
|
17658
|
+
} else {
|
|
17659
|
+
segType = dwv.dicom.cleanString(segType);
|
|
17660
|
+
}
|
|
17661
|
+
if (segType !== 'BINARY') {
|
|
17662
|
+
throw new Error('Unsupported segmentation type: ' + segType);
|
|
17663
|
+
}
|
|
17664
|
+
|
|
17665
|
+
// check if compressed
|
|
17666
|
+
var syntax = dwv.dicom.cleanString(dicomElements.getFromKey('x00020010'));
|
|
17667
|
+
var algoName = dwv.dicom.getSyntaxDecompressionName(syntax);
|
|
17668
|
+
if (algoName !== null) {
|
|
17669
|
+
throw new Error('Unsupported compressed segmentation: ' + algoName);
|
|
17670
|
+
}
|
|
17671
|
+
|
|
17672
|
+
// Segment Sequence
|
|
17673
|
+
var segSequence = dicomElements.getFromKey('x00620002', true);
|
|
17674
|
+
if (!segSequence || typeof segSequence === 'undefined') {
|
|
17675
|
+
throw new Error('Missing or empty segmentation sequence');
|
|
17676
|
+
}
|
|
17677
|
+
var labels = [];
|
|
17678
|
+
var storeAsRGB = false;
|
|
17679
|
+
for (var i = 0; i < segSequence.length; ++i) {
|
|
17680
|
+
// value -> Segment Number
|
|
17681
|
+
// name -> Segment Label
|
|
17682
|
+
var label = {
|
|
17683
|
+
value: segSequence[i].x00620004.value[0],
|
|
17684
|
+
name: dwv.dicom.cleanString(segSequence[i].x00620005.value[0]),
|
|
17685
|
+
algorithmType: dwv.dicom.cleanString(segSequence[i].x00620008.value[0])
|
|
17686
|
+
};
|
|
17687
|
+
// Segment Algorithm Name
|
|
17688
|
+
if (segSequence[i].x00620009) {
|
|
17689
|
+
label.algorithmName =
|
|
17690
|
+
dwv.dicom.cleanString(segSequence[i].x00620009.value[0]);
|
|
17691
|
+
}
|
|
17692
|
+
// Recommended Display CIELab Value
|
|
17693
|
+
if (typeof segSequence[i].x0062000D !== 'undefined') {
|
|
17694
|
+
var cielabElement = segSequence[i].x0062000D.value;
|
|
17695
|
+
var rgb = dwv.utils.cielabToSrgb(dwv.utils.uintLabToLab({
|
|
17696
|
+
l: cielabElement[0],
|
|
17697
|
+
a: cielabElement[1],
|
|
17698
|
+
b: cielabElement[2]
|
|
17699
|
+
}));
|
|
17700
|
+
label.colour = rgb;
|
|
17701
|
+
// create rgb image
|
|
17702
|
+
storeAsRGB = true;
|
|
17703
|
+
}
|
|
17704
|
+
// store
|
|
17705
|
+
labels.push(label);
|
|
17706
|
+
}
|
|
17707
|
+
|
|
17708
|
+
// image size
|
|
17709
|
+
var size = dicomElements.getImageSize();
|
|
17710
|
+
|
|
17711
|
+
var getSpacingFromMeasure = function (measure) {
|
|
17712
|
+
if (typeof measure.x00280030 === 'undefined') {
|
|
17713
|
+
return null;
|
|
17714
|
+
}
|
|
17715
|
+
var pixelSpacing = measure.x00280030;
|
|
17716
|
+
var spacingValues = [
|
|
17717
|
+
parseFloat(pixelSpacing.value[0]),
|
|
17718
|
+
parseFloat(pixelSpacing.value[1])
|
|
17719
|
+
];
|
|
17720
|
+
if (typeof measure.x00180088 !== 'undefined') {
|
|
17721
|
+
var sliceThickness = measure.x00180088;
|
|
17722
|
+
spacingValues.push(parseFloat(sliceThickness.value[0]));
|
|
17723
|
+
}
|
|
17724
|
+
return new dwv.image.Spacing(spacingValues);
|
|
17725
|
+
};
|
|
17726
|
+
|
|
17727
|
+
// Shared Functional Groups Sequence
|
|
17728
|
+
var spacing;
|
|
17729
|
+
var imageOrientationPatient;
|
|
17730
|
+
var sharedFunctionalGroupsSeq = dicomElements.getFromKey('x52009229', true);
|
|
17731
|
+
if (sharedFunctionalGroupsSeq.length !== 0) {
|
|
17732
|
+
// should be only one
|
|
17733
|
+
var funcGroup0 = sharedFunctionalGroupsSeq[0];
|
|
17734
|
+
// Plane Orientation Sequence
|
|
17735
|
+
if (typeof funcGroup0.x00209116 !== 'undefined') {
|
|
17736
|
+
var planeOrientationSeq = funcGroup0.x00209116;
|
|
17737
|
+
if (planeOrientationSeq.value.length !== 0) {
|
|
17738
|
+
// should be only one
|
|
17739
|
+
imageOrientationPatient = planeOrientationSeq.value[0].x00200037.value;
|
|
17740
|
+
} else {
|
|
17741
|
+
dwv.logger.warn(
|
|
17742
|
+
'No shared functional group plane orientation sequence items.');
|
|
17743
|
+
}
|
|
17744
|
+
}
|
|
17745
|
+
// Pixel Measures Sequence
|
|
17746
|
+
if (typeof funcGroup0.x00289110 !== 'undefined') {
|
|
17747
|
+
var pixelMeasuresSeq = funcGroup0.x00289110;
|
|
17748
|
+
if (pixelMeasuresSeq.value.length !== 0) {
|
|
17749
|
+
// should be only one
|
|
17750
|
+
spacing = getSpacingFromMeasure(pixelMeasuresSeq.value[0]);
|
|
17751
|
+
} else {
|
|
17752
|
+
dwv.logger.warn(
|
|
17753
|
+
'No shared functional group pixel measure sequence items.');
|
|
17754
|
+
}
|
|
17755
|
+
}
|
|
17756
|
+
}
|
|
17757
|
+
|
|
17758
|
+
// position patient utility functions
|
|
17759
|
+
var equalPosPat = function (pos1, pos2) {
|
|
17760
|
+
return JSON.stringify(pos1) === JSON.stringify(pos2);
|
|
17761
|
+
};
|
|
17762
|
+
|
|
17763
|
+
var comparePosPat = function (pos1, pos2) {
|
|
17764
|
+
var diff = null;
|
|
17765
|
+
var posLen = pos1.length;
|
|
17766
|
+
var index = posLen;
|
|
17767
|
+
for (var i = 0; i < posLen; ++i) {
|
|
17768
|
+
--index;
|
|
17769
|
+
diff = pos2[index] - pos1[index];
|
|
17770
|
+
if (diff !== 0) {
|
|
17771
|
+
return diff;
|
|
17772
|
+
}
|
|
17773
|
+
}
|
|
17774
|
+
return diff;
|
|
17775
|
+
};
|
|
17776
|
+
|
|
17777
|
+
var includesPosPat = function (arr, val) {
|
|
17778
|
+
return arr.some(function (arrVal) {
|
|
17779
|
+
return equalPosPat(val, arrVal);
|
|
17780
|
+
});
|
|
17781
|
+
};
|
|
17782
|
+
|
|
17783
|
+
var findIndexPosPat = function (arr, val) {
|
|
17784
|
+
return arr.findIndex(function (arrVal) {
|
|
17785
|
+
return equalPosPat(val, arrVal);
|
|
17786
|
+
});
|
|
17787
|
+
};
|
|
17788
|
+
|
|
17789
|
+
var arrayEquals = function (arr0, arr1) {
|
|
17790
|
+
if (arr0 === null || arr1 === null) {
|
|
17791
|
+
return false;
|
|
17792
|
+
}
|
|
17793
|
+
if (arr0.length !== arr1.length) {
|
|
17794
|
+
return false;
|
|
17795
|
+
}
|
|
17796
|
+
return arr0.every(function (element, index) {
|
|
17797
|
+
return element === arr1[index];
|
|
17798
|
+
});
|
|
17799
|
+
};
|
|
17800
|
+
|
|
17801
|
+
// Per-frame Functional Groups Sequence
|
|
17802
|
+
var perFrameFuncGroupSequence = dicomElements.getFromKey('x52009230', true);
|
|
17803
|
+
if (!perFrameFuncGroupSequence ||
|
|
17804
|
+
typeof perFrameFuncGroupSequence === 'undefined') {
|
|
17805
|
+
throw new Error('Missing or empty per frame functional sequence');
|
|
17806
|
+
}
|
|
17807
|
+
if (frames !== perFrameFuncGroupSequence.length) {
|
|
17808
|
+
throw new Error(
|
|
17809
|
+
'perFrameFuncGroupSequence meta and numberOfFrames are not equal.');
|
|
17810
|
+
}
|
|
17811
|
+
// create frame info object from per frame func
|
|
17812
|
+
var frameInfos = [];
|
|
17813
|
+
var posPats = [];
|
|
17814
|
+
for (var j = 0; j < perFrameFuncGroupSequence.length; ++j) {
|
|
17815
|
+
var frameFunc = perFrameFuncGroupSequence[j];
|
|
17816
|
+
// Derivation Image Sequence
|
|
17817
|
+
var referencedSOPInstanceUID;
|
|
17818
|
+
if (typeof frameFunc.x00089124 !== 'undefined') {
|
|
17819
|
+
var derivationImageSq = frameFunc.x00089124.value;
|
|
17820
|
+
// Source Image Sequence
|
|
17821
|
+
if (typeof derivationImageSq[0].x00082112 !== 'undefined') {
|
|
17822
|
+
var sourceImageSq = derivationImageSq[0].x00082112.value;
|
|
17823
|
+
// Referenced SOP Instance UID
|
|
17824
|
+
if (typeof sourceImageSq[0].x00081155 !== 'undefined') {
|
|
17825
|
+
referencedSOPInstanceUID = sourceImageSq[0].x00081155.value[0];
|
|
17826
|
+
}
|
|
17827
|
+
}
|
|
17828
|
+
}
|
|
17829
|
+
// Frame Content Sequence
|
|
17830
|
+
var frameContentSq = frameFunc.x00209111.value;
|
|
17831
|
+
// Dimension Index Value
|
|
17832
|
+
var dimIndex = frameContentSq[0].x00209157.value;
|
|
17833
|
+
// Plane Position Sequence
|
|
17834
|
+
var planePosSq = frameFunc.x00209113.value;
|
|
17835
|
+
// Image Position (Patient)
|
|
17836
|
+
var imagePosPat = planePosSq[0].x00200032.value;
|
|
17837
|
+
for (var p = 0; p < imagePosPat.length; ++p) {
|
|
17838
|
+
imagePosPat[p] = parseFloat(imagePosPat[p], 10);
|
|
17839
|
+
}
|
|
17840
|
+
if (!includesPosPat(posPats, imagePosPat)) {
|
|
17841
|
+
posPats.push(imagePosPat);
|
|
17842
|
+
}
|
|
17843
|
+
frameInfos.push({
|
|
17844
|
+
dimIndex: dimIndex,
|
|
17845
|
+
imagePosPat: imagePosPat,
|
|
17846
|
+
referencedSOPInstanceUID: referencedSOPInstanceUID
|
|
17847
|
+
});
|
|
17848
|
+
// Plane Orientation Sequence
|
|
17849
|
+
if (typeof frameFunc.x00209116 !== 'undefined') {
|
|
17850
|
+
var framePlaneOrientationSeq = frameFunc.x00209116;
|
|
17851
|
+
if (framePlaneOrientationSeq.value.length !== 0) {
|
|
17852
|
+
// should only be one
|
|
17853
|
+
var frameImageOrientation =
|
|
17854
|
+
framePlaneOrientationSeq.value[0].x00200037.value;
|
|
17855
|
+
if (typeof imageOrientationPatient === 'undefined') {
|
|
17856
|
+
imageOrientationPatient = frameImageOrientation;
|
|
17857
|
+
} else {
|
|
17858
|
+
if (!arrayEquals(frameImageOrientation, imageOrientationPatient)) {
|
|
17859
|
+
throw new Error('Unsupported multi orientation dicom seg.');
|
|
17860
|
+
}
|
|
17861
|
+
}
|
|
17862
|
+
}
|
|
17863
|
+
}
|
|
17864
|
+
// Pixel Measures Sequence
|
|
17865
|
+
if (typeof frameFunc.x00289110 !== 'undefined') {
|
|
17866
|
+
var framePixelMeasuresSeq = frameFunc.x00289110;
|
|
17867
|
+
if (framePixelMeasuresSeq.value.length !== 0) {
|
|
17868
|
+
// should only be one
|
|
17869
|
+
var frameSpacing =
|
|
17870
|
+
getSpacingFromMeasure(framePixelMeasuresSeq.value[0]);
|
|
17871
|
+
if (typeof spacing === 'undefined') {
|
|
17872
|
+
spacing = frameSpacing;
|
|
17873
|
+
} else {
|
|
17874
|
+
if (!spacing.equals(frameSpacing)) {
|
|
17875
|
+
throw new Error('Unsupported multi resolution dicom seg.');
|
|
17876
|
+
}
|
|
17877
|
+
}
|
|
17878
|
+
} else {
|
|
17879
|
+
dwv.logger.warn(
|
|
17880
|
+
'No shared functional group pixel measure sequence items.');
|
|
17881
|
+
}
|
|
17882
|
+
}
|
|
17883
|
+
}
|
|
17884
|
+
// sort positions patient
|
|
17885
|
+
posPats.sort(comparePosPat);
|
|
17886
|
+
|
|
17887
|
+
// create output buffer
|
|
17888
|
+
// as many slices as posPats -> gap slices between groups are not represented
|
|
17889
|
+
var numberOfSlices = posPats.length;
|
|
17890
|
+
var mul = storeAsRGB ? 3 : 1;
|
|
17891
|
+
var buffer = new pixelBuffer.constructor(mul * sliceSize * numberOfSlices);
|
|
17892
|
+
buffer.fill(0);
|
|
17893
|
+
// merge frame buffers
|
|
17894
|
+
var sliceOffset = null;
|
|
17895
|
+
var sliceIndex = null;
|
|
17896
|
+
var frameOffset = null;
|
|
17897
|
+
var labelIndex = null;
|
|
17898
|
+
for (var f = 0; f < frameInfos.length; ++f) {
|
|
17899
|
+
// get the slice index from the position in the posPat array
|
|
17900
|
+
sliceIndex = findIndexPosPat(posPats, frameInfos[f].imagePosPat);
|
|
17901
|
+
frameOffset = sliceSize * f;
|
|
17902
|
+
labelIndex = frameInfos[f].dimIndex[0] - 1;
|
|
17903
|
+
sliceOffset = sliceSize * sliceIndex;
|
|
17904
|
+
var pixelValue;
|
|
17905
|
+
if (storeAsRGB) {
|
|
17906
|
+
pixelValue = labels[labelIndex].colour;
|
|
17907
|
+
} else {
|
|
17908
|
+
pixelValue = labels[labelIndex].value;
|
|
17909
|
+
}
|
|
17910
|
+
for (var l = 0; l < sliceSize; ++l) {
|
|
17911
|
+
if (pixelBuffer[frameOffset + l] !== 0) {
|
|
17912
|
+
var offset = mul * (sliceOffset + l);
|
|
17913
|
+
if (storeAsRGB) {
|
|
17914
|
+
buffer[offset] = pixelValue.r;
|
|
17915
|
+
buffer[offset + 1] = pixelValue.g;
|
|
17916
|
+
buffer[offset + 2] = pixelValue.b;
|
|
17917
|
+
} else {
|
|
17918
|
+
buffer[offset] = pixelValue;
|
|
17919
|
+
}
|
|
17920
|
+
}
|
|
17921
|
+
}
|
|
17922
|
+
}
|
|
17923
|
+
|
|
17924
|
+
if (typeof spacing === 'undefined') {
|
|
17925
|
+
throw Error('No spacing found in DICOM seg file.');
|
|
17926
|
+
}
|
|
17927
|
+
|
|
17928
|
+
// geometry
|
|
17929
|
+
var point3DFromArray = function (arr) {
|
|
17930
|
+
return new dwv.math.Point3D(arr[0], arr[1], arr[2]);
|
|
17931
|
+
};
|
|
17932
|
+
var origin = point3DFromArray(posPats[0]);
|
|
17933
|
+
var geometry = new dwv.image.Geometry(origin, size, spacing);
|
|
17934
|
+
var uids = [0];
|
|
17935
|
+
for (var m = 1; m < numberOfSlices; ++m) {
|
|
17936
|
+
// args: origin, volumeNumber, uid, index, increment
|
|
17937
|
+
geometry.appendOrigin(point3DFromArray(posPats[m]), m);
|
|
17938
|
+
uids.push(m);
|
|
17939
|
+
}
|
|
17940
|
+
|
|
17941
|
+
// create image
|
|
17942
|
+
var image = new dwv.image.Image(geometry, buffer, uids);
|
|
17943
|
+
if (storeAsRGB) {
|
|
17944
|
+
image.setPhotometricInterpretation('RGB');
|
|
17945
|
+
}
|
|
17946
|
+
// image meta
|
|
17947
|
+
var meta = {
|
|
17948
|
+
Modality: 'SEG',
|
|
17949
|
+
BitsStored: 8,
|
|
17950
|
+
labels: labels,
|
|
17951
|
+
frameInfos: frameInfos,
|
|
17952
|
+
SeriesInstanceUID: dicomElements.getFromKey('x0020000E'),
|
|
17953
|
+
SOPInstanceUID: dicomElements.getFromKey('x00080018'),
|
|
17954
|
+
ImageOrientationPatient: imageOrientationPatient
|
|
17955
|
+
};
|
|
17956
|
+
image.setMeta(meta);
|
|
17957
|
+
|
|
17958
|
+
return image;
|
|
17959
|
+
};
|
|
17960
|
+
|
|
17961
|
+
// namespaces
|
|
17962
|
+
var dwv = dwv || {};
|
|
17963
|
+
dwv.image = dwv.image || {};
|
|
17964
|
+
|
|
17412
17965
|
/**
|
|
17413
17966
|
* Plane geometry helper.
|
|
17414
17967
|
*
|
|
@@ -18163,12 +18716,12 @@ dwv.image.View = function (image) {
|
|
|
18163
18716
|
// to add the extra dimension
|
|
18164
18717
|
image.addEventListener('appendframe', function () {
|
|
18165
18718
|
// update current position if first appendFrame
|
|
18166
|
-
var
|
|
18167
|
-
if (
|
|
18719
|
+
var index = self.getCurrentIndex();
|
|
18720
|
+
if (index.length() === 3) {
|
|
18168
18721
|
// add dimension
|
|
18169
|
-
var values =
|
|
18722
|
+
var values = index.getValues();
|
|
18170
18723
|
values.push(0);
|
|
18171
|
-
self.
|
|
18724
|
+
self.setCurrentIndex(new dwv.math.Index(values));
|
|
18172
18725
|
}
|
|
18173
18726
|
});
|
|
18174
18727
|
|
|
@@ -18216,9 +18769,9 @@ dwv.image.View = function (image) {
|
|
|
18216
18769
|
* Current position as a Point3D.
|
|
18217
18770
|
*
|
|
18218
18771
|
* @private
|
|
18219
|
-
* @type {
|
|
18772
|
+
* @type {dwv.math.Index}
|
|
18220
18773
|
*/
|
|
18221
|
-
var
|
|
18774
|
+
var currentIndex = null;
|
|
18222
18775
|
/**
|
|
18223
18776
|
* View orientation. Undefined will use the original slice ordering.
|
|
18224
18777
|
*
|
|
@@ -18271,20 +18824,20 @@ dwv.image.View = function (image) {
|
|
|
18271
18824
|
};
|
|
18272
18825
|
|
|
18273
18826
|
/**
|
|
18274
|
-
*
|
|
18827
|
+
* Initialise the view: set initial index.
|
|
18275
18828
|
*/
|
|
18276
|
-
this.
|
|
18277
|
-
|
|
18829
|
+
this.init = function () {
|
|
18830
|
+
this.setInitialIndex();
|
|
18831
|
+
};
|
|
18278
18832
|
|
|
18833
|
+
/**
|
|
18834
|
+
* Set the initial index to 0.
|
|
18835
|
+
*/
|
|
18836
|
+
this.setInitialIndex = function () {
|
|
18279
18837
|
var geometry = image.getGeometry();
|
|
18280
18838
|
var values = new Array(geometry.getSize().length());
|
|
18281
18839
|
values.fill(0);
|
|
18282
|
-
|
|
18283
|
-
|
|
18284
|
-
this.setCurrentPosition(
|
|
18285
|
-
geometry.indexToWorld(index),
|
|
18286
|
-
silent
|
|
18287
|
-
);
|
|
18840
|
+
this.setCurrentIndex(new dwv.math.Index(values), true);
|
|
18288
18841
|
};
|
|
18289
18842
|
|
|
18290
18843
|
/**
|
|
@@ -18353,10 +18906,9 @@ dwv.image.View = function (image) {
|
|
|
18353
18906
|
*/
|
|
18354
18907
|
this.getCurrentWindowLut = function (rsi) {
|
|
18355
18908
|
// check position
|
|
18356
|
-
if (!this.
|
|
18357
|
-
this.
|
|
18909
|
+
if (!this.getCurrentIndex()) {
|
|
18910
|
+
this.setInitialIndex();
|
|
18358
18911
|
}
|
|
18359
|
-
var currentIndex = this.getCurrentIndex();
|
|
18360
18912
|
// use current rsi if not provided
|
|
18361
18913
|
if (typeof rsi === 'undefined') {
|
|
18362
18914
|
rsi = image.getRescaleSlopeAndIntercept(currentIndex);
|
|
@@ -18539,7 +19091,8 @@ dwv.image.View = function (image) {
|
|
|
18539
19091
|
* @returns {dwv.math.Point} The current position.
|
|
18540
19092
|
*/
|
|
18541
19093
|
this.getCurrentPosition = function () {
|
|
18542
|
-
|
|
19094
|
+
var geometry = this.getImage().getGeometry();
|
|
19095
|
+
return geometry.indexToWorld(currentIndex);
|
|
18543
19096
|
};
|
|
18544
19097
|
|
|
18545
19098
|
/**
|
|
@@ -18548,60 +19101,89 @@ dwv.image.View = function (image) {
|
|
|
18548
19101
|
* @returns {dwv.math.Index} The current index.
|
|
18549
19102
|
*/
|
|
18550
19103
|
this.getCurrentIndex = function () {
|
|
18551
|
-
|
|
18552
|
-
return geometry.worldToIndex(currentPosition);
|
|
19104
|
+
return currentIndex;
|
|
18553
19105
|
};
|
|
18554
19106
|
|
|
18555
19107
|
/**
|
|
18556
19108
|
* Set the current position.
|
|
18557
19109
|
*
|
|
18558
|
-
* @param {dwv.math.Point}
|
|
19110
|
+
* @param {dwv.math.Point} position The new position.
|
|
18559
19111
|
* @param {boolean} silent Flag to fire event or not.
|
|
18560
19112
|
* @returns {boolean} False if not in bounds
|
|
18561
19113
|
* @fires dwv.image.View#positionchange
|
|
18562
19114
|
*/
|
|
18563
|
-
this.setCurrentPosition = function (
|
|
19115
|
+
this.setCurrentPosition = function (position, silent) {
|
|
19116
|
+
// send invalid event if not in bounds
|
|
19117
|
+
var geometry = image.getGeometry();
|
|
19118
|
+
var index = geometry.worldToIndex(position);
|
|
19119
|
+
if (!geometry.isIndexInBounds(index)) {
|
|
19120
|
+
if (!silent) {
|
|
19121
|
+
// fire event with valid: false
|
|
19122
|
+
fireEvent({
|
|
19123
|
+
type: 'positionchange',
|
|
19124
|
+
value: [
|
|
19125
|
+
index.getValues(),
|
|
19126
|
+
position.getValues(),
|
|
19127
|
+
],
|
|
19128
|
+
valid: false
|
|
19129
|
+
});
|
|
19130
|
+
}
|
|
19131
|
+
return false;
|
|
19132
|
+
}
|
|
19133
|
+
return this.setCurrentIndex(index, silent);
|
|
19134
|
+
};
|
|
19135
|
+
|
|
19136
|
+
/**
|
|
19137
|
+
* Set the current index.
|
|
19138
|
+
*
|
|
19139
|
+
* @param {dwv.math.Index} index The new index.
|
|
19140
|
+
* @param {boolean} silent Flag to fire event or not.
|
|
19141
|
+
* @returns {boolean} False if not in bounds
|
|
19142
|
+
* @fires dwv.image.View#positionchange
|
|
19143
|
+
*/
|
|
19144
|
+
this.setCurrentIndex = function (index, silent) {
|
|
18564
19145
|
// check input
|
|
18565
19146
|
if (typeof silent === 'undefined') {
|
|
18566
19147
|
silent = false;
|
|
18567
19148
|
}
|
|
18568
19149
|
|
|
18569
|
-
// check if possible
|
|
18570
19150
|
var geometry = image.getGeometry();
|
|
18571
|
-
|
|
19151
|
+
var position = geometry.indexToWorld(index);
|
|
19152
|
+
|
|
19153
|
+
// check if possible
|
|
19154
|
+
if (!geometry.isIndexInBounds(index)) {
|
|
18572
19155
|
return false;
|
|
18573
19156
|
}
|
|
18574
19157
|
|
|
18575
|
-
var isNew = !
|
|
19158
|
+
var isNew = !currentIndex || !currentIndex.equals(index);
|
|
18576
19159
|
|
|
18577
19160
|
if (isNew) {
|
|
18578
|
-
var posIndex = geometry.worldToIndex(newPosition);
|
|
18579
19161
|
var diffDims = null;
|
|
18580
|
-
if (
|
|
18581
|
-
if (
|
|
18582
|
-
diffDims =
|
|
19162
|
+
if (currentIndex) {
|
|
19163
|
+
if (currentIndex.canCompare(index)) {
|
|
19164
|
+
diffDims = currentIndex.compare(index);
|
|
18583
19165
|
} else {
|
|
18584
19166
|
diffDims = [];
|
|
18585
|
-
var minLen = Math.min(
|
|
19167
|
+
var minLen = Math.min(currentIndex.length(), index.length());
|
|
18586
19168
|
for (var i = 0; i < minLen; ++i) {
|
|
18587
|
-
if (
|
|
19169
|
+
if (currentIndex.get(i) !== index.get(i)) {
|
|
18588
19170
|
diffDims.push(i);
|
|
18589
19171
|
}
|
|
18590
19172
|
}
|
|
18591
|
-
var maxLen = Math.max(
|
|
19173
|
+
var maxLen = Math.max(currentIndex.length(), index.length());
|
|
18592
19174
|
for (var j = minLen; j < maxLen; ++j) {
|
|
18593
19175
|
diffDims.push(j);
|
|
18594
19176
|
}
|
|
18595
19177
|
}
|
|
18596
19178
|
} else {
|
|
18597
19179
|
diffDims = [];
|
|
18598
|
-
for (var k = 0; k <
|
|
19180
|
+
for (var k = 0; k < index.length(); ++k) {
|
|
18599
19181
|
diffDims.push(k);
|
|
18600
19182
|
}
|
|
18601
19183
|
}
|
|
18602
19184
|
|
|
18603
19185
|
// assign
|
|
18604
|
-
|
|
19186
|
+
currentIndex = index;
|
|
18605
19187
|
|
|
18606
19188
|
if (!silent) {
|
|
18607
19189
|
/**
|
|
@@ -18615,18 +19197,18 @@ dwv.image.View = function (image) {
|
|
|
18615
19197
|
var posEvent = {
|
|
18616
19198
|
type: 'positionchange',
|
|
18617
19199
|
value: [
|
|
18618
|
-
|
|
18619
|
-
|
|
19200
|
+
index.getValues(),
|
|
19201
|
+
position.getValues(),
|
|
18620
19202
|
],
|
|
18621
19203
|
diffDims: diffDims,
|
|
18622
19204
|
data: {
|
|
18623
|
-
imageUid: image.getImageUid(
|
|
19205
|
+
imageUid: image.getImageUid(index)
|
|
18624
19206
|
}
|
|
18625
19207
|
};
|
|
18626
19208
|
|
|
18627
19209
|
// add value if possible
|
|
18628
19210
|
if (image.canQuantify()) {
|
|
18629
|
-
var pixValue = image.getRescaledValueAtIndex(
|
|
19211
|
+
var pixValue = image.getRescaledValueAtIndex(index);
|
|
18630
19212
|
posEvent.value.push(pixValue);
|
|
18631
19213
|
}
|
|
18632
19214
|
|
|
@@ -18639,18 +19221,6 @@ dwv.image.View = function (image) {
|
|
|
18639
19221
|
return true;
|
|
18640
19222
|
};
|
|
18641
19223
|
|
|
18642
|
-
/**
|
|
18643
|
-
* Set the current index.
|
|
18644
|
-
*
|
|
18645
|
-
* @param {dwv.math.Index} index The index.
|
|
18646
|
-
* @param {boolean} silent If true, does not fire a positionchange event.
|
|
18647
|
-
* @returns {boolean} False if not in bounds.
|
|
18648
|
-
*/
|
|
18649
|
-
this.setCurrentIndex = function (index, silent) {
|
|
18650
|
-
var geometry = this.getImage().getGeometry();
|
|
18651
|
-
return this.setCurrentPosition(geometry.indexToWorld(index), silent);
|
|
18652
|
-
};
|
|
18653
|
-
|
|
18654
19224
|
/**
|
|
18655
19225
|
* Set the view window/level.
|
|
18656
19226
|
*
|
|
@@ -18832,16 +19402,21 @@ dwv.image.View.prototype.setWindowLevelMinMax = function () {
|
|
|
18832
19402
|
* Generate display image data to be given to a canvas.
|
|
18833
19403
|
*
|
|
18834
19404
|
* @param {Array} array The array to fill in.
|
|
19405
|
+
* @param {dwv.math.Index} index Optional index at which to generate,
|
|
19406
|
+
* otherwise generates at current index.
|
|
18835
19407
|
*/
|
|
18836
|
-
dwv.image.View.prototype.generateImageData = function (array) {
|
|
18837
|
-
// check
|
|
18838
|
-
if (
|
|
18839
|
-
this.
|
|
19408
|
+
dwv.image.View.prototype.generateImageData = function (array, index) {
|
|
19409
|
+
// check index
|
|
19410
|
+
if (typeof index === 'undefined') {
|
|
19411
|
+
if (!this.getCurrentIndex()) {
|
|
19412
|
+
this.setInitialIndex();
|
|
19413
|
+
}
|
|
19414
|
+
index = this.getCurrentIndex();
|
|
18840
19415
|
}
|
|
19416
|
+
|
|
18841
19417
|
var image = this.getImage();
|
|
18842
|
-
var position = this.getCurrentIndex();
|
|
18843
19418
|
var iterator = dwv.image.getSliceIterator(
|
|
18844
|
-
image,
|
|
19419
|
+
image, index, false, this.getOrientation());
|
|
18845
19420
|
|
|
18846
19421
|
var photoInterpretation = image.getPhotometricInterpretation();
|
|
18847
19422
|
switch (photoInterpretation) {
|
|
@@ -18907,8 +19482,7 @@ dwv.image.View.prototype.incrementIndex = function (dim, silent) {
|
|
|
18907
19482
|
}
|
|
18908
19483
|
var incr = new dwv.math.Index(values);
|
|
18909
19484
|
var newIndex = index.add(incr);
|
|
18910
|
-
|
|
18911
|
-
return this.setCurrentPosition(geometry.indexToWorld(newIndex), silent);
|
|
19485
|
+
return this.setCurrentIndex(newIndex, silent);
|
|
18912
19486
|
};
|
|
18913
19487
|
|
|
18914
19488
|
/**
|
|
@@ -18929,8 +19503,7 @@ dwv.image.View.prototype.decrementIndex = function (dim, silent) {
|
|
|
18929
19503
|
}
|
|
18930
19504
|
var incr = new dwv.math.Index(values);
|
|
18931
19505
|
var newIndex = index.add(incr);
|
|
18932
|
-
|
|
18933
|
-
return this.setCurrentPosition(geometry.indexToWorld(newIndex), silent);
|
|
19506
|
+
return this.setCurrentIndex(newIndex, silent);
|
|
18934
19507
|
};
|
|
18935
19508
|
|
|
18936
19509
|
/**
|
|
@@ -19036,8 +19609,8 @@ dwv.image.ViewFactory.prototype.create = function (dicomElements, image) {
|
|
|
19036
19609
|
// store
|
|
19037
19610
|
view.setWindowPresets(windowPresets);
|
|
19038
19611
|
|
|
19039
|
-
//
|
|
19040
|
-
view.
|
|
19612
|
+
// initialise the view
|
|
19613
|
+
view.init();
|
|
19041
19614
|
|
|
19042
19615
|
return view;
|
|
19043
19616
|
};
|
|
@@ -23249,6 +23822,27 @@ dwv.math.Index.prototype.equals = function (rhs) {
|
|
|
23249
23822
|
return true;
|
|
23250
23823
|
};
|
|
23251
23824
|
|
|
23825
|
+
/**
|
|
23826
|
+
* Compare indices and return different dimensions.
|
|
23827
|
+
*
|
|
23828
|
+
* @param {dwv.math.Index} rhs The index to compare to.
|
|
23829
|
+
* @returns {Array} The list of different dimensions.
|
|
23830
|
+
*/
|
|
23831
|
+
dwv.math.Index.prototype.compare = function (rhs) {
|
|
23832
|
+
// check if can compare
|
|
23833
|
+
if (!this.canCompare(rhs)) {
|
|
23834
|
+
return null;
|
|
23835
|
+
}
|
|
23836
|
+
// check values
|
|
23837
|
+
var diffDims = [];
|
|
23838
|
+
for (var i = 0, leni = this.length(); i < leni; ++i) {
|
|
23839
|
+
if (this.get(i) !== rhs.get(i)) {
|
|
23840
|
+
diffDims.push(i);
|
|
23841
|
+
}
|
|
23842
|
+
}
|
|
23843
|
+
return diffDims;
|
|
23844
|
+
};
|
|
23845
|
+
|
|
23252
23846
|
/**
|
|
23253
23847
|
* Add another index to this one.
|
|
23254
23848
|
*
|
|
@@ -32428,7 +33022,11 @@ dwv.utils.buildMultipart = function (parts, boundary) {
|
|
|
32428
33022
|
var partsSize = 0;
|
|
32429
33023
|
var headers = [];
|
|
32430
33024
|
for (var i = 0; i < parts.length; ++i) {
|
|
32431
|
-
var headerStr = '
|
|
33025
|
+
var headerStr = '';
|
|
33026
|
+
if (i !== 0) {
|
|
33027
|
+
headerStr += lineBreak;
|
|
33028
|
+
}
|
|
33029
|
+
headerStr += '--' + boundary + lineBreak;
|
|
32432
33030
|
var partKeys = Object.keys(parts[i]);
|
|
32433
33031
|
for (var k = 0; k < partKeys.length; ++k) {
|
|
32434
33032
|
var key = partKeys[k];
|
|
@@ -32442,7 +33040,7 @@ dwv.utils.buildMultipart = function (parts, boundary) {
|
|
|
32442
33040
|
partsSize += header.byteLength + parts[i].data.byteLength;
|
|
32443
33041
|
}
|
|
32444
33042
|
// build trailer
|
|
32445
|
-
var trailerStr = '--' + boundary + '--' + lineBreak;
|
|
33043
|
+
var trailerStr = lineBreak + '--' + boundary + '--' + lineBreak;
|
|
32446
33044
|
var trailer = dwv.utils.stringToUint8Array(trailerStr);
|
|
32447
33045
|
|
|
32448
33046
|
// final buffer
|
|
@@ -35315,8 +35913,10 @@ dwv.utils.loadFromQuery = function (query, app, options) {
|
|
|
35315
35913
|
dwv.utils.decodeQuery(query, app.loadURLs, options);
|
|
35316
35914
|
// optional display state
|
|
35317
35915
|
if (typeof query.state !== 'undefined') {
|
|
35916
|
+
// queue after main data load
|
|
35318
35917
|
var onLoadEnd = function (/*event*/) {
|
|
35319
|
-
app.
|
|
35918
|
+
app.removeEventListener('loadend', onLoadEnd);
|
|
35919
|
+
app.loadURLs([query.state]);
|
|
35320
35920
|
};
|
|
35321
35921
|
app.addEventListener('loadend', onLoadEnd);
|
|
35322
35922
|
}
|