Skip to content
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

OHIF error when opening studies #2138

Closed
marcopin opened this issue Oct 30, 2020 · 28 comments
Closed

OHIF error when opening studies #2138

marcopin opened this issue Oct 30, 2020 · 28 comments
Labels
Bug Verified Bug reported, reproducible, and verified.

Comments

@marcopin
Copy link

I'm using lastest ohif viewer with docker (ohif/viewer:lastest), and I have configured to read my local images (dcm4chee). But when I try to open more of my studies I get this message:

Something went wrong in ViewerMain
ViewerMain: windowWidth.toFixed is not a function

Captura de Pantalla 2020-10-29 a la(s) 8 49 11 p  m

And no images is shown.

@marcopin
Copy link
Author

Additional: Stack Trace:

in ViewportOverlay
in div
in div
in CornerstoneViewport
in ConnectFunction
in OHIFCornerstoneViewport
in Suspense
in OHIFCornerstoneViewport
in ExtendedOHIFCornerstoneViewport
in div
in ViewportPane
in div
in ViewportGrid
in ConnectFunction
in div
in ViewerMain
in ConnectFunction
in ErrorBoundary
in OHIFErrorBoundary
in ErrorBoundaryDialog
in div
in div
in Viewer
in WrappedComponent
in ConnectFunction
in ViewerRetrieveStudyData
in ConnectFunction
in ViewerRouting
in AsyncComponent
in ErrorBoundary
in OHIFErrorBoundary
in Transition
in CSSTransition
in Route
in OHIFStandaloneViewer
in ConnectFunction
in withRouter(Connect(OHIFStandaloneViewer))
in Unknown
in Unknown
in ModalProvider
in DialogProvider
in SnackbarProvider
in Router
in BrowserRouter
in I18nextProvider
in AppProvider
in Provider
in ErrorBoundary
in OHIFErrorBoundary
in App

@marcopin
Copy link
Author

marcopin commented Nov 2, 2020

@brucedesa
Copy link

Same here

@nisalupendra
Copy link

same here

@barthelemyleveque
Copy link

Same issue here

@SivanRAVSoft
Copy link

Facing same issue. Any solution for this ?
Error:
Something went wrong in ViewerMain

ViewerMain: windowWidth.toFixed is not a function

in ViewportOverlay (created by CornerstoneViewport)
in div (created by CornerstoneViewport)
in div (created by CornerstoneViewport)
in CornerstoneViewport (created by ConnectFunction)
in ConnectFunction (created by OHIFCornerstoneViewport)
in OHIFCornerstoneViewport (created by OHIFCornerstoneViewport)
in Suspense (created by OHIFCornerstoneViewport)
in OHIFCornerstoneViewport (created by ExtendedOHIFCornerstoneViewport)
in ExtendedOHIFCornerstoneViewport (created by ViewportGrid)
in div (created by ViewportPane)
in ViewportPane (created by ViewportGrid)
in div (created by ViewportGrid)
in ViewportGrid (created by ConnectFunction)
in ConnectFunction (created by ViewerMain)
in div (created by ViewerMain)
in ViewerMain (created by ConnectFunction)
in ConnectFunction (created by Viewer)
in ErrorBoundary (created by OHIFErrorBoundary)
in OHIFErrorBoundary (created by ErrorBoundaryDialog)
in ErrorBoundaryDialog (created by Viewer)
in div (created by Viewer)
in div (created by Viewer)
in Viewer (created by WrappedComponent)
in WrappedComponent (created by ConnectFunction)
in ConnectFunction (created by ViewerRetrieveStudyData)
in ViewerRetrieveStudyData (created by ConnectFunction)
in ConnectFunction (created by ViewerRouting)
in ViewerRouting (created by AsyncComponent)
in AsyncComponent (created by Context.Consumer)
in ErrorBoundary (created by OHIFErrorBoundary)
in OHIFErrorBoundary (created by Context.Consumer)
in Transition (created by CSSTransition)
in CSSTransition (created by Context.Consumer)
in Route (created by OHIFStandaloneViewer)
in OHIFStandaloneViewer (created by ConnectFunction)
in ConnectFunction (created by Context.Consumer)
in withRouter(Connect(OHIFStandaloneViewer)) (created by Component)
in Unknown (created by Component)
in Component (created by App)
in ModalProvider (created by App)
in DialogProvider (created by App)
in SnackbarProvider (created by App)
in Router (created by BrowserRouter)
in BrowserRouter (created by App)
in I18nextProvider (created by App)
in AppProvider (created by App)
in Provider (created by App)
in ErrorBoundary (created by OHIFErrorBoundary)
in OHIFErrorBoundary (created by App)
in App (created by HotExportedApp)
in AppContainer (created by HotExportedApp)
in HotExportedApp

