Open gdevenyi opened 5 years ago
Above code fails when labels have same left and right label value When labels$Structure[i] is referenced on line 9 it needs to be converted to a character string. Updated function below:
anatCreateVolume2 <- function (anat, column = 1)
{
labels <- read.csv(attr(anat, "definitions"))
volume <- mincGetVolume(attr(anat, "atlas"))
newvolume <- volume
for (i in 1:nrow(labels)) {
if (labels$right.label[i] == labels$left.label[i] ) {
newvolume[volume < labels$right.label[i] + 0.5 & volume >
labels$right.label[i] - 0.5] <- anat[as.character(labels$Structure[i]),
column]
} else {
newvolume[volume < labels$right.label[i] + 0.5 & volume >
labels$right.label[i] - 0.5] <- anat[paste0("right ",labels$Structure[i]),
column]
newvolume[volume < labels$left.label[i] + 0.5 & volume >
labels$left.label[i] - 0.5] <- anat[paste0("left ",labels$Structure[i]),
column]
}
}
return(invisible(mincArray(newvolume)))
}
Right, the label set I used had all unique numbers so we didn't have this issue.
Fixed the function up with this: