Issues with rendering ImageCPRMapper using vtkImageCPRMapper

I saw the ImageCPRMapper example vtk.js
The example uses vtkHttpDataSetReader, and I converted the data through itk’s readImageDICOMFileSeries and convertItkToVtkImage, but it cannot be rendered.The problem is that reader.getOutputPort() is used here.

const actor = vtkImageSlice.newInstance();
const mapper = vtkImageCPRMapper.newInstance();
mapper.setBackgroundColor(0, 0, 0, 0);
actor.setMapper(mapper);

mapper.setInputConnection(reader.getOutputPort(), 0);
mapper.setInputData(centerline, 1);

I found a way to write it like this but it doesn’t work, please help me

const actor = vtkImageSlice.newInstance();
      const mapper = vtkImageCPRMapper.newInstance();
      mapper.setBackgroundColor(0, 0, 0, 0);
      actor.setMapper(mapper);
      reslice.setInputData(this.vtkImageData);
      mapper.setInputData(reslice.getOutputData());
      
      mapper.setInputData(centerline, 1);
1 Like

You might want to check the content of the read image data.
Maybe the problem does not come from the ImageCPRMapper.
One way to check is to pipe it with a vtkXMLImageDataWriter to see what it writes.

After trying multiple image sequences, I found that the same examination type is CT, the torso part, why some sequences can be rendered, while some sequences are rendered with offset positions, and cannot achieve the example effect? ​​I converted the data through itk without any processing, and MPR can render normally. I believe that there should be no problem with data conversion. What is the reason why some images are not rendered at all and the positions are changed? Do I need to set any parameters separately? Or is there something wrong with my dicom image? I can’t render CPR normally, and no errors are thrown. I want help
The CPR of these 150 images did not render anything, but the MPR rendered normally.



Another patient’s sequence can be rendered, but the position is offse


This one is not only offset, but only partially rendered, and the widget in the lower right corner is missing.

The position in the world of the CPR is abritrary. This is because you display on a place something that is not planar in the real world (i.e. a spline).
If I remember correctly, the CPR mapper was rendering the output plane at the origin (0,0,0).
You can apply a transform to the associated actor if you want it elsewhere. You might want to look at the example.

Hello, I’m here to ask again. I’ve set the coordinates of the source point through the data converted by itk.js.

imageData.setOrigin([0,0,0]);

After that, the image is loaded, but the image effect is not as good as the ImageCPRMapper example. 1. The aorta and spine are not displayed; 2. The image is reversed, the head should be on top, and the CPR thumbnail is not rendered according to the original orientation of the image.
I just copied the example code and did not modify the rendering logic. I just changed the vtkImage data source. What should I do? Can the .vti file in the example be rendered? Can the vti file be processed and used directly? Do I need to do anything with the data after itk converts the data?
I also tried to set actor.setUserMatrix, but it didn’t work very well. Please help me,Thanks again

  1. The aorta and spine are not displayed

maybe your centerline points coordinates are not correctly placed

  1. The image is reversed

you can flip the order of your centerline points or you can change the camera viewUp vector

the CPR thumbnail is not rendered according to the original orientation of the image

This can be controlled with the Reslice Cursor Widget widget state plane normal.

Hth,
Julien.

Are the two json files aorta_centerline.json and spine_centerline.json used for all images, or does each image need to calculate its own centerline coordinate points? How should I calculate the centerline coordinate points of the aorta and spine?

Those are proper to each image.

You need a tool that let’s you know what are the coordinates of a point under the mouse cursor.
You can typically do that with the VTK.js pickers or you can do it with third-party software. We used 3D Slicer to find the point coordinates in an image (warning, there might be some X,Y coordinate switch in Slicer)

Hello Julien.
I may not have described the clearing correctly, what I want to ask is whether these two json files are applicable to all patients’ images?

Those files work only with the volume from the example.
If you want to display a different volume, you need to create your own JSon file. To do so, you need to follow the technique I mentionned in my previous post.

I also encountered the same problem