- How is the get_totals() function defined? In particular, what does it expect as input?
- In the example, does each .nii file correspond to a binary mask representing the named material?
- For each specific region in which you're interested, do you have an .nii file corresponding to a binary mask representing the region?
How to Get Grey Matter Volume of Specific Brain Regions in SPM/MATLAB?
32 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I want to extract grey matter volume for specific regions (e.g., prefrontal cortex, amygdala) from MRI data that has been preprocessed. My lab gave me a code (see below) for calculating global grey matter volume (and white matter volume and CSF), but I am not sure whether I can adapt this script to also extract regional grey matter volume. Would appreciate help!
% Get total volumes in mm3
grey_totals(i) = get_totals ([data_path num2str(subnum) '/c1' num2str(subnum) '.nii']);
white_totals(i) = get_totals ([data_path num2str(subnum) '/c2' num2str(subnum) '.nii']);
csf_totals(i) = get_totals ([data_path num2str(subnum) '/c3' num2str(subnum) '.nii']);
end
12 comentarios
Karl
el 19 de Feb. de 2024
You're welcome! If you're unable to get the looping to work, please do submit another question, ideally including code and files for reproducing the problem (as you did in the comments here). Hopefully I, or someone else, will be able to help!
Respuesta aceptada
Karl
el 18 de Feb. de 2024
Summarising from the comments, if 'roi.nii' is a NIfTI file containing a binary mask representing a region of interest (ROI), and the Statistical Parametric Mapping (SPM12) package is on the MATLAB path, the ROI volume can be calculated using the get_totals() function written by Ged Ridgway:
% Calculate ROI volume using SPM12.
roi_volume = get_totals('roi.nii');
The ROI volume can also be calculated without having SPM12 installed:
% Write example ROI (cuboid) in NIfTI format.
mask = zeros(100,100,100);
[x1, y1, z1] = deal(31, 41, 11);
[dx, dy, dz] = deal(40, 20, 80);
mask(x1:x1+dx-1,y1:y1+dy-1,z1:z1+dz-1) = 1;
niftiwrite(mask,'roi.nii')
% Read ROI from NIfTI file, and calculate its volume.
roi_info = niftiinfo('roi.nii');
roi = niftiread(roi_info);
roi_volume = sum(roi(:)) * prod(roi_info.PixelDimensions)
% Check that the calculated volume is as expected from the cuboid dimensions.
assert(roi_volume == dx * dy * dz)
Whichever method is used, the volume units should be checked.
Más respuestas (0)
Ver también
Categorías
Más información sobre Get Started with Image Processing Toolbox en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!