cornerstonejs / cornerstoneTools

[Deprecated] Use Cornerstone3D Instead https://cornerstonejs.org/
MIT License
579 stars 456 forks source link

combine cornerstoneTools.addStackStateManager with HTML Slider element #1170

Closed stebro01 closed 3 years ago

stebro01 commented 4 years ago

Prerequisites

Description

I need to control the image shown in the canvas DOM object bey cornerstone.loadimage / addSackStateManager with a slider element.

I could not figure out, how to control the displayed image.

dannyrb commented 4 years ago

Have you tried:

stebro01 commented 4 years ago

Dear Mr. Brown, thanks in advance for your help. I have tried loadImage / displayImage, but I could not figure out how to solve my problem:

I load the image on a DICOM server / prepare an URL stack by:

this.stack.imageIds = series.map(seriesImage =>${scheme}:${baseUrl}${seriesImage}`)

  // load images and set the stack
  cornerstone.enable(element)
  cornerstone.loadImage(this.stack.imageIds[INDEX - 1]).then((image) => {
    cornerstone.displayImage(element, image)
    // // STACK
    cornerstoneTools.addStackStateManager(element, ['stack'])
    cornerstoneTools.addToolState(element, 'stack', this.stack)
  })`

This works fine and I can PanScroll through the loaded Images. I even figured out how to display: stack.currentImageIdIndex

=> now my problem: I want to set the stack.currentImageIdIndex and directly show the stacked image I am afraid, I could find no description in the documentation.

best wishes Stefan Brodoehl / University of Jena / Neurology

dannyrb commented 4 years ago

Lib: https://github.com/cornerstonejs/cornerstoneTools/blob/master/src/lib.js#L139 ScrollToIndex: https://github.com/cornerstonejs/cornerstoneTools/blob/master/src/util/scrollToIndex.js#L17

Some of the advanced API options are tucked away in "lib". They're for tool authors, and aren't guaranteed to be as stable as the top level API options; however, they rarely change.

const element = document.querySelector("#my-cornerstone-element");
const scrollToIndex = cornerstoneTools.importInternal('util/scrollToIndex');

scrollToIndex(element, 2);
stebro01 commented 4 years ago

Dear Mr. Brown, works like a charm. Thank you very much. Awesome answering time!

best of luck to you sb

Gordon-007 commented 4 years ago

perfect!