Project-MONAI / MONAILabel

MONAI Label is an intelligent open source image labeling and learning tool.
https://docs.monai.io/projects/label
Apache License 2.0
567 stars 185 forks source link

How can I reorganize labeled data via the MONAILabel extension? #1597

Open Cestovatels opened 7 months ago

Cestovatels commented 7 months ago

Hello, I have ready labeled data and when I click on the Next Instance button in the MONAILabel extension I connected via 3D slicer, I get the message "Unlabeled samples or images not found at server. Instead please go to File -> Add Data to load image." I am getting the error. I can't go back to a labeled image and edit it again without using the MONAILabel Reviewer extension? What can I do about this? Can't I change the labeled data directly in the MONAILabel extension? The labels of my data are in label->final. The original file is empty inside. I would be very grateful if you can help me with this issue.

diazandr3s commented 7 months ago

Hi @Cestovatels,

The final folder is used to store the ground-truth annotations or annotations approved by the expert. This means annotations that are already good for training or updating the model. The original folder is used to store the predictions made by the model. They can be edited before Submitting it to the server (or moving it to the final folder).

If you still want to edit /correct some labels, please move them out of the final folder

hope this helps,

Cestovatels commented 7 months ago

Thank you very much for your return. @diazandr3s Actually, my goal is as follows. I have a lot of labeled data. I want to make many more different labels on these labels, save them and continue labeling from where I left off. However, the "submit label" data is not labeled again. I have to use this button to save. I want to update the label, but "Submit label" restricts this. Is there any possibility to update the original labels? Or can I continue labeling with a change in the code? Thank you in advance for your answers.

diazandr3s commented 7 months ago

Hi @Cestovatels,

Thanks for the update.

I want to make many more different labels on these labels, save them and continue labeling from where I left off

Do you mean to create more segments in addition to the ones existing on the label file? If yes, how are you creating these new segments? Manually? or you are using a DL model for that? The Submit Label button is used when you are done with the annotation and you want to use that case for training a model.

Depending on how you are creating additional segments, you may either change the way MONAI Label keep the labels (datastore) or manually save intermediate results on a separate folder. Then, when you are done with the annotation, you can use the Submit Label button.

Let us know,

FreZYa commented 7 months ago

@diazandr3s Hi, I am working on monai label and 3d slicer connection. I may have made some changes to the code on both the server and 3dslicer side. I can view the 280_0000.nii.gz images I put in the "Studies" folder and the 280_0000.nii.gz "labels" I put in the "finals" folder on monailabelrewiever. However, when I want to draw and save an extra label later, I want them to be saved in .nii.gz format. As far as I see, there is another format called .nrrd. It saves it in a temporary temp folder and then sends it to the server via PUT. There it first takes it to temp and then saves it. While the 280_0000.nii.gz "labels" that existed during the registration process here was approximately 3mb, it drops to 600kb even though I draw extra labels on it, and when I upload it again, no labels appear (it uploads this file to the server). How can I fix this situation? How can I save .nii.gz "labels" as .nii.gz on monailabelreviwer in 3d slicer?

diazandr3s commented 7 months ago

Hi @FreZYa,

I'm not sure I fully understand what's the goal here. Do you mind creating a video showing what is the issue you are facing? NIfTI and NRRD are two different file formats. MONAI Labels does support both. You could train a model using any or both file formats.

FreZYa commented 7 months ago

Hi @diazandr3s My aim was not to provide model training. I was only able to "overwrite" the drawings I made after the existing .nifti format labels were displayed in the 3D slicer. However, after making this drawing, my image format saved in finals was .nrrd. This was causing my tags in .nrrd format not to appear on my images in .nifti format. I solved this problem like this: First of all, I disabled the code that prevented me from overwriting a .nifti extension image that was already in finals. Then, I made the following change in MonaiServerREST: basepath = os.path.abspath(labelDirectory)

  def saveLabel(self, imageId:......):
         img = sitk.ReadImage(basepath)
         save_path = basepath.replace("nrrd", "nii.gz")
         sitk.WriteImage(img, save_path)
         try:
             with open(save_path, "rb") as f:
                 response = requests.put(url, headers=headers, data=embeddedParams, files={"label": (imageId + ".nii.gz", f)})

I converted the image from nrrd format to nii.gz format and then replaced the .nrrd parts with nii.gz. This allowed me to both work on .nii.gz files and overwrite the file in the finals folder with the changes I made, without causing any confusion. Thank you for your feedback.

diazandr3s commented 6 months ago

Hi @FreZYa,

Sorry for the late response, I didn't see this until now. What kind of tags do not appear in NRRD format? Which MONAI Label version are you using? In any case, it shouldn't convert images from NIfTI to NRRD. It should keep the same format.

Please let us know,