How to change pixel size (Image Spacing) without changing of matrix size

Dear Users and Developers

I want to change pixel size (Image Spacing) without changing of matrix size (Image Dimensions).
I check some modules such as Resample Scalar Volume and Resize Image. I do not success to do it. At these modules, the matrix size and pixel size are changed simultaneously that I do not mean.

Anyway, I am able to do it very simply by changing the Image Spacing values in the module of Volume. This is OK.

At now, my questions are mentioned as:
1- How can I do this through another module (without Volume module)?
2- Is my method correct in doing so (using Volume module to change pixel size with changing matrix size using Volume module)?

Please guide me.
Best regards.

1 Like

You can change spacing value by calling SetSpacing method of the volume node.

Changing the pixel size would change the physical size of an object so, it is normally not needed. There are only a few exceptions when it is valid to change the pixel size, for example when the volume is loaded from a format where image spacing is not available and you need to change the default 1.0 value to the actual value.

Why are you considering changing the image spacing without resampling the image? What would you like to achieve?

1 Like

Thanks a lot for your guidance.
In summary, I want to determine the patient setup error in radiotherapy by automatically registering two EPID and DRR images.

I want to first make the DRR and EPID images identical in the aspect of pixel size (Image Spacing). At first, I must mentioned that these two images are different from these two aspects.

Image Dimensions: 512 512 1
Image Spacing: 2.1864mm 2.1864mm 1.0000mm

Image Dimensions: 1024 1024 1
Image Spacing: 0.4mm 0.4mm 1.0mm

The following figure is shown this issue.

As you mentioned, I can do it by calling SetSpacing method of the volume node. Thanks a lot.

At this moment, I can match the centers of these two images with Center Volume in Volume module. In practice, the centers of these two images are the place through which the central axis of the radiation field of LINAC passes.

Now, with the guidance you gave me in my topics entitled “ Crop regions outside the radiation field of the DRR image ”, I can crop out-of-field areas of the DRR image.

After completing these steps, I want to compare the two images matrices row by row. I assume these rows as the spatial one-dimensional signals. I think that I can do it with numpy arrays.

After doing it, I want to evaluate the similarity of these two signals (from DRR cropped and EPID) with a tool like xcor. This work must be done for finding similar signals (rows). I interpret that two similar signals correspond to the same anatomical regions.

If this is true, I can determine the amount of spatial shift of the two similar signals. This value of spatial shift can be a patient setup error in the Right - Left direction of the patient.

The same can be done for the columns of EPID and DRR and determine patient setup error in the Inferior - Superior direction of the patient.

I’ll be happy to receive your feedback on these steps.

‌Best regards.

You should be able to register these images fully automatically after an approximate initial alignment. All the automatic registration methods in Slicer are set up for 3D (multi-slice) images, so you need to change their parameters to constrain the transformation to 2D (or split the síngle-slice image to 3-5 identical slice.

You may also consider using SimpleITK for this registration, as the basic ITK registration framework could be sufficient for this and there are many 2D Image registration examples online for SimpleITK. If you get stuck you can ask help for this on the ITK forum.

Hi, not sure if this helps, but you can do 2D registration with SlicerANTs Extension. See the dimensionality property under Settings

1 Like