Skip to content

Commit

Permalink
modified curve_srvf_align so that it returns rotations and gammas
Browse files Browse the repository at this point in the history
  • Loading branch information
Llosa committed May 10, 2023
1 parent 0b28687 commit 991c29c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions R/curve_srvf_align.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#' @references Srivastava, A., Klassen, E., Joshi, S., Jermyn, I., (2011). Shape analysis of elastic curves in euclidean spaces. Pattern Analysis and Machine Intelligence, IEEE Transactions on 33 (7), 1415-1428.
#' @export
#' @examples
#' out <- curve_srvf_align(beta[, , 1, 1:2], maxit = 2)
#' # note: use more shapes, small for speed
#' data("mpeg7")
#' out = curve_srvf_align(beta[,,1,1:2],maxit=2) # note: use more shapes, small for speed
curve_srvf_align <- function(beta, mode="O", rotated=T, scale = F, maxit=20, ms = "mean"){
if (mode=="C"){
isclosed = TRUE
Expand All @@ -35,22 +35,24 @@ curve_srvf_align <- function(beta, mode="O", rotated=T, scale = F, maxit=20, ms

qn = array(0, c(n,T1,N))
betan = array(0, c(n,T1,N))

rotmat = array(0, c(n,n,N)) # CL added
gams = matrix(0, T1, N) # CL added

Check warning on line 39 in R/curve_srvf_align.R

View check run for this annotation

Codecov / codecov/patch

R/curve_srvf_align.R#L38-L39

Added lines #L38 - L39 were not covered by tests

# align to mean
for (ii in 1:N){
q1 = q[,,ii]
beta1 = beta[,,ii]

out = find_rotation_seed_unqiue(mu,q1,mode)
gams[,ii] = out$gambest # CL added

Check warning on line 47 in R/curve_srvf_align.R

View check run for this annotation

Codecov / codecov/patch

R/curve_srvf_align.R#L47

Added line #L47 was not covered by tests
beta1 = out$Rbest%*%beta1
beta1n = group_action_by_gamma_coord(beta1, out$gambest)
q1n = curve_to_q(beta1n)$q

out = find_best_rotation(mu, q1n)
qn[,,ii] = out$q2new
betan[,,ii] = out$R%*%beta1n

rotmat[,,ii] = out$R # CL added

Check warning on line 55 in R/curve_srvf_align.R

View check run for this annotation

Codecov / codecov/patch

R/curve_srvf_align.R#L55

Added line #L55 was not covered by tests
}

return(list(betan=betan, qn=qn, betamean=betamean, q_mu=mu))
return(list(betan=betan, qn=qn, betamean=betamean, q_mu=mu, rotmat = rotmat,gams = gams,v=v))

Check warning on line 57 in R/curve_srvf_align.R

View check run for this annotation

Codecov / codecov/patch

R/curve_srvf_align.R#L57

Added line #L57 was not covered by tests
}

0 comments on commit 991c29c

Please sign in to comment.