Open Golpette opened 4 years ago
Hi @Golpette , thanks for the report. I must admit that I only tested this code with HFS images and I agree that we should make sure that it also works with other anatomical orientations. I think I saw in some of the other gate tools that @tbaudier managed to ensure that they work with other orientations. The roi utils code is more messy than the other tools, unfortunately. We'll have look at your proposed fix. I'm currently very busy with other things, so I cannot promise that this is fixed very soon, but hopefully within a few weeks this should at least partly be addressed.
Great, I'll also update the thread if I manage to do anything extra. I think using GetDirection() as above is fine if the matrix is always diagonal with values of +/-1 (which it should be for any standard image for radiotherapy). I initially wanted to just take the AnatomicalOrientation tag from the mhd file ("RAI", "LPI" etc) and generate the directions list from that, but as far as I can see ITK totally ignores that information.
Hi,
I tried to use this tool in a radiotherapy simulation in which the patient was in head first prone position (HFP). The mhd image I am using has the header:
Seems the issue is that the get_mask method is expecting the Origin to represent the centre of the voxel with the minimum coordinates, which is not the case for this HFP image.
I'm not comfortable enough with ITK / mhd / dicom to suggest a robust fix to this. But my hack solution for now is to determine a "direction" for each axis using GetDirection() (corresponding to the mhd TransformMatrix). I'm then using these +/-1 values to determine if the Origin field is representing a max or min position of the image. So I have:
(1) Replaced lines 517-518 of roi_utils.py to find the centre of the minimal voxel and the direction of the axes:
(2) Give this orig_min_corner to check "contained" in line 527:
for o,s,d,rmin,rmax in zip(orig_min_corner,space,dims,self.bb.mincorner,self.bb.maxcorner):
(3) Replaced 537-538 in case this min/max orientation issue ever happens with the z-axis too:
(4) Replaced 557-558 to give the xpoints and ypoints the correct ordering, using the 'directions' list above, before feeding them into the meshgrid:
The above seems to have solved my problem but I'm not comfortable enough with ITK/mhd/dicom images and their properties, or the rest of roi_utils.py, to know if this hack will generate problems elsewhere.