How to do skull stripping when the skull in the image is not complete?

조회 수: 44 (최근 30일)
How do I remove the skull (as well as others tissues that are not tumor, but have similar intensity) from the MRI images? I have seen methods including removing the largest blob (the skull), but the skull does not enclose the brain fully in the picture I attached here. Using imbinarize will also keep other tissues which have similar intensity as the tumor in the image.
I have tried to use imerode, but the skull is not removed entirely.
Any help is appreciated. Thanks!
  댓글 수: 3
Eudora
Eudora 2024년 7월 28일
Hi, thanks for your reply. I tried to use similar methods / functions but it didn't work well.. but still, thank you for trying to help!
Umar
Umar 2024년 7월 28일
Hi Eudora,
Glad to help, but if these functions did not work, I will provide guidance on how to use these functions, in case if you have to utilize them in your future matlab projects, please refer to
https://www.mathworks.com/help/images/ref/bwareaopen.html
https://www.mathworks.com/help/images/ref/imcomplement.html?searchHighlight=imcomplement&s_tid=srchtitle_support_results_1_imcomplement
https://www.mathworks.com/help/images/ref/imshowpair.html?searchHighlight=imshowpair&s_tid=srchtitle_support_results_1_imshowpair
Good luck!

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2024년 7월 25일
편집: Image Analyst 2024년 7월 28일
I presume you've already seen my skull stripping demo I've posted many times, but I'm attaching it here for others.
If your initial binary image, gotten from thresholding, has gaps in the skull, then imerode will erode it from both sides, as well as any blobs inside thus changing their area and shape. So what you want to do is to create a full skull mask using bwconvhull and then erode that and use it as a mask against your gray level image or another binary image.
The assumptions of the skull or tumor being the largest blob is not robust. Not only that but there is a possibility that there may be more than one tumor.
But what you do know is that the skull is, or should be the outermost blob since it encloses everything else. If there are no blobs outside the skull then you label the binary image mask and the skull will have a label ID of 1 and you can se ismember to get the skull blob alone, if you want it. However a more robust way that handles small outside blobs, like text annotations or whatever is to call bwconvhull and then call bwareafilt
% Fill gaps in outer skull blob.
headMask = bwconvhull(binary_mask, 'objects');
% Take largest blob which should be the whole head mask.
headMask = bwareafilt(headMask, 1);
% Erode it some amount to get a mask of just the interior.
se = strel('disk', 5, 0);
headMask = imerode(headMask, se); % Shrunken head mask
% Now use the headMask to mask out the skull and everything outside of it.
binary_mask = binary_mask & headMask;
% Now only blobs inside the skull remain and you can continue segmentation
% to find one or more tumors based on some criteria.
But I really think that if you want a robust algorithm you should not use any 30 line code snippet you get here but see how people have discovered how to do it and have published peer reviewed results. They've spent years perfecting the algorithm and it will be better than any simplistic algorithm I think up off the top of my head. You can search PubMed (medical papers) or VisionBib (archive of all image processing papers):
  댓글 수: 2
Eudora
Eudora 2024년 7월 28일
Woww, thank you for introducing new functions and recommending helpful papers! I will try to use those functions on my project once I get back to work! (I am on vacation.) Thank you for all the help, appreciate it!!
Image Analyst
Image Analyst 2024년 7월 28일
Attached is a more complete demo that produces the image below.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Milan Bansal
Milan Bansal 2024년 7월 24일
Hi Eudora,
I understand that you wish to remove the skull area in order to isolate the tumour from the MRI scans but are facing issues with it.
To isolate and remove everything except the tumor (assuming the bright white spot) from the MRI image, it is required to focus on segmenting the brightest region. The following approach can be followed to achieve this:
  1. Enhance the contrast to highlight the tumor. "imadjust" function can be used to enhance the contrast of the grayscale image.
  2. Use thresholding to segment the brightest region.Use "imbinarize" with a high threshold value to isolate the bright regions.
  3. Apply morphological operations to refine the segmentation. "imerode" and "imdilate" refine the segmentation by removing small artifacts and filling gaps. "imfill" fills any holes within the segmented region.
  4. Select the tumour region. Use "bwlabel" to label connected components in the binary image and "regionprops" to measure the properties of each labeled region to identify the largest one, assumed to be the tumor.
  5. Mask the original image to isolate the tumor.
Please refer to the following code snippet for demo:
img = imread("image.jpeg");
grayImg = rgb2gray(img);
% Apply Gaussian filter to smooth the image
filteredImg = imgaussfilt(grayImg, 1);
% Enhance contrast
enhancedImg = imadjust(filteredImg);
% Thresholding to segment the bright region
thresholdValue = 0.93; % Adjust this value as needed
binaryImg = imbinarize(enhancedImg, thresholdValue);
% Morphological operations to refine the segmentation
binaryImg = imerode(binaryImg, strel('disk', 2));
binaryImg = imdilate(binaryImg, strel('disk', 3));
binaryImg = imfill(binaryImg, 'holes');
% Label connected components
labeledImg = bwlabel(binaryImg);
% Measure properties of the blobs
stats = regionprops(labeledImg, 'Area', 'PixelIdxList');
% Find the largest blob (assuming it's the tumor)
[~, idx] = max([stats.Area]);
tumorMask = ismember(labeledImg, idx);
% Apply the mask to the original image to isolate the tumor
tumorImg = grayImg;
tumorImg(~tumorMask) = 0;
% Display the results
figure;
subplot(1, 2, 1), imshow(grayImg), title('Original Image');
subplot(1, 2, 2), imshow(tumorImg), title('Isolated Tumor');
Please refer to the following documentation links to learn more about mentioned functions:
Hope this helps!
  댓글 수: 2
Image Analyst
Image Analyst 2024년 7월 25일
imadjust is not needed - it simply changes the threshold to a different gray level than it would be originally but won't change the binary image. I also doubt that blurring the image is necessary because it will just make the tumor boundary smoother and less accurate. And the code depends on the tumor being brighter than the skull but she said that in some images the tumor is not brighter because it's the same brightness as the skull.
Eudora
Eudora 2024년 7월 28일
Hi, thank you for your reply and the example code! I will try to use them once I get back to work!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MRI에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by