Brats-20 dataset labels visualization on 3D images #5683
Replies: 3 comments 1 reply
-
Hi @faizan1234567, if you have the number 4 in the tensor, then maybe your num_classes in the one-hot function should be 5. You can use AsDiscrete in MONAI. Just a simple example for your reference. MONAI/monai/transforms/post/array.py Line 131 in 78d4f42
Hope it can help you, thanks! |
Beta Was this translation helpful? Give feedback.
-
I want to create a visualization of tumors on the scan. The scan has the shape:(4, 240, 240, 155), and the shape of mask and prediction is: (3, 240, 240, 155), how can I use this to plot abnormalities on the scan, is there any way or example? Could you please help? Also, I want to create a gif from this. Like labels is being plotted on the input or the case |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I am working on the Brats-20 dataset. I want to create a gif animation of labels on images and prediction results on images. I am trying to do that. However, I am confused about the plots I get from the visualization.
I use the Keras function 'to_categorical' to convert labels to one hot representation from (240, 240, 155) shape as in the following code.
`def categorical(image, mask, is_categorical=False):
if not is_categorical:
label = to_categorical(mask, num_classes = 4).astype(np.uint8)
Here the image has the shape of (240, 240, 155, 4) corresponding to a patient scan, and the mask has the shape of (240, 240, 155).
I want to create a nice visualization like that:
And a gif file to show labels or prediction results on an image. But the _seg.nii.gz (label file) contains the number 4 in the tensor. Which gives me an error in to_categorical. Because I am using num_classes =4 in the above function as you can see. Then I normalized the labels which converted labels for int to float values, and it was wrong.
Then I wrote something like limiting pixel labels from 1 to 3 to remove the error. Which successfully removed the error, however, I don't know if it is correct to label colors for the visualization. OR has it been mapped accurately or not? I need guidance, please.
I wrote the following code to map labels from 1 to 3 (I don't know if it's correct or not), but it removed the error in the to_categorical function. The code:
`def normalize(mask: np.ndarray):
Help will be appreciated as I am stuck here.
Beta Was this translation helpful? Give feedback.
All reactions