nnUNet
nnUNet copied to clipboard
DICOM to nii nnUNet format
Hi all,
I am surprised I did not see this in the FAQ or in any issue before (sorry if this info exists but I could not find it): Is there any easy way or already available functions to convert from DICOM to nnUNet nifti format for the training/test data? I have explored dicom2nifti library but this is only for the CT, and not the RTSTRUCT. What do you recommend?
Best, Ana
It's easy to do this: import SimpleITK as sitk
step1:read data from dcm
series_file_names = sitk.ImageSeriesReader.GetGDCMSeriesFileNames(dcm_dir)
series_reader = sitk.ImageSeriesReader()
series_reader.SetFileNames(series_file_names)
image3D = series_reader.Execute()
step2: save as nii.gz
save_img_file = "***.nii.gz"
sitk.WriteImage(image3D, save_img_file, True)
Hello thanks a lot!
I have also found out a codalab notebook where they use Plastimatch, I guess this is another good alternative. Just in case someone need it:
https://github.com/RSNA/AI-Deep-Learning-Lab-2021/blob/main/sessions/tcia-idc/RSNA_2021_IDC_and_TCIA.ipynb
Ana
@BigPandaCPU I am just trying your code and I see that it is to convert the CTs. My question was about converting the RTSTRUCTs, do you have a couple of lines to convert the RTSTRUCT with simple ITK?
Hey there, converting file formats to something that is interpretable by nnU-Net is not within the scopeof nnU-Net (how could it be?), so I cannot help you here. I will close this issue, but please fell free to continue the discussion.
@anabm07 do you know how to get a numpy array from your RTSTRUCT? If so then exporting that to nifti should be no problem