JDSobek / MedYOLO

A 3D bounding box detection model for medical data.
GNU Affero General Public License v3.0
25 stars 6 forks source link

Could you tell me how to set the label! #16

Open yuqingchen123 opened 1 week ago

yuqingchen123 commented 1 week ago

When I used the BRaTS-2021 dataset, I couldn't understand how the “.txt” in the labels was designed, could you please solve my question? Thank you.

JDSobek commented 1 week ago

Here is a piece of code that shows how to go from a NIfTI segmentation to a .txt label. It might not generalize perfectly but should give you a pretty good schematic for how segmentation masks relate to .txt labels. You'd at least need to change the "target labels" list to whichever BRaTS labels you are interested in, for the paper/testing I used the whole tumor segmentation without the extra rotation augmentation.

Building from what YOLOv5 used, the labels are in the order of: class-number z-center x-center y-center z-length x-length y-length Class is an integer, the other numbers or normalized lengths (i.e. whatever the voxel size of the segmentation is divided by the nifti's size along that axis). So an example label (using random numbers) might look like a .txt file containing the following:

3 0.5363 0.332 0.2467 0.13 0.184 0.145 2 0.3058 0.284 0.138 0.042 0.053 0.026

Predictions will look similar, but can optionally have the model's confidence saved at the end.

I don't think BRaTS required any special considerations during the conversion from segmentations to text labels, but any preprocessing of the dataset was done well before I used it, so I'm not 100% sure.

yuqingchen123 commented 1 week ago

我已收到。