@swederik swederik added Bug Verified Bug reported, reproducible, and verified. and removed Awaiting Reproduction labels Dec 1, 2020
@davidthemaster30
Copy link

I have the same bug with dcm4chee-arc-psql:5.22.6-secure-ui.
5.22.5 works without issues.
I suggest using that version as a workaround for now.

@proteeti13
Copy link

I have the same bug with dcm4chee-arc-psql:5.22.6-secure-ui.
5.22.5 works without issues.
I suggest using that version as a workaround for now.

can you share your yml file?

@davidthemaster30
Copy link

davidthemaster30 commented Jan 4, 2021

sorry I can't share the full yml file, but just add the version tags to your dcm4chee service in your yml like this:

version: "3.7"
services:
    archive:
      image: dcm4che/dcm4chee-arc-psql:5.22.5-secure-ui
	/* ... */
    pgdb:
      image: dcm4che/postgres-dcm4chee:12.2-22
	/* ... */
    keycloak:
      image: dcm4che/keycloak:11.0.2
	/* ... */
    ldap:
      image: dcm4che/slapd-dcm4chee:2.4.50-22.5

@ptt-bs23
Copy link

ptt-bs23 commented Jan 5, 2021

@davidthemaster30 thanks! I tried but it didn't resolve my error!

@bianyueyan
Copy link

The error is not from OHIF Viewer, but the dependent library "react-cornerstone-viewport". You can change
var wwwc = "W: ".concat(windowWidth.toFixed(0), " L: ").concat(windowCenter.toFixed(0));
into
var wwwc = "W: ".concat(Number(windowWidth).toFixed(0), " L: ").concat(Number(windowCenter).toFixed(0));

in the ./node_modules/react-cornerstone-viewport/dist/index.umd.js.

@marcopin
Copy link
Author

marcopin commented Feb 3, 2021

The error is not from OHIF Viewer, but the dependent library "react-cornerstone-viewport". You can change
var wwwc = "W: ".concat(windowWidth.toFixed(0), " L: ").concat(windowCenter.toFixed(0));
into
var wwwc = "W: ".concat(Number(windowWidth).toFixed(0), " L: ").concat(Number(windowCenter).toFixed(0));

in the ./node_modules/react-cornerstone-viewport/dist/index.umd.js.

This solution seems to work. Thanx @bianyueyan

@eanzuresb
Copy link

Hi @bianyueyan I'm using latest ohif viewer from docker in debian 10, can you help me?, i have been searching index.umd.js, but I can not find it :(

Thanks

@davidthemaster30
Copy link

you won't find index.umd.js in 'ohif/viewer:latest' on docker, because it's already compiled. You need change it before it's compiled, so you'll need to make you own Dockerfile. You can base your own on the one that's used for the official build https://github.com/OHIF/Viewers/blob/master/Dockerfile

FYI,

        var wwwc = "W: ".concat(windowWidth.toFixed(0), " L: ").concat(windowCenter.toFixed(0));

is on line 7066 in "node_modules/react-cornerstone-viewport/dist/index.umd.js". the node_modules folder is only created when "yarn install" is executed.

@davidthemaster30
Copy link

Just tested the fix, and it does get rid on the error. But images appear either solid white or solid black.

@ken-proradis
Copy link

ken-proradis commented Feb 23, 2021

I checked this issue in the releases @OHIF:[email protected]
I was able to connect to my dcm4chee:5.22.6 instance by downgrading to @OHIF:[email protected].
Haven't tested for releases 3.x.

The error is not from OHIF Viewer, but the dependent library "react-cornerstone-viewport". You can change
var wwwc = "W: ".concat(windowWidth.toFixed(0), " L: ").concat(windowCenter.toFixed(0));
into
var wwwc = "W: ".concat(Number(windowWidth).toFixed(0), " L: ").concat(Number(windowCenter).toFixed(0));

in the ./node_modules/react-cornerstone-viewport/dist/index.umd.js.

By performing these changes in the latest version series of other errors appeared for me:

  1. Window level adjustment gets extremely sensitive, eventually getting to NaN values;
  2. Couldn't use 2D MPR. It throws javascript errors;
  3. Many studies won't load, rendering errors;

I could open different issues for each case. But I could not use ohif viewer's latest versions connected to dcm4chee 5.

@davidthemaster30
Copy link

thanks @ken-proradis ohif/viewer:v2.11.8.7749 (the latest v2 version) works!. I also tried the v3 (ohif/viewer:v3.11.11.11515, the latest v3) and it has the same error as v4.

@gccgomes
Copy link

gccgomes commented Feb 24, 2021

This errors appear when the metadata is formed. On old dcm4chee arc WindowCenter and WindowWidth appear as number, float or integer in the metadata as is expected .
I don't know why at this time why this happen, But I tested here and changed on metadataprovider

    const windowCenter = Array.isArray(WindowCenter)
      ? WindowCenter
      : [WindowCenter];
    const windowWidth = Array.isArray(WindowWidth)
      ? WindowWidth
      : [WindowWidth];

to
const windowCenter = Array.isArray(WindowCenter)
? Number(WindowCenter)
: Number([WindowCenter]);
const windowWidth = Array.isArray(WindowWidth)
? Number(WindowWidth)
: Number([WindowWidth]);

And all worked as the past with CR and DR images.

This workaround will not working with CT modalities.

@bianyueyan
Copy link

I changed

      rescaleIntercept: instance.RescaleIntercept,
      rescaleSlope: instance.RescaleSlope,

to
rescaleIntercept: Number(instance.RescaleIntercept),
rescaleSlope: Number(instance.RescaleSlope),

in the "MetadataProvider.js"

it is working for CT modalities.

@gccgomes
Copy link

gccgomes commented Mar 8, 2021

@bianyueyan thank you. I can go further based on your solution.

I modified Metadata.js and add this lines, and removed all modifications on MetadataProvider.

getData() {
this.metadataSanitizer(this._data)
return this._data;
}

metadataSanitizer( data ){

if((typeof data.metadata )!= 'undefined' ){
  data.metadata.WindowCenter = parseInt(data.metadata.WindowCenter,10)
  data.metadata.WindowWidth = parseInt(data.metadata.WindowWidth,10)
  data.metadata.RescaleIntercept = parseFloat(data.metadata.RescaleIntercept,10)
  data.metadata.RescaleSlope = parseInt(data.metadata.RescaleSlope,10)
  data.metadata.DataCollectionDiameter =parseFloat(data.metadata.DataCollectionDiameter,10)
  data.metadata.Exposure =parseInt(data.metadata.Exposure,10)
  data.metadata.ExposureTime =parseInt(data.metadata.ExposureTime,10)
  data.metadata.GantryDetectorTilt =parseFloat(data.metadata.GantryDetectorTilt,10)
  data.metadata.GeneratorPower =parseInt(data.metadata.GeneratorPower,10)
  data.metadata.InstanceNumber =parseInt(data.metadata.InstanceNumber,10)
  data.metadata.KVP =parseInt(data.metadata.KVP,10)
  data.metadata.ReconstructionDiameter=parseFloat(data.metadata.ReconstructionDiameter,10)
  data.metadata.SeriesNumber =parseInt(data.metadata.SeriesNumber,10)
  data.metadata.SliceThickness =parseFloat(data.metadata.SliceThickness,10)
  data.metadata.TableHeight  =parseFloat(data.metadata.TableHeight,10)
  data.metadata.XRayTubeCurrent =parseInt(data.metadata.XRayTubeCurrent,10)
  data.metadata.SliceLocation=parseInt(data.metadata.SliceLocation,10)
  if(data.metadata.hasOwnProperty("PixelSpacing")){
    data.metadata.PixelSpacing[0]=parseFloat(data.metadata.PixelSpacing[0],10)
    data.metadata.PixelSpacing[1]=parseFloat(data.metadata.PixelSpacing[1],10)
  }
  if(data.metadata.hasOwnProperty("ImagePositionPatient")){
    data.metadata.ImagePositionPatient[0]=parseFloat(data.metadata.ImagePositionPatient[0],10)
    data.metadata.ImagePositionPatient[1]=parseFloat(data.metadata.ImagePositionPatient[1],10)
    data.metadata.ImagePositionPatient[2]=parseFloat(data.metadata.ImagePositionPatient[2],10)
  }
  if(data.metadata.hasOwnProperty("ImageOrientationPatient")){
    data.metadata.ImageOrientationPatient[0]=parseFloat(data.metadata.ImageOrientationPatient[0],10)
    data.metadata.ImageOrientationPatient[1]=parseFloat(data.metadata.ImageOrientationPatient[1],10)
    data.metadata.ImageOrientationPatient[2]=parseFloat(data.metadata.ImageOrientationPatient[2],10)
    data.metadata.ImageOrientationPatient[3]=parseFloat(data.metadata.ImageOrientationPatient[3],10)
    data.metadata.ImageOrientationPatient[4]=parseFloat(data.metadata.ImageOrientationPatient[4],10)
    data.metadata.ImageOrientationPatient[5]=parseFloat(data.metadata.ImageOrientationPatient[5],10)
  }
  if(data.metadata.hasOwnProperty("FocalSpots")){
    data.metadata.FocalSpots[0]=parseFloat(data.metadata.FocalSpots[0],10)
    data.metadata.FocalSpots[1]=parseFloat(data.metadata.FocalSpots[1],10)
  }
}

}

@gccgomes
Copy link

gccgomes commented Mar 8, 2021

I wish update directly on github, but I cannot pull

@igoroctaviano
Copy link
Contributor

@swederik issue duplicated here: windowWidth.toFixed is not a function in viewerMain [failed to load image] #2297
can we close one of them?

@pschader
Copy link

pschader commented Apr 1, 2021

I experienced the same error after updating our dcm4chee-arc-psql from 5.22.4 to 5.23.2. After some investigation it seems to me that the DICOM JSON representation of the metadata returned by dcm4chee changed. In 5.22.4 DICOM tags where the VR is DS (Decimal String) are returned as Numbers where in 5.23.3 they are returned as String. Looking into the specification of the DICOM JSON Model this change seems to be valid. Unfortunately the viewer can not handle the string representation of DS.

I am pretty new to this project so I am not sure if my suggestions are of any value, but for me it seems there are a few different solutions:

  1. To my knowledge the viewer works on metadata "naturalized" by dcmjs so extending the according method to parse DS VRs to Number (e.g. here - see the diff in the workaround)
  2. Like @gccgomes suggested handling these by sanitizing the "naturalized" values in Metadata.js.
  3. Keep the string representation in the metadata and parse the string to numbers when invoking functions which can not handle DS as String.

As a workaround I have implemented solution 1 which seems to work:

--- node_modules/dcmjs/build/dcmjs.es.js.old	2021-04-01 16:13:39.755351407 +0200
+++ node_modules/dcmjs/build/dcmjs.es.js	2021-04-01 16:15:33.119409498 +0200
@@ -2778,6 +2778,8 @@
               naturalValues.push(DicomMetaDictionary.naturalizeDataset(data.Value[index]));
             });
             naturalDataset[naturalName] = naturalValues;
+          } else if (data.vr === "DS") {
+            naturalDataset[naturalName] = data.Value.map(x => { return Number(x) });
           } else {
             naturalDataset[naturalName] = data.Value;
           }

@jsampat76
Copy link

Thanks a lot @pschader,

You saved me from the frustration.
Your solution is working for me.

Thanks again

@igoroctaviano
Copy link
Contributor

Fixed in the latest version!

@hawodi
Copy link

hawodi commented May 30, 2021

you won't find index.umd.js in 'ohif/viewer:latest' on docker, because it's already compiled. You need change it before it's compiled, so you'll need to make you own Dockerfile. You can base your own on the one that's used for the official build https://github.com/OHIF/Viewers/blob/master/Dockerfile

FYI,

        var wwwc = "W: ".concat(windowWidth.toFixed(0), " L: ").concat(windowCenter.toFixed(0));

is on line 7066 in "node_modules/react-cornerstone-viewport/dist/index.umd.js". the node_modules folder is only created when "yarn install" is executed.

Hello,
I'm a newbie to ohif viewer and I still can't find where to modify the files before the app is created in the Dockerfile. Any direction please?

@Pela2silveira
Copy link

Face similar problem. Solved in last version.

@sedghi
Copy link
Member

sedghi commented Jul 9, 2024

We recently added several recipes for implementing authentication with Keycloak in OHIF. You can find them here:

https://docs.ohif.org/deployment/user-account-control

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Verified Bug reported, reproducible, and verified.
Projects
None yet
Development

No branches or pull requests