hhaentze / MRSegmentator

Apache License 2.0
91 stars 13 forks source link

Differences between inference with nnUNet #15

Closed liyihao76 closed 2 months ago

liyihao76 commented 2 months ago

First of all, a big thank you to the whole team for a great job on this project! This is by far the best performing project I've ever seen for an MR image organ segmentation task.

Currently, I'm trying to use nnUNet's inference commands to compare the performance of the segmentation of my own trained network, TotalSegmentatorMR with MRSegmentator. However, I found that when I use nnUNetv2's inference command (nnUNetv2_predict) with the weights you provided (MRSegmentator/weights), the results I get are very far from using your inference command (inference.infer). Here is an example, using nnUNetv2_predict on the right and reference.infer on the left. image

The nnUNetv2 inference command I used: nnUNetv2_predict -i xxxxx -o xxxxx -d 050 -c 3d_fullres -f 0 Do you know the cause of this problem, please? What should I tweak to achieve the same result as you by using nnUNetv2_predict?

hhaentze commented 2 months ago

Happy to hear that you like the project. We didn't change much from the original nnUNet implementation. The only large difference should be that MRSegmentator automatically forces all images to be in the LPS coordinate system. If you want to use the nnUNetv2 inference command instead, it could maybe help to preprocess your data beforehand.

simpleitk_reader_writer.py:

import SimpleITK as sitk

# read image and save meta data
itk_image = sitk.ReadImage(image_fname)
...
itk_image = sitk.DICOMOrient(itk_image, "LPS")

( I remember it was quite challenging to correctly install the DICOMOrient method, which is apparently not part of all sitk versions. If you know other methods it might be faster to just choose those.)

liyihao76 commented 2 months ago

Thank you very much for your reply, it solved my problem!