rt-utils icon indicating copy to clipboard operation
rt-utils copied to clipboard

issue with saggital MR scans

Open ceps1986 opened this issue 3 years ago • 4 comments

I have a 3D MR series with 160 dicom files. x, y, z dims for the series are (160, 256, 256). If I've followed the code properly, i think it assumes that image series files are acquired in z direction, is that a correct?

ceps1986 avatar Nov 16 '21 22:11 ceps1986

terrific tool by the way, first time I've run into issues using it!

ceps1986 avatar Nov 16 '21 22:11 ceps1986

Hi @ceps1986, glad you like the tool!

What exactly is the issue you were having? Were you expecting it to be acquired in a different manner? Would you also mind clarifying what you mean by acquired? We don't do much when the DICOM files are loaded in, it is mostly just handled by Pydicom. We do assume that the contour points are arranged in [x, y, z].

asim-shrestha avatar Nov 17 '21 00:11 asim-shrestha

Hi @asim-shrestha, thanks for the prompt response.

Here's what I think is happening... (I haven't gone down the rabbit hole just yet):

What exactly is the issue you were having?

  • rtstruct.add_roi requires mask.shape[-1] to be equal to the number of DICOM files. if I reshape my mask (i.e. from [160, 256, 256] -> [256, 256, 160]) then the contour points are being place on the wrong axis in get_contours_coords (https://github.com/qurit/rt-utils/blob/5b7072e306c52c3ee7c11b3d778a8dbeb80f29d9/rt_utils/image_helper.py#L46) Doing this writes a RTSTRUCT file, but the contours in the file do not match the image space so several dicom viewers won't import/load the DICOM file properly.

Would you also mind clarifying what you mean by acquired?

  • MR scans can be acquired in any direction (axial, sagittal, coronal, etc.). In my case (where images where acquired sagittally) this leads to the array_data loaded for a single file using pydicom to show as below. image

We don't do much when the DICOM files are loaded in, it is mostly just handled by Pydicom. We do assume that the contour points are arranged in [x, y, z].

  • Yes, points are always arranged in [x, y, z]. Here though (https://github.com/qurit/rt-utils/blob/5b7072e306c52c3ee7c11b3d778a8dbeb80f29d9/rt_utils/image_helper.py#L50) the assumption is that the slices are in the z direction, therefore contour coordinates in the wrong space.

Hope this makes sense! I will look for a publicly available dataset that I can share so that we can test this

ceps1986 avatar Nov 17 '21 02:11 ceps1986

Thank you for the in-depth response @ceps1986! This clears a lot up. I'll have to discuss ways we can update RT-Utils to handle files acquired in different axes.

If you have any ideas yourself, feel free to submit a pull request with your changes :)

asim-shrestha avatar Nov 23 '21 05:11 asim-shrestha