Skip to content

Commit 59cf498

Browse files
committed
Log message when retrieving bulkdata
1 parent 2ec4c6b commit 59cf498

File tree

1 file changed

+66
-1
lines changed

1 file changed

+66
-1
lines changed

src/annotation.js

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,13 @@ async function _fetchGraphicData ({
214214
)
215215
} else {
216216
if ('PointCoordinatesData' in bulkdataItem) {
217+
console.info(`fetch point coordinate data of annotation group "${uid}"`)
217218
return await _fetchBulkdata({
218219
client,
219220
reference: bulkdataItem.PointCoordinatesData
220221
})
221222
} else if ('DoublePointCoordinatesData' in bulkdataItem) {
223+
console.info(`fetch point coordinate data of annotation group "${uid}"`)
222224
return await _fetchBulkdata({
223225
client,
224226
reference: bulkdataItem.DoublePointCoordinatesData
@@ -266,6 +268,7 @@ async function _fetchGraphicIndex ({
266268
}
267269
} else {
268270
if ('LongPrimitivePointIndexList' in bulkdataItem) {
271+
console.info(`fetch point index list of annotation group "${uid}"`)
269272
return await _fetchBulkdata({
270273
client,
271274
reference: bulkdataItem.LongPrimitivePointIndexList
@@ -324,6 +327,11 @@ async function _fetchMeasurementValues ({
324327
measurementBulkdataItem.MeasurementValuesSequence[0]
325328
)
326329
if ('FloatingPointValues' in valuesBulkdataItem) {
330+
const nameItem = measurementMetadataItem.ConceptNameCodeSequence[0]
331+
const name = nameItem.CodeMeaning
332+
console.info(
333+
`fetch measurement values for measurement #${index} "${name}"`
334+
)
327335
return await _fetchBulkdata({
328336
client,
329337
reference: valuesBulkdataItem.FloatingPointValues
@@ -380,6 +388,11 @@ async function _fetchMeasurementIndices ({
380388
.MeasurementValuesSequence[0]
381389
)
382390
if ('AnnotationIndexList' in valuesBulkdataItem) {
391+
const nameItem = measurementMetadataItem.ConceptNameCodeSequence[0]
392+
const name = nameItem.CodeMeaning
393+
console.info(
394+
`fetch measurement indices for measurement #${index} "${name}"`
395+
)
383396
return await _fetchBulkdata({
384397
client,
385398
reference: valuesBulkdataItem.AnnotationIndexList
@@ -392,7 +405,7 @@ async function _fetchMeasurementIndices ({
392405
}
393406

394407
/**
395-
* Fetch measurements of an annotation group.
408+
* Fetch all measurements of an annotation group.
396409
*
397410
* @param {object} options
398411
* @param {object} options.metadataItem - Metadata of Annotation Group Sequence item
@@ -435,6 +448,57 @@ async function _fetchMeasurements ({
435448
return measurements
436449
}
437450

451+
/**
452+
* Fetch an individual measurement of an annotation group.
453+
*
454+
* @param {object} options
455+
* @param {object} options.metadataItem - Metadata of Annotation Group Sequence item
456+
* @param {object} options.bulkdataItem - Bulkdata of Annotation Group Sequence item
457+
* @param {object} options.index - Index of the Measurements Sequence item
458+
* @param {object} options.client - DICOMweb client
459+
*
460+
* @returns {Promise<Array<object>>} Name, values, and indices of measurements
461+
*
462+
* @private
463+
*/
464+
async function _fetchMeasurement ({
465+
metadataItem,
466+
bulkdataItem,
467+
index,
468+
client
469+
}) {
470+
if (metadataItem.MeasurementsSequence == null) {
471+
throw new Error(
472+
'Measurements Sequence element is not contained in metadata.'
473+
)
474+
}
475+
if (metadataItem.MeasurementsSequence.length === 0) {
476+
throw new Error(
477+
'Measurements Sequence element in empty.'
478+
)
479+
}
480+
const item = metadataItem.MeasurementsSequence[index]
481+
if (item == null) {
482+
throw new Error(
483+
`Measurements Sequence does not contain an item #${index}.`
484+
)
485+
}
486+
const name = getContentItemNameCodedConcept(item)
487+
const values = await _fetchMeasurementValues({
488+
metadataItem,
489+
bulkdataItem,
490+
index,
491+
client
492+
})
493+
const indices = await _fetchMeasurementIndices({
494+
metadataItem,
495+
bulkdataItem,
496+
index,
497+
client
498+
})
499+
return { name, values, indices }
500+
}
501+
438502
/**
439503
* Get dimensionality of coordinates.
440504
*
@@ -725,6 +789,7 @@ export {
725789
_fetchGraphicData,
726790
_fetchGraphicIndex,
727791
_fetchMeasurements,
792+
_fetchMeasurement,
728793
_getCentroid,
729794
_getCommonZCoordinate,
730795
_getCoordinateDimensionality

0 commit comments

Comments
 (0)