Gray Matter Area and Volume Calculations

21 views (last 30 days)
Hello, I am working on gray matter area and volume calculation of brain MRI image. I have some doubts with my code below:
% Area Calculation
Pixel_Numbers = sum(J(:));
DistanceinUnit = 1.796875; %Based on pixel spacing (in mm?)
DistanceinPixel = sqrt(x^2+y^2);
DistancePerPixel = DistanceinUnit/DistanceinPixel;
Area = (Pixel_Numbers)*(DistancePerPixel^2); %Is it in mm^2 or mm^2/pixel?
% Volume Calculation (Is the formula correct?)
LengthinPixel = length(find(J(:)==1));
Length = LengthinPixel*DistanceinUnit;
Volume = Area*Length;
The information about pixel spacing is 1.796875\1.796875. I'd be glad if you can help me to figure out the answer. Here is the picture. Thank you.
Qvna Lhyvnav
Qvna Lhyvnav on 24 Apr 2020
Sorry for the badly-named image :D No, it doesn't. I attach the new one here.
The doubts are:
  1. Did I define for "DistanceinUnit = 1.796875" based on the pixel spacing information in MRI image correctly?
  2. My script was based on yours (spatial calibration script), but I confused about the area unit since DistanceinPixel = pixel; DistancePerPixel = mm/pixel; Area = pixel*(mm^2/pixel^2) = mm^2/pixel. Do I define this correct or I miss something? I want to have a mm unit for area.
  3. I also want to calculate the volume, but was my script correct (area x length)? I have no idea to find the height information.
Looking forward to your reply. Thank you.

Sign in to comment.

Accepted Answer

Ryan Comeau
Ryan Comeau on 6 May 2020
Hello, i think you're image appears to be binarized already. This means we can obtain the area well with the regionprops function.
In terms of the volume, are you wanting to sum up the number of pixel in that area * intensity? In you case if the image is binary, the volume and area will be the same. volume=area*height but height is 1 because your image is binary.
The last thing you want now is pixels to mm? just determine the conversion for this, if a pixel is 1.796875x1.796875 we will have an area=(1.796875)^2*num_pixels.
If all the area is one block, it will be returned from regionprops, if not you'll need to sum it up. Here is my logic for this problem:
image=rescale(image,0,1); %helps for binarization
BW_im=imbinarize(image); %see documentation, it is versatile
hh=regionprops(BW_im,{'Centroid','Area',}); %centroid for locations.
height=1;%your image is binary, if it's not this will change pixel by pixel.
%see the regionprops function to sum up pixel values as well.
for i=1:length(hh)
Hope this helps, if not, drop a comment.
Qvna Lhyvnav
Qvna Lhyvnav on 10 May 2020
Edited: Qvna Lhyvnav on 10 May 2020
I understand your explanation about the bounding box, but I don't understand why you put hh(i).BoundingBox(4) into the total_area. My logic is like this:
total_volume=total_volume+(hh(i).Area*hh(i).BoundingBox(3)) %height is the 3rd element of the bounding box
Would you like to elaborate your code?
I also have another idea after read can anyone inform me on how to calculate the volume of the segmented region?. I added the slice thickness information, so the code would be like this:
voxel_numbers = 0;
for i=1:length(hh)
voxel_numbers = voxel_numbers+hh(i).Area;
Pixel_Spacing = [1.796875;1.796875]; Slice_Thickness = 4;
Volume_Per_Voxel = Pixel_Spacing(1)*Pixel_Spacing(2)* Slice_Thickness;
Volume_in_mm3 = Volume_Per_Voxel*voxel_numbers;
Does my code make sense? Thank you before, RC.

Sign in to comment.

More Answers (0)


Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!