How to do skull stripping when the skull in the image is not complete?
49 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Eudora
am 15 Jul. 2024
Kommentiert: Image Analyst
am 28 Jul. 2024
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 Kommentare
Umar
am 28 Jul. 2024
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!
Akzeptierte Antwort
Image Analyst
am 25 Jul. 2024
Bearbeitet: Image Analyst
am 28 Jul. 2024
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):
- 21.9 Medical Applications -- Brain, Cortex Applications
- 21.9.1 Brain Tumors, Cortex, Cancer
- 21.9.1.1 Glioma Detection, Analysis, Brain Glioma
- 21.9.2 Brain, Cortex, Dementia
- 21.9.2.1 Brain, Cortex, Alzheimer's Disease
- 21.9.3 Brain, Parkinson's Disease
- 21.9.4 Brain, Schizophrenia
- 21.9.5 Brain, Stroke, Ischemic Stroke
- 21.9.5.1 Brain Development Analysis, Infant Brain
- 21.9.6 Brain, Cortex, General Segmentation Issues
- 21.9.7 Brain, Cortex, MRI Analysis, Models, 3-D
- 21.9.7.1 White Matter Fiber Tractography MRI
- 21.9.7.2 Brain, Cortex, Cerebral Arteries, Cerebral Aneurysm, Cerebrovascular
- 21.9.7.3 Brain, Cortex, MRI Segmentation
- 21.9.7.4 Brain, Cortex, Registration, Alignment, MRI, Other
- 21.9.7.5 Functional Magnetic Resonance, fMRI
- 21.9.7.6 fMRI Brain Activity Detction
- 21.9.7.7 fMRI for Brain Connectivity Analysis
- 21.9.7.8 EEG-MRI, EEG-fMRI, Combined Analysis
- 21.9.8 Brain, Cortex, Brain Waves, EEG Analysis, Electroencephalogram
- 21.9.8.1 Brain Waves, EEG Analysis, Electroencephalogram for Biometrics
- 21.9.8.2 EEG Noise Removal, Electroencephalogram Denoising
- 21.9.8.3 Brain-Computer Interface, Brain-Machine Interface, Biomimetic
- 21.9.9 Multiple Sclerosis Detection and Analysis
- 21.9.10 Epileptic Seizures, Epilepsy Detection and Analysis
2 Kommentare
Image Analyst
am 28 Jul. 2024
Attached is a more complete demo that produces the image below.
Weitere Antworten (1)
Milan Bansal
am 24 Jul. 2024
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:
- Enhance the contrast to highlight the tumor. "imadjust" function can be used to enhance the contrast of the grayscale image.
- Use thresholding to segment the brightest region.Use "imbinarize" with a high threshold value to isolate the bright regions.
- 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.
- 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.
- 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:
- imadjust: https://www.mathworks.com/help/images/ref/imadjust.html
- imbinarize: https://in.mathworks.com/help/images/ref/imbinarize.html
- imdilate: https://www.mathworks.com/help/images/ref/imdilate.html
- imerode: https://www.mathworks.com/help/images/ref/imerode.html
- imfill: https://in.mathworks.com/help/images/ref/imfill.html
- bwlabel: https://in.mathworks.com/help/images/ref/bwlabel.html
- regionprops: https://www.mathworks.com/help/images/ref/regionprops.html
Hope this helps!
2 Kommentare
Image Analyst
am 25 Jul. 2024
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.
Siehe auch
Kategorien
Mehr zu MRI finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!