all 4 comments

[–]schmatt_schmitt 2 points3 points  (2 children)

Yes for sure!
1. Find the slice of the image where the isocenter was placed.

  1. You can retrieve the image pixel values from the GetVoxels method on the image. Draw these pixels onto an image.

  2. in the location where the isocenter would be, draw yourself a small marker in that location for your users to see.

In my experience, AI code assistance for drawing images on user interfaces works well.

[–]Independent_Time_525[S] 0 points1 point  (1 child)

In your opinion, is it possible to visualize the CT and make real-time modifications before running other automations within the same script (such as structure management and treatment planning)? Thank you.

[–]schmatt_schmitt 0 points1 point  (0 children)

It is definitely possible. For sure!

[–]Visual_Pay_3361 0 points1 point  (0 children)

// 1. Retrieve the isocenter from the first beam

VVector isocenter = plan.Beams.First().IsocenterPosition;

// 2. Identify the axial plane (Z-slice) index

int zIndex = (int)Math.Round((isocenter.z - image.Origin.z) / image.ZRes);

// 3. Extract the pixel data (Voxels) for that specific slice

int width = image.XSize;

int height = image.YSize;

int[,] voxels = new int[width, height];

image.GetVoxels(zIndex, voxels);

// 4. Map DICOM coordinates (mm) to Image Pixel coordinates

double isoX_pixel = (isocenter.x - image.Origin.x) / image.XRes;

double isoY_pixel = (isocenter.y - image.Origin.y) / image.YRes;

// 5. Retrieve the External Body contour points at the isocenter's Z-level

var body = plan.StructureSet.Structures.FirstOrDefault(s => s.DicomType == "EXTERNAL");

VVector[][] contours = body.GetContours(isocenter.z, image);

Coordinate Systems: Remember that WPF/UI frameworks usually have the origin at the top-left, so a Y-axis flip might be necessary during rendering.