How to realign PATCH object along with plotted 3D GRAPH network?

3 vues (au cours des 30 derniers jours)
I try to plot a 3d graph network over a loaded STL object to enhanced visualization. I would like to know if I can move and rotate the plotted PATCH object to align perfectly under plotted scalph graph network?
Here is a list of function I used in the script:
  • EEGLAB for getting EEG.chanlocs (electrode position) for plotting graph network, this value is constant for all plot.
  • STL File Reader by Eric Johnson for import 3d brain file
Here is my code so far:
W1 = threshold_proportional(plv, 0.2); % thresholding for PLV
W2 = threshold_proportional(pliComputed, 0.2); % thresholding for PLI
W3 = threshold_proportional(PTE,0.2); % thresholding for PTE
W4 = threshold_proportional(dPTE,0.2); % thresholding for dPTE
w = W1; % change data here
st = sum(w,2); % compute network strength
[links,wij,rgb] = convMatrixGraph(w); % compute plotting parameters
figure
hold on;
for ll = 1 : length(links) %% plotting links
line([EEG.chanlocs(links(ll,1)).X, EEG.chanlocs(links(ll,2)).X], [EEG.chanlocs(links(ll,1)).Y, EEG.chanlocs(links(ll,2)).Y], [EEG.chanlocs(links(ll,1)).Z, EEG.chanlocs(links(ll,2)).Z], 'LineWidth', wij(ll), 'Color', rgb(ll,:) );
end
colormap(jet);
% colorbar
for nn = 1 : 32 %% plotting nodes
plot3(EEG.chanlocs(nn).X, EEG.chanlocs(nn).Y, EEG.chanlocs(nn).Z, 'ro', 'MarkerSize', st(nn), 'MarkerFaceColor', 'y')
text(EEG.chanlocs(nn).X+0.5, EEG.chanlocs(nn).Y, EEG.chanlocs(nn).Z, EEG.chanlocs(nn).labels, 'FontSize', 11);
end
% read brain model file
fv = stlread('brain.stl');
%% Render
% The model is rendered with a PATCH graphics object. We also add some dynamic
% lighting, and adjust the material properties to change the specular
% highlighting.
patch(fv,'FaceColor', [0.8 0.8 1.0], ...
'EdgeColor', 'none', ...
'FaceLighting', 'gouraud', ...
'AmbientStrength', 0.15, ...
'FaceAlpha', 0.07);
% Add a camera light, and tone down the specular highlighting
camlight('headlight');
material('dull');
% Fix the axes scaling, and set a nice view angle
axis('image');
view([-135 35]);
% view([270 90]); %% rotating to vertical view
axis equal; axis off;
title('test mapping 3D')
set(gcf, 'units','normalized','outerposition',[0 0 1 1]) %EXPANDING FIGURE ON SCREEN
Here is the current result and how I would like to move it:
Top view & side & front view
My expected result:
to rotate, move under the plotted graph and enlarge to fit the scale. The brain model is set to semi-transparent also to see the line connection.
Any help would be greatly appreciate, thank you.

Réponse acceptée

Walter Roberson
Walter Roberson le 1 Déc 2022
You would create a hgtransform() whose parent is the axes, and when you patch() you would tell patch() that the 'Parent' object is the hgtransform you created. Then you would set the Matrix property of the hgtransform to be a Transformation Matrix -- a 4 x 4 rotation / scaling / translation matrix. Using makehgtform() makes it a lot easier to create such matrix -- just remember that the last operation you list in creating the transform is the one that is applied first.
You might, for example, subtract off the coordinates of a point you want to rotate around, then rotate, then add back on the points you are rotating around, to get the overall effect of rotation around that point.

Plus de réponses (0)

Catégories

En savoir plus sur Lighting, Transparency, and Shading dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by