Skip to content

Commit cf2134d

Browse files
authored
Add files via upload
1 parent a38ea7c commit cf2134d

1 file changed

Lines changed: 83 additions & 34 deletions

File tree

mcode/processAmputation_vs1.m

Lines changed: 83 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
% This code requires the GIBBON MATLAB toolbox
1010
% <www.gibboncode.org>
1111

12+
%colors
13+
green = 1/255*[0, 100, 0];
1214
%% Control parameters
1315

1416
projectFolder = fileparts(fileparts(mfilename('fullpath')));
@@ -145,13 +147,15 @@
145147
%%
146148
% Visualization
147149

148-
cFigure; hold on;
149-
%title('Cut features');
150-
% gpatch(FT,VT,'w','none',0.1);
151-
gpatch(FT_amp,VT_amp,CT_amp,'none',0.5);
152-
axisGeom; axis off; camlight headlight;
153-
colormap gjet; %icolorbar;
154-
gdrawnow;
150+
% cFigure; hold on;
151+
% %title('Cut features');
152+
% % gpatch(FT,VT,'w','none',0.1);
153+
% gpatch(FT_amp,VT_amp,CT_amp,'none',0.5);
154+
% gpatch(FT{1},VT{1},'w','none',0.25);
155+
% plotV(V_bone_femur(I_min_femur,:),'k.','MarkerSize',100);
156+
% axisGeom; axis off; camlight headlight;
157+
% colormap gjet; %icolorbar;
158+
% gdrawnow;
155159

156160
%% Set up skin taper parameterisation
157161
switch select_amputation_case
@@ -175,14 +179,20 @@
175179
%Muscle
176180
Fm=FT_amp{6};
177181
Vm=VT_amp{6};
178-
end
182+
%Get cut bone end curve
183+
Ebt=patchBoundary(Ft,Vt);
184+
indBt=edgeListToCurve(Ebt);
185+
indBt=indBt(1:end-1);
186+
P_end_centroid=mean(Vt(indBt,:),1);
179187

180-
188+
end
189+
181190
%Get cut bone end curve
182191
Ebt=patchBoundary(Ft,Vt);
183192
indBt=edgeListToCurve(Ebt);
184193
indBt=indBt(1:end-1);
185194
P_end_centroid=mean(Vt(indBt,:),1);
195+
186196
%Skin
187197
D=Vs(:,3)-(min(Vs(:,3))+taperHeigth);
188198
D(D>0)=0;
@@ -191,7 +201,6 @@
191201
D=D.^2;
192202

193203
[Dp,indMin]=minDist(Vs(:,[1 2]),Vt(indBt,[1 2]));
194-
195204
Dp(Dp<=taperThreshold)=taperThreshold;
196205
Dp=Dp-min(Dp);
197206
Dp=Dp./max(Dp);
@@ -215,16 +224,20 @@
215224
VT_amp{5}=Vs;
216225
end
217226

227+
F_skin_ref=FT_amp{2};
228+
V_skin_ref=VT_amp{2};
218229
cFigure; hold on;
219-
title('taper morphing');
220-
gpatch(FT_amp,VT_amp,'w','none',0.5);
221-
% gpatch(Fs,Vs,'w','none',0.5);
230+
%title('taper morphing');
231+
gpatch(FT_amp{2},VT_amp{2},'w','none',0.5);
232+
%gpatch(FT_amp,VT_amp,'w','none',0.5);
233+
234+
%gpatch(Fs,Vs,'r','none',0.5);
222235
quiverVec(Vs1,R);
223236
colormap gjet; colorbar;
224-
axisGeom; camlight headlight;
237+
axisGeom; axis off; camlight headlight;
238+
set(gca,'FontSize',35);
225239
gdrawnow;
226240

227-
228241
%% Process skin distal end closure
229242
P_end=P_end_centroid-[0 0 distalExcess];
230243
Ebs=patchBoundary(Fs,Vs);
@@ -234,8 +247,9 @@
234247
% Visualization
235248

236249
cFigure; hold on;
237-
title('Distal end closure');
238-
gpatch(FT_amp,VT_amp,'w','none',1);
250+
%title('Distal end closure');
251+
%gpatch(FT_amp{2},VT_amp{2},'w','none',0.5);
252+
gpatch(FT_amp,VT_amp,'w','none',0.5);
239253
%gpatch(Fs,Vs,'w','none',0.25);
240254
hp=gpatch(Fsb,Vsb,Vsb(:,3),'none',1); hp.FaceColor='interp';
241255
% gpatch(Ebs,Vs,'none','b',1,3);
@@ -277,7 +291,6 @@
277291
CT_amp{5}=5*ones(size(Fs,1),1);
278292
end
279293

280-
281294
cFigure;
282295
subplot(1,2,1); hold on;
283296
% gpatch(FT,VT,'w','none',0.25);
@@ -290,6 +303,10 @@
290303
axisGeom; axis off; camlight headlight;
291304
gdrawnow;
292305

306+
% cFigure; hold on;
307+
% gpatch(FT_amp{2},VT_amp{2},'w','k',1);
308+
% axisGeom; axis off; camlight headlight;
309+
% gdrawnow;
293310

294311
%% Process muscle taper
295312
Dm=Vm(:,3)-(min(Vm(:,3))+taperHeigth);
@@ -324,11 +341,13 @@
324341
end
325342

326343
cFigure; hold on;
327-
title('taper morphing');
344+
%title('taper morphing');
345+
%gpatch(FT_amp{3},VT_amp{3},'w','none',0.5);
328346
gpatch(FT_amp,VT_amp,'w','none',0.5);
329347
quiverVec(Vm1,Rm);
330348
colormap gjet; colorbar;
331-
axisGeom; camlight headlight;
349+
axisGeom; axis off; camlight headlight;
350+
set(gca,'FontSize',35);
332351
gdrawnow;
333352

334353
%% Process muscle distal end closure
@@ -338,9 +357,10 @@
338357
%%
339358
% Visualization
340359
cFigure; hold on;
341-
title('Distal end closure');
360+
%title('Distal end closure');
361+
%gpatch(FT_amp{3},VT_amp{3},'w','none',0.25);
342362
gpatch(FT_amp,VT_amp,'w','none',0.25);
343-
gpatch(Fm,Vm,'w','none',1);
363+
gpatch(Fm,Vm,'w','none',0.5);
344364
hp=gpatch(Fmb,Vmb,Vmb(:,3),'none',1); hp.FaceColor='interp';
345365

346366
quiverVec(Vm(indBm,:),Nd(indBm,:),radiusEnd/4,'k');
@@ -353,7 +373,7 @@
353373
end
354374

355375
plotV(P_end,'k.','MarkerSize',25);
356-
376+
axis off;
357377
axisGeom; camlight headlight;
358378
gdrawnow;
359379

@@ -393,6 +413,14 @@
393413
axisGeom; axis off; camlight headlight;
394414
gdrawnow;
395415

416+
%
417+
% %
418+
% cFigure; hold on;
419+
% gpatch(FT_amp{3},VT_amp{3},'w','k',1);
420+
% axisGeom; axis off; camlight headlight;
421+
% gdrawnow;
422+
423+
396424
%% Process femur taper
397425
switch select_amputation_case
398426
case 'tf'
@@ -417,7 +445,7 @@
417445
%%
418446
% Visualization
419447
cFigure; hold on;
420-
gpatch(Ft,Vt,'w','none',0.25);
448+
gpatch(Ft,Vt,'w','none',0.5);
421449
gpatch(Ebs,Vt,'none','b',1,3);
422450
hp=gpatch(Fsb,Vsb,'w','k',1,1);
423451
% hp.FaceColor='interp';
@@ -431,7 +459,7 @@
431459
for q=1:size(XB,2)
432460
plotV([XB(:,q) YB(:,q) ZB(:,q)],'k.-','LineWidth',0.5,'MarkerSize',5);
433461
end
434-
462+
axis off;
435463
axisGeom; camlight headlight;
436464
gdrawnow;
437465

@@ -458,6 +486,12 @@
458486

459487
%%
460488

489+
% cFigure;hold on;
490+
% gpatch(Ft,Vt,'w','k',1);
491+
% axisGeom; axis off; camlight headlight;
492+
% gdrawnow;
493+
494+
461495
cFigure;
462496
subplot(1,2,1); hold on;
463497
% gpatch(FT,VT,'w','none',0.25);
@@ -476,7 +510,8 @@
476510
% gpatch(FT,VT,'w','none',0.25);
477511
gpatch(FT_amp,VT_amp,CT_amp,'none',0.5);
478512
axisGeom; axis off; camlight headlight;
479-
colormap gjet; %icolorbar;
513+
colormap gjet; icolorbar;
514+
set(gca,'FontSize',35);
480515
gdrawnow;
481516

482517
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -807,6 +842,9 @@
807842
colormap gjet; icolorbar;
808843
gdrawnow;
809844

845+
%Save original skin surface for socket design
846+
F_skin_original=FT_amp{2};
847+
V_skin_original=VT_amp{2};
810848
%Cut the top skin surface
811849
Fs=FT_amp{2};
812850
Vs=VT_amp{2};
@@ -851,14 +889,19 @@
851889

852890
%%
853891
cFigure;hold on;
854-
gpatch(Fc_skin,Vc_skin,'gw','k',1);
855-
gpatch(Fc_muscle,Vc_muscle,'rw','k',1);
856-
gpatch(Fsm,Vsm,'bw','k',0.6);
857-
plotV(Vc_skin(indBs_skin,:),'r-','LineWidth',4);
858-
plotV(Vc_muscle(indBs_muscle,:),'g-','LineWidth',4);
892+
gpatch(Fc_skin,Vc_skin,green,'none',0.5);
893+
gpatch(Fc_muscle,Vc_muscle,'rw','none',0.5);
894+
gpatch(Fsm,Vsm,'w','k',0.6);
895+
gpatch(Ftt,Vtt,'w','k',0.6);
896+
897+
898+
plotV(Vc_skin(indBs_skin,:),'k-','LineWidth',4);
899+
plotV(Vc_muscle(indBs_muscle,:),'r-','LineWidth',4);
900+
plotV(Vc_femur(indBs_femur,:),'b-','LineWidth',4);
901+
859902

860903
colormap gjet;
861-
axisGeom; camlight headlight;
904+
axisGeom; axis off;camlight headlight;
862905
gdrawnow;
863906

864907

@@ -874,11 +917,17 @@
874917
%%
875918
cFigure; hold on;
876919
gpatch(FT_amp,VT_amp,CT_amp,'none',0.5);
877-
patchNormPlot(FT_amp,VT_amp);
920+
%patchNormPlot(FT_amp,VT_amp);
878921
axisGeom; axis off; camlight headlight;
879-
colormap gjet; %icolorbar;
922+
colormap gjet; icolorbar;
880923
gdrawnow;
924+
881925

926+
927+
FT_amp{6}=F_skin_original;
928+
VT_amp{6}=V_skin_original;
929+
CT_amp{6}=6*ones(size(F_skin_original,1),1);
930+
882931
% stlwrite(triangulation(VT_amp{1},FT_amp{1}),fullfile(saveFolder_stl,'femur_tf.stl'),'binary');
883932
% stlwrite(triangulation(VT_amp{2},FT_amp{2}),fullfile(saveFolder_stl,'skin_tf.stl'),'binary');
884933
% stlwrite(triangulation(VT_amp{3},FT_amp{3}),fullfile(saveFolder_stl,'muscle_tf.stl'),'binary');

0 commit comments

Comments
 (0)