How to Create a pixelLabelDatastore from a groundTruthMedical Object Exported from Medical Image Labeler?

2 次查看(过去 30 天)
Hi everyone,
I'm working on a semantic segmentation project in MATLAB involving medical images in DICOM format. My idea is use masks exported from Medical Image Labeler from Matlab. I used Medical Image Labeler to annotate several slices (around 10) of volumetric DICOM data. After exporting, I received a .mat file containing a groundTruthMedical object.
My goal is to train a segmentation network, and for that, I need to create a pixelLabelDatastore. I found two ways to do this:
1.Using a groundTruth object directly:
pxds = pixelLabelDatastore(gTruth);
…but this doesn’t work because my variable is of type groundTruthMedical, and MATLAB throws an error if I try to convert it directly to groundTruth due to incompatible DataSource types (e.g., VolumeSource).
>> mask
mask =
groundTruthMedical with properties:
DataSource: [1×1 medical.labeler.loading.VolumeSource]
LabelData: [2×1 string]
LabelDefinitions: [5×3 table]
2. Using the format:
pxds = pixelLabelDatastore(location, classNames, labelIDs);
…but in my case, the labels exist only inside the .mat file and not as individual PNG or image files saved on disk. I don't know what to provide for the location argument here.
Additionally, my original image set has over 600 DICOM slices, but only a few have been labeled, because I would like to see how does it work, as a smaller provisional test. I understand that combine(imds, pxds) requires exact correspondence between image and mask sets. So I probably need to create a subset of the imageDatastore to match the available masks — but I’m unsure of the best way to do this, especially when masks are still stored inside the groundTruthMedical object.My questions:
  • What is the correct workflow to create a pixelLabelDatastore from a groundTruthMedical object?
  • Is it possible to extract the labeled masks from groundTruthMedical and save them as PNGs to use with pixelLabelDatastore(location, classNames, labelIDs)?
  • How do I properly subset my imageDatastore so that it matches only the labeled slices?
Any suggestions or examples would be greatly appreciated!
Thanks in advance.

回答(1 个)

Lipi Vora
Lipi Vora 2025-5-1
We do have an example that could help you with the workflow you are referring to: https://www.mathworks.com/help/medical-imaging/ug/create-training-data-for-3-d-medical-image-semantic-segmentation.html
Please let me know if you run into issues while translating any aspect of this example for your case.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by