|
15 | 15 | loadFolder=fullfile(projectFolder,'data','BodyParts3D','post'); |
16 | 16 | saveFolder_stl=fullfile(projectFolder,'data','BodyParts3D','post_stl'); |
17 | 17 | saveFolder=loadFolder; |
18 | | -saveNameGeom='BodyParts3D_right_leg_transtibial_amp'; |
19 | | -select_amputation_case='tt';%'tt';'tf' % where the trans-tibial(tt); trans-femoral (tf) |
| 18 | +saveNameGeom_tt='BodyParts3D_right_leg_transtibial_amp'; |
| 19 | +saveNameGeom_tf='BodyParts3D_right_leg_transfemoral_amp'; |
| 20 | +select_amputation_case='tf';%'tt';'tf' % where the trans-tibial(tt); trans-femoral (tf) |
20 | 21 |
|
21 | 22 | switch select_amputation_case |
22 | 23 | case 'tf' |
|
25 | 26 | fileNames={'right_femur','right_tibia','right_fibula','right_patella','right_leg_skin','right_leg_muscles'}; |
26 | 27 | end |
27 | 28 |
|
28 | | -saveOn=0; |
| 29 | +saveOn=1; |
29 | 30 |
|
30 | 31 | %The percentage for trans-femoral (above knee) amputation |
31 | 32 | amputationPercentageFemur=25; |
|
73 | 74 | % Visualize surface and landmarks |
74 | 75 | cFigure; hold on; |
75 | 76 | gpatch(FT,VT,CT,'none',0.5); |
76 | | -axisGeom; camlight headlight; |
| 77 | +axisGeom; axis off;camlight headlight; |
77 | 78 | colormap gjet; icolorbar; |
78 | 79 | gdrawnow; |
79 | 80 |
|
80 | | - |
81 | | -%% Compute landmarks for tt amputation |
| 81 | +%% Compute landmarks for tf amputation |
82 | 82 | switch select_amputation_case |
83 | 83 | case 'tf' |
84 | 84 | %% Compute the femur length for tf amputation |
|
91 | 91 | %% |
92 | 92 | % Visualize surface and landmarks |
93 | 93 | cFigure; hold on; |
94 | | - gpatch(FT,VT,CT,'none',0.5); |
95 | | - plotV(V_bone_femur(I_min_femur,:),'k.','MarkerSize',35); |
96 | | - axisGeom; camlight headlight; |
97 | | - colormap gjet; icolorbar; |
| 94 | + gpatch(FT,VT,CT,'none',0.25); |
| 95 | + plotV(V_bone_femur(I_min_femur,:),'k.','MarkerSize',50); |
| 96 | + axisGeom; axis off; camlight headlight; |
| 97 | + colormap gjet; %icolorbar; |
98 | 98 | gdrawnow; |
99 | 99 |
|
100 | 100 | case 'tt' |
|
103 | 103 | %% |
104 | 104 | % Visualize surface and landmarks |
105 | 105 | cFigure; hold on; |
106 | | - gpatch(FT,VT,CT,'none',0.5); |
107 | | - plotV(P_patella_centroid,'k.','MarkerSize',35); |
108 | | - axisGeom; camlight headlight; |
109 | | - colormap gjet; icolorbar; |
| 106 | + gpatch(FT,VT,CT,'none',0.25); |
| 107 | + plotV(P_patella_centroid,'k.','MarkerSize',50); |
| 108 | + axisGeom; axis off;camlight headlight; |
| 109 | + colormap gjet; %icolorbar; |
110 | 110 | gdrawnow; |
111 | 111 | end |
112 | 112 |
|
|
146 | 146 | % Visualization |
147 | 147 |
|
148 | 148 | cFigure; hold on; |
149 | | -title('Cut features'); |
| 149 | +%title('Cut features'); |
150 | 150 | % gpatch(FT,VT,'w','none',0.1); |
151 | 151 | gpatch(FT_amp,VT_amp,CT_amp,'none',0.5); |
152 | | -axisGeom; camlight headlight; |
153 | | -colormap gjet; icolorbar; |
| 152 | +axisGeom; axis off; camlight headlight; |
| 153 | +colormap gjet; %icolorbar; |
154 | 154 | gdrawnow; |
155 | 155 |
|
156 | 156 | %% Set up skin taper parameterisation |
|
236 | 236 | cFigure; hold on; |
237 | 237 | title('Distal end closure'); |
238 | 238 | gpatch(FT_amp,VT_amp,'w','none',1); |
239 | | -gpatch(Fs,Vs,'w','none',0.25); |
| 239 | +%gpatch(Fs,Vs,'w','none',0.25); |
240 | 240 | hp=gpatch(Fsb,Vsb,Vsb(:,3),'none',1); hp.FaceColor='interp'; |
241 | 241 | % gpatch(Ebs,Vs,'none','b',1,3); |
242 | 242 |
|
|
251 | 251 |
|
252 | 252 | plotV(P_end,'k.','MarkerSize',25); |
253 | 253 |
|
254 | | -axisGeom; camlight headlight; |
| 254 | +axisGeom; axis off; camlight headlight; |
255 | 255 | gdrawnow; |
256 | 256 |
|
257 | 257 |
|
|
282 | 282 | subplot(1,2,1); hold on; |
283 | 283 | % gpatch(FT,VT,'w','none',0.25); |
284 | 284 | gpatch(FT_amp,VT_amp,CT_amp,'none',0.5); |
285 | | -axisGeom; camlight headlight; |
286 | | -colormap gjet; icolorbar; |
| 285 | +axisGeom; axis off; camlight headlight; |
| 286 | +colormap gjet; %icolorbar; |
287 | 287 |
|
288 | 288 | subplot(1,2,2); hold on; |
289 | 289 | gpatch(FT_amp,VT_amp,'w','k',1); |
290 | | -axisGeom; camlight headlight; |
| 290 | +axisGeom; axis off; camlight headlight; |
291 | 291 | gdrawnow; |
292 | 292 |
|
293 | 293 |
|
|
385 | 385 | subplot(1,2,1); hold on; |
386 | 386 | % gpatch(FT,VT,'w','none',0.25); |
387 | 387 | gpatch(FT_amp,VT_amp,CT_amp,'none',0.5); |
388 | | -axisGeom; camlight headlight; |
389 | | -colormap gjet; icolorbar; |
| 388 | +axisGeom; axis off; camlight headlight; |
| 389 | +colormap gjet; %icolorbar; |
390 | 390 |
|
391 | 391 | subplot(1,2,2); hold on; |
392 | 392 | gpatch(FT_amp,VT_amp,'w','k',0.5); |
393 | | -axisGeom; camlight headlight; |
| 393 | +axisGeom; axis off; camlight headlight; |
394 | 394 | gdrawnow; |
395 | 395 |
|
396 | 396 | %% Process femur taper |
|
462 | 462 | subplot(1,2,1); hold on; |
463 | 463 | % gpatch(FT,VT,'w','none',0.25); |
464 | 464 | gpatch(FT_amp,VT_amp,CT_amp,'none',0.5); |
465 | | -axisGeom; camlight headlight; |
466 | | -colormap gjet; icolorbar; |
| 465 | +axisGeom; axis off; camlight headlight; |
| 466 | +colormap gjet; %icolorbar; |
467 | 467 |
|
468 | 468 | subplot(1,2,2); hold on; |
469 | 469 | gpatch(FT_amp,VT_amp,'w','none',0.5); |
|
475 | 475 | hold on; |
476 | 476 | % gpatch(FT,VT,'w','none',0.25); |
477 | 477 | gpatch(FT_amp,VT_amp,CT_amp,'none',0.5); |
478 | | -axisGeom; camlight headlight; |
479 | | -colormap gjet; icolorbar; |
| 478 | +axisGeom; axis off; camlight headlight; |
| 479 | +colormap gjet; %icolorbar; |
480 | 480 | gdrawnow; |
481 | 481 |
|
482 | 482 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
715 | 715 | %% |
716 | 716 | cFigure; hold on; |
717 | 717 | gpatch(FT_amp,VT_amp,CT_amp,'none',0.5); |
718 | | - patchNormPlot(FT_amp{1},VT_amp{1}); |
719 | | - axisGeom; camlight headlight; |
720 | | - colormap gjet; icolorbar; |
| 718 | + %patchNormPlot(FT_amp{1},VT_amp{1}); |
| 719 | + axisGeom; axis off; camlight headlight; |
| 720 | + colormap gjet; %icolorbar; |
721 | 721 | gdrawnow; |
722 | 722 |
|
723 | 723 | case 'tf' |
|
875 | 875 | cFigure; hold on; |
876 | 876 | gpatch(FT_amp,VT_amp,CT_amp,'none',0.5); |
877 | 877 | patchNormPlot(FT_amp,VT_amp); |
878 | | - axisGeom; camlight headlight; |
879 | | - colormap gjet; icolorbar; |
| 878 | + axisGeom; axis off; camlight headlight; |
| 879 | + colormap gjet; %icolorbar; |
880 | 880 | gdrawnow; |
881 | 881 |
|
882 | 882 | % stlwrite(triangulation(VT_amp{1},FT_amp{1}),fullfile(saveFolder_stl,'femur_tf.stl'),'binary'); |
883 | 883 | % stlwrite(triangulation(VT_amp{2},FT_amp{2}),fullfile(saveFolder_stl,'skin_tf.stl'),'binary'); |
884 | 884 | % stlwrite(triangulation(VT_amp{3},FT_amp{3}),fullfile(saveFolder_stl,'muscle_tf.stl'),'binary'); |
885 | 885 | % stlwrite(triangulation(VT_amp{4},FT_amp{4}),fullfile(saveFolder_stl,'muscle_lid_tf.stl'),'binary'); |
886 | 886 | % stlwrite(triangulation(VT_amp{5},FT_amp{5}),fullfile(saveFolder_stl,'skin_lid_tf.stl'),'binary'); |
887 | | - stlStruct.solidNames={'Femur'}; |
888 | | - stlStruct.solidVertices={VT_amp{1}}; |
889 | | - stlStruct.solidFaces={FT_amp{1}}; |
890 | | - stlStruct.solidNormals={[]}; |
891 | | - fileName=fullfile(saveFolder_stl,'femur_tf.stl'); |
892 | | - export_STL_txt(fileName,stlStruct); |
893 | | - |
894 | | - stlStruct.solidNames={'Skin'}; |
895 | | - stlStruct.solidVertices={VT_amp{2}}; |
896 | | - stlStruct.solidFaces={FT_amp{2}}; |
897 | | - stlStruct.solidNormals={[]}; |
898 | | - fileName=fullfile(saveFolder_stl,'skin_tf.stl'); |
899 | | - export_STL_txt(fileName,stlStruct); |
900 | | - |
901 | | - stlStruct.solidNames={'Muscle'}; |
902 | | - stlStruct.solidVertices={VT_amp{3}}; |
903 | | - stlStruct.solidFaces={FT_amp{3}}; |
904 | | - stlStruct.solidNormals={[]}; |
905 | | - fileName=fullfile(saveFolder_stl,'muscle_tf.stl'); |
906 | | - export_STL_txt(fileName,stlStruct); |
907 | | - |
908 | | - stlStruct.solidNames={'Muscle_lid'}; |
909 | | - stlStruct.solidVertices={VT_amp{4}}; |
910 | | - stlStruct.solidFaces={FT_amp{4}}; |
911 | | - stlStruct.solidNormals={[]}; |
912 | | - fileName=fullfile(saveFolder_stl,'muscle_lid_tf.stl'); |
913 | | - export_STL_txt(fileName,stlStruct); |
914 | | - |
915 | | - stlStruct.solidNames={'Skin_lid'}; |
916 | | - stlStruct.solidVertices={VT_amp{5}}; |
917 | | - stlStruct.solidFaces={FT_amp{5}}; |
918 | | - stlStruct.solidNormals={[]}; |
919 | | - fileName=fullfile(saveFolder_stl,'skin_lid_tf.stl'); |
920 | | - export_STL_txt(fileName,stlStruct); |
921 | | - |
922 | | - |
| 887 | +% |
| 888 | +% %% Remesh |
| 889 | +% optionStructRemesh.pointSpacing=2; %Set desired point spacing |
| 890 | +% [FT_amp{1},VT_amp{1}]=ggremesh(FT_amp{1},VT_amp{1},optionStructRemesh); |
| 891 | +% [FT_amp{2},VT_amp{2}]=ggremesh(FT_amp{2},VT_amp{2},optionStructRemesh); |
| 892 | +% [FT_amp{3},VT_amp{3}]=ggremesh(FT_amp{3},VT_amp{3},optionStructRemesh); |
| 893 | +% [FT_amp{4},VT_amp{4}]=ggremesh(FT_amp{4},VT_amp{4},optionStructRemesh); |
| 894 | +% [FT_amp{5},VT_amp{5}]=ggremesh(FT_amp{5},VT_amp{5},optionStructRemesh); |
| 895 | + |
923 | 896 | end |
924 | 897 |
|
925 | 898 | %% Save model |
926 | 899 | if saveOn==1 |
927 | | - saveName_mat=fullfile(saveFolder,[saveNameGeom,'.mat']); |
928 | | - save(saveName_mat,'FT_amp','VT_amp','CT_amp'); |
| 900 | + switch select_amputation_case |
| 901 | + case 'tt' |
| 902 | + saveName_mat=fullfile(saveFolder,[saveNameGeom_tt,'.mat']); |
| 903 | + save(saveName_mat,'FT_amp','VT_amp','CT_amp'); |
| 904 | + case 'tf' |
| 905 | + |
| 906 | + saveName_mat=fullfile(saveFolder,[saveNameGeom_tf,'.mat']); |
| 907 | + save(saveName_mat,'FT_amp','VT_amp','CT_amp'); |
| 908 | + end |
929 | 909 | end |
930 | 910 |
|
931 | 911 | %% |
|
0 commit comments