-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(windowing): more robust loading of multi-component DICOMs #578
Conversation
✅ Deploy Preview for volview-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
@@ -30,7 +59,8 @@ function useAutoRangeValues(imageID: MaybeRef<Maybe<string>>) { | |||
|
|||
// Pre-compute the auto-range values | |||
const scalarData = imageData.value.getPointData().getScalars(); | |||
const [min, max] = scalarData.getRange(); | |||
// Assumes all data is one component | |||
const { min, max } = fastComputeRange(scalarData.getData()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was the original getRange() call causing any particular issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was working perfectly for one component, which caused NANs in downstream windowing calculations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it makes sense to treat multi-component data as single-component data. How about instead just picking out the first component using scalarData.getRange(0)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scalarData.getRange(0)
is the default and what was happaning before with just scalarData.getRange()
. That is a problem when we compute the autoRangeValues
, which computes the histogram from all components from scalarData.getData()
. Histogram including all compnents does not make sense to me eather.
We are rendering all components. Looks like a single Window and Level are getting applied to all components:
https://github.com/Kitware/vtk-js/blob/master/Sources/Rendering/OpenGL/ImageMapper/index.js#L638-L655
I see this PR as a cludge to keep the app trucking along while still sort of supporting RGB images.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, this is fine. We will have to revisit this at some point.
import useWindowingStore from '@/src/store/view-configs/windowing'; | ||
import { Maybe } from '@/src/types'; | ||
import type { TypedArray } from '@kitware/vtk.js/types'; | ||
import { watchImmediate } from '@vueuse/core'; | ||
import { MaybeRef, computed, unref, watch } from 'vue'; | ||
|
||
// Original source from https://www.npmjs.com/package/compute-range and vtkDataArray | ||
// Modified to assume one component array | ||
function fastComputeRange(arr: number[] | TypedArray) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is accessible via vtkDataArray.fastComputeRange
. You should be able to just use that + set numComponents to 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
6b7cb40
to
4bb28a5
Compare
LGTM! |
Attached DICOM was freezing app.
1-001.zip