question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to get index of image in StackScrollTool to get dicom tags

See original GitHub issue

When I scroll the viewer dicom images are chnage but i did not get index of that dicom image so that depending upon that index I can pass it another function so that I can able to get dicom tags for the respective dicom image scroll index.

const scheme = 'wadouri'
const baseUrl = 'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/' 
const series = [
	'bbmri-53323851.dcm',
    'bbmri-53323707.dcm',
	'bbmri-53323563.dcm'
]

const imageIds = series.map(seriesImage => `${scheme}:${baseUrl}${seriesImage}`);
var element = document.querySelector('.cornerstone-element');//document.getElementById("cornerstone-element");
// Add our tool, and set it's mode
cornerstoneWebImageLoader.external.cornerstone = cornerstone;
cornerstone.registerImageLoader('http', cornerstoneWebImageLoader.loadImage)
cornerstone.registerImageLoader('https', cornerstoneWebImageLoader.loadImage)
cornerstoneWADOImageLoader.external.cornerstone = cornerstone;
cornerstoneTools.init();

var item1 = cornerstone.enable(element);
//define the stack
const StackScrollTool = cornerstoneTools.StackScrollTool

//define the stack
const stack = {
  currentImageIdIndex: 0,
  imageIds
}

// load images and set the stack
cornerstone.loadImage(imageIds[0]).then((image) => {
  cornerstone.displayImage(element, image)
  cornerstoneTools.addStackStateManager(element, ['stack'])
  cornerstoneTools.addToolState(element, 'stack', stack)
})
	cornerstoneTools.addTool(StackScrollTool)
	cornerstoneTools.setToolActive('StackScroll', {mouseButtonMask: 1 })

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
Raistlfirencommented, Jan 31, 2020

I just wanted to add to this issue - you need to place the event on the element and not on cornerstone. I spent hours putting the event on cornerstone, and wondering why it didn’t work. The following code worked after enabling cornerstone on the element.

element.addEventListener('cornerstonenewimage', function (e) {
     window.downloadURL = e.detail.image.imageId.replace('wadouri:', '');
});

Thanks!

2reactions
dannyrbcommented, Jan 31, 2020

@Raistlfiren, this is a good call out. This can be especially tricky if you’re dynamically enabling/destroying enabledElements. You can listen, on cornerstone for the element enabled event, then use the enabled element in that event to attach the cornerstonenewimage listener.

It might be a worthwhile enhancement to allow listening for cornerstonenewimage on cornerstone, but also include the enabled element that emitted the event. This would likely save consumers some effort.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating an index of the DICOM image tags - Yohz Software
Basically, you have the power of a relational database engine to search your DICOM images based on their tag values. Let's take a...
Read more >
Get Dicom image position into a sequence - Stack Overflow
Position of each slice (dicom image) into the Sequence. For the first question i know i can use tag 0020,1002 (however it is...
Read more >
API Docs - Cornerstone Tools
The imageId of the image displayed on the cornerstone enabled element. ... The index of the frame to get the slice thickness for....
Read more >
Image Index Attribute - DICOM Standard Browser - Innolitics
An index identifying the position of this image within a PET Series. ... Therefore, all normals are co-planar and make a single angle...
Read more >
DICOM Tags
Tag VR Name (0002,0000) UL File Meta Information Group Length (0002,0001) OB File Meta Information Version (0002,0002) UI Media Storage SOP Class UID
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found