- Create a Grid: Use meshgrid to create a grid of x and y coordinates corresponding to your dose_data matrix.
- Generate Binary Masks: Create binary masks where the pixels within the 11 Gy isodose line and within the tumour circle are 1, and all other pixels are 0.
- Calculate the Intersection: Find the intersection of the binary masks to see which pixels are within both the isodose line and the circle.
- Calculate the DSC: The DSC is calculated as 2 * (|A ∩ B|) / (|A| + |B|), where A and B are the binary masks of the two regions, and |A ∩ B| is the count of pixels in the intersection.
- Calculate the Percentage Area Covered: The percentage of the circle covered by the 11 Gy dose contour is the number of pixels in the intersection divided by the number of pixels in the circle mask.
How to compare contours?
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Gail Distefano
el 30 de Dic. de 2023
Comentada: Gail Distefano
el 2 de En. de 2024
In the attached file is a matrix of dose_data for a piece of radiographic film I have irradiated, and respective x and y coordinates for the film.
I can plot specific dose lines (11Gy,12.1Gy), and then plot a circle (representing a tumour) centre 0,0 and radius 5.
contour(col_scale,row_scale,dose_data,[11,12.1]);
hold on;
ROI1= drawcircle('Center',[0,0],'Radius',5,'StripeColor','red');
I would like to be able to compare for example the 11Gy isodose line and the circle (tumour) to see how well it was irradiated. For example getting a DSC or % area of circle covered by the 11Gy dose contour. I have tried different Matlab functions but my data is not in the correct data type/format. Any advice on how to do this would be much appreciated.
Thanks very much in advance.
0 comentarios
Respuesta aceptada
Hassaan
el 30 de Dic. de 2023
Editada: Hassaan
el 30 de Dic. de 2023
To what I understand. There maybe other ways to achieve desired results:
To compare the 11 Gy isodose line with the tumour circle (ROI) and compute metrics like the Dice Similarity Coefficient (DSC) or the percentage of the circle covered by the 11 Gy dose contour, you'll need to perform several steps. First, you'll need to create binary masks of the isodose line and the circle, then compare these masks.
% Assume col_scale and row_scale are vectors that scale the matrix indices to your physical coordinates.
[x, y] = meshgrid(col_scale, row_scale);
% Binary mask for the 11 Gy isodose line
isodose_11Gy_mask = dose_data >= 11;
% Binary mask for the circle (tumour)
% This is a logical operation to create a binary mask of the circle.
circle_mask = ((x.^2 + y.^2) <= 5^2);
% Find the intersection of the isodose line and the circle
intersection_mask = isodose_11Gy_mask & circle_mask;
% Calculate Dice Similarity Coefficient (DSC)
DSC = 2 * nnz(intersection_mask) / (nnz(isodose_11Gy_mask) + nnz(circle_mask));
% Calculate the percentage area of circle covered by the 11 Gy dose contour
percent_coverage = nnz(intersection_mask) / nnz(circle_mask) * 100;
% Display the results
disp(['DSC: ', num2str(DSC)]);
disp(['Percentage of Circle Covered by 11 Gy Contour: ', num2str(percent_coverage), '%']);
This code assumes that col_scale and row_scale are defined such that they scale the matrix indices of dose_data to the corresponding physical coordinates of your film.
Please replace the placeholder operations with the appropriate variables and operations from your actual data and setup. Make sure that the x and y coordinates in the meshgrid correctly represent the physical positions on your film. If your dose data is very large or if the contour function doesn't return a binary mask directly, you might need additional processing to convert the contour lines into a binary mask.
Note
You may need to adjust things as per your requirements.
------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
2 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!