|
114 | 114 | idm = idm(not_rep_pts); %remove repeats in the sample positions |
115 | 115 | md = md(not_rep_pts); %remove repeats in measured data |
116 | 116 |
|
117 | | -% Step 3: Resample for gamma analysis |
| 117 | +% Step 3: Check for non-uniform dose grid axes |
| 118 | +% Some TPS (e.g. ViewRay) exports DICOM-RT dose files that have |
| 119 | +% rounding errors in the (X,Y,Z) positions, resulting in a non-uniform dose |
| 120 | +% grid. The following code checks for this condition, determines how large |
| 121 | +% it is and resamples to a uniform spacing. |
| 122 | + |
| 123 | +% X |
| 124 | +x_max_space = max(cx(2:end)-cx(1:(end-1))); |
| 125 | +x_min_space = min(cx(2:end)-cx(1:(end-1))); |
| 126 | +if (x_max_space-x_min_space > 0.001) % is it larger than 1/100 mm? |
| 127 | + h = msgbox(sprintf('%WARNING: The calculated x-axis values are not uniformly spaced. The maximum discrepancy is %f cm.',x_max_space-x_min_space)); |
| 128 | + cx = linspace(cx(1),cx(end),length(cx)); |
| 129 | +elseif (x_max_space-x_min_space > 0.0) % is it larger than 0 mm? |
| 130 | + cx = linspace(cx(1),cx(end),length(cx)); |
| 131 | +end |
| 132 | + |
| 133 | +% Y |
| 134 | +y_max_space = max(cy(2:end)-cy(1:(end-1))); |
| 135 | +y_min_space = min(cy(2:end)-cy(1:(end-1))); |
| 136 | +if (y_max_space-y_min_space > 0.001) % is it larger than 1/100 mm? |
| 137 | + h = msgbox(sprintf('%WARNING: The calculated y-axis values are not uniformly spaced. The maximum discrepancy is %f cm.',y_max_space-y_min_space)); |
| 138 | + cy = linspace(cy(1),cy(end),length(cy)); |
| 139 | +elseif (y_max_space-y_min_space > 0.0) % is it larger than 0 mm? |
| 140 | + cy = linspace(cy(1),cy(end),length(cy)); |
| 141 | +end |
| 142 | + |
| 143 | +% Z |
| 144 | +z_max_space = max(cz(2:end)-cz(1:(end-1))); |
| 145 | +z_min_space = min(cz(2:end)-cz(1:(end-1))); |
| 146 | +if (z_max_space-z_min_space > 0.001) % is it larger than 1/100 mm? |
| 147 | + h = msgbox(sprintf('%WARNING: The calculated z-axis values are not uniformly spaced. The maximum discrepancy is %f cm.',z_max_space-z_min_space)); |
| 148 | + cz = linspace(cz(1),cz(end),length(cz)); |
| 149 | +elseif (z_max_space-z_min_space > 0.0) % is it larger than 0 mm? |
| 150 | + cz = linspace(cz(1),cz(end),length(cz)); |
| 151 | +end |
| 152 | + |
| 153 | + |
| 154 | +% Step 4: Resample for gamma analysis |
118 | 155 |
|
119 | 156 | % Resample indep with the same range but a finer spacing |
120 | 157 | SAMP_PER_CM = 200; % samples per cm |
|
0 commit comments