Couldn't decode TypeError: Cannot read properties of undefined (reading 'samplesPerPixel')

Describe Your Question

I have built an API that is wrapping Google Cloud Health. I have this endpoint that returns a DICOM Instance (application/dicom; transfer-syntax=1.2.840.10008.1.2.4.91).

When using dicomImageLoader I’m getting this error: Couldn't decode TypeError: Cannot read properties of undefined (reading 'samplesPerPixel'). I found out that this exception is raised because imagePixelModule is undefined but I don’t understand why. I already used dicom-parser and it parsed the DICOM instances successfully.

// cornerstone3D/packages/dicomImageLoader/src/imageLoader/getInstanceModule.ts

function getImageFrame(imageId: string): ImageFrame {
  const { cornerstone } = external;
  const imagePixelModule: MetadataImagePixelModule = cornerstone.metaData.get(
    'imagePixelModule',
    imageId
  );

  return {
    samplesPerPixel: imagePixelModule.samplesPerPixel, // <!-- EXCEPTION TRIGGERS HERE
    // ...
  }
}

When parsed, the JSON have the fields related with Image Pixel:

	"x00280002": "1",
	"x00280004": "MONOCHROME2",
	"x00280006": "0",
	"x00280010": "614",
	"x00280011": "816",
	"x00280100": "8",
	"x00280101": "8",
	"x00280102": "7",
	"x00280103": "0",
	"x00281050": "127",
	"x00281051": "256",
	"x00282110": "00",
	"x00282112": "3",

I tried using the frames from this example: https://www.cornerstonejs.org/live-examples/stackmanipulationtools but it still fails with the same exception