fs=string(segm.Alias_ID); for i=1:size(fs,1); fs(i)=erase(fs(i)," "); end regionIds=segm.Region_Id(fs==patientID); nr=size(regionIds,1); vtemp=zeros(nr,3); %rotate to match convention below vtemp(:,3)=segm.X(fs==patientID); vtemp(:,2)=segm.Y(fs==patientID); vtemp(:,1)=segm.Z(fs==patientID); v0=vtemp; for j=1:nr v0(regionIds(j)+1,:)=vtemp(j,:); end