diff --git a/R/read_fs_mgh.R b/R/read_fs_mgh.R index d58edd4..84c2aae 100755 --- a/R/read_fs_mgh.R +++ b/R/read_fs_mgh.R @@ -94,7 +94,7 @@ read.fs.mgh <- function(filepath, is_gzipped = "AUTO", flatten = FALSE, with_hea header$internal$M = M; header$internal$Mdc = Mdc; - header$vox2ras_matrix = M; + header$vox2ras_matrix = as.matrix(M); header$ras_xform = ras_xform; RAS_space_size = (3*4 + 4*3*4); # 60 bytes diff --git a/R/write_fs_mgh.R b/R/write_fs_mgh.R index d17c865..f8cd64c 100644 --- a/R/write_fs_mgh.R +++ b/R/write_fs_mgh.R @@ -32,9 +32,12 @@ write.fs.mgh <- function(filepath, data, vox2ras_matrix = NULL, mr_params = c(0. if(length(vox2ras_matrix) == 0) { ras_flag = 0; } else { - if (class(vox2ras_matrix) != "matrix") { + if(class(vox2ras_matrix) != "matrix") { + cat(sprintf("The class of the 'vox2ras_matrix' argument is '%s'.", class(vox2ras_matrix))); + print(vox2ras_matrix); stop("The 'vox2ras_matrix' argument must be a matrix."); } + if(length(vox2ras_matrix) != 16 || nrow(vox2ras_matrix) != 4) { stop(sprintf("The 'vox2ras_matrix' argument must be a 4x4 matrix of length 16, but length is %d and nrow is %d.", length(vox2ras_matrix), nrow(vox2ras_matrix))); }