How to draw the image using co-ordinates?
Show older comments
Hello
i want to draw the image using the cordinates. I got the extracted ROI's from freesurfer now is it possible to draw the ROI's using these cordinates?
Answers (1)
Akshat
on 26 Dec 2024
I am assuming you have the vertices of the ROI. Here is some boilerplate code to assist you:
function plotROIs(coords, labels)
figure;
hold on;
uniqueLabels = unique(labels);
colors = lines(length(uniqueLabels));
for i = 1:length(uniqueLabels)
roiIdx = labels == uniqueLabels(i);
roiCoords = coords(roiIdx, :);
scatter3(roiCoords(:,1), roiCoords(:,2), roiCoords(:,3), ...
'filled', 'MarkerFaceColor', colors(i,:));
if size(roiCoords, 1) > 3
k = boundary(roiCoords); % Create convex hull
trisurf(k, roiCoords(:,1), roiCoords(:,2), roiCoords(:,3), ...
'FaceColor', colors(i,:), 'FaceAlpha', 0.3);
end
end
% Make it look nice
grid on;
axis equal;
xlabel('X'); ylabel('Y'); zlabel('Z');
view(3); % 3D view
rotate3d on;
end
% Example usage:
% coords = [x, y, z] coordinates from FreeSurfer
% labels = ROI labels/numbers
% plotROIs(coords, labels);
Hope this helps
Categories
Find more on Neuroimaging 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!