################################################################################ ############# transform the files in IMP files ################################# ################################################################################ IMP.transf=function (array.file,centroid.size=NA,centroid=F) { # if there is only one specimen the array become a matrix so make change accordingly test=is.matrix(array.file$coordinates) # numb of specimen if (test==T) n=1 else n=length(array.file$coordinates[1,1,]) # numb of dimension if (test==T) k=length(array.file$coordinates[1,]) else k=length(array.file$coordinates[1,,1]) # numb of landmarks if (test==T) p=length(array.file$coordinates[,1]) else p=length(array.file$coordinates[,1,1]) # create matrix coordinates=matrix(NA,n,k*p+1) # calculate total number of coordinate coord=p*k even=vector(length=(coord/2)) odd=vector(length=(coord/2)) for (i in 1:(coord/2)) { odd[i]=i*2-1 even[i]=i*2 } # fill the matrix if (test==T) { for (i in 1:n) { for (j in 1:p) { coordinates[i,odd]=array.file$coordinates[,1] coordinates[i,even]=array.file$coordinates[,2] } } } else { for (i in 1:n) { for (j in 1:p) { coordinates[i,odd]=array.file$coordinates[,1,i] coordinates[i,even]=array.file$coordinates[,2,i] } } } # add the centroid size at the end of the matrix if (centroid==T) coordinates[,k*p+1]=centroid.size else coordinates[,k*p+1]=array.file$scales coordinates }