AFNI Message Board

Dear AFNI users-

We are very pleased to announce that the new AFNI Message Board framework is up! Please join us at:

https://discuss.afni.nimh.nih.gov

Existing user accounts have been migrated, so returning users can login by requesting a password reset. New users can create accounts, as well, through a standard account creation process. Please note that these setup emails might initially go to spam folders (esp. for NIH users!), so please check those locations in the beginning.

The current Message Board discussion threads have been migrated to the new framework. The current Message Board will remain visible, but read-only, for a little while.

Sincerely, AFNI HQ

History of AFNI updates  

|
August 05, 2014 10:37AM
Hi,
I am getting the following message (below) when I use 3dICC.R. I've carefully checked my model.txt file (attached) to verify that I have even numbers of datasets from session 1 and session 2, so I'm not sure what has gone wrong. Files are in afni format, so that shouldn't be the problem.

Any suggestions would be helpful.
Thanks,
Matt

Error message:


> #!/usr/bin/env afni_run_R
> #Welcome to 3dICC.R, an AFNI IntraClass Correlation Package!
> #-----------------------------------------------------------
> #Version 0.0.1, Dec. 22, 2008
> #Author: Gang Chen (gangchen@mail.nih.gov)
> #Website: [afni.nimh.nih.gov]
> #SSCC/NIMH, National Institutes of Health, Bethesda MD 20892
> #-----------------------------------------------------------
>
> # Commannd line to run this script: 3dICC.R MyOutput & (R CMD BATCH 3dICC3.R MyOut &)
> # (Output is a file in which the running progress including
> # error messages will be stored)
>
> #varComp <- function(x) {
> # v<-as.numeric(VarCorr(x)[,1])
> # v<-as.numeric(na.omit(v))
> # v/sum(v)
> #}
>
> lineNum <- function(key, inFile) grep(key, readLines(inFile), ignore.case = TRUE)
>
> getInfo <- function(key, inFile) {
+ LN<-lineNum(key, inFile)
+ if (length(LN)>0) unlist(strsplit(unlist(scan(file=inFile, what= list(""),
+ skip=LN-1, strip.white=TRUE, nline=1)), "\\:"))[2] else NA
+ }
>
> band <- function(x, lo, hi) {ifelse((x<=hi)&(x>=lo), x, ifelse(x>hi, hi, lo))}
>
> system("rm -f .RData")
> source(file.path(Sys.getenv("AFNI_R_DIR"), "AFNIio.R"))
> #source(file.path(Sys.getenv("LME"), "AFNIio.R"))
>
> # Output filename: optional
> Out <- getInfo("Output", "model.txt")
Read 1 record
> if(is.na(Out)) {
+ print("No output file name provided: a suffix of TEST will be used...")
+ Out <- "TEST"
+ }
> OutFile <- paste(Out, "+orig", sep="")
>
> # MASK: optional
> mask <- getInfo("Mask", "model.txt")
Read 1 record
>
> # Line 4: model formula
> #ModelShape <- unlist(strsplit(unlist(scan(file="model.txt", what= list(""),
> # skip=3, strip.white=TRUE, nline=1)), "\\:"))[2]
> #number of factors
> #nF <- length(unique(unlist(strsplit(unlist(strsplit(ModelShape[[1]],
> #:q "\\*")), "\\+"))))
> #factors
> #terms <- unlist(strsplit(strsplit(ModelShape[[1]], "\\+")[[1]], "\\*"))
>
> #ModelForm <- as.formula(paste("Beta~", ModelShape))
>
> # number of Clusters: optional
> nNodes <- as.integer(getInfo("Clusters", "model.txt"))
Read 1 record
> if(is.na(nNodes)) nNodes<-1
>
> # header position (hp) defined by column name InputFile
> if(!is.na(LN<-lineNum("InputFile", "model.txt"))) {
+ Model <- read.table("model.txt", skip=LN-1, header=TRUE)
+ # More decent way to do this?
+ Model$Subj <- as.factor(Model$Subj)
+ Model$InputFile <- as.character(Model$InputFile)
+ } else {print("ERROR: No column named inputFile found!"); break}
>
> # Assume the last column is input files
> #FileCol <- length(colnames(Model))
> #FileCol <- dim(Model)[2]
>
> # Number of input files
> NoFile <- dim(Model[1])[1]
> # number of factors
> nFact <- dim(Model)[2]-1
> # factor names
> fNames <- colnames(Model)[which(colnames(Model) != "InputFile")]
>
> ModelForm <- paste("Beta~", fNames[1])
> if (nFact == 2 ) ModelForm <- paste(ModelForm,"+",fNames[2])
> if (nFact == 3 ) ModelForm <- paste(ModelForm,"+",fNames[2],"+",fNames[3],
+ "+",fNames[1],"*",fNames[2],"+",fNames[1],"*",fNames[3],"+",fNames[2],"*",fNames[3])
> ModelForm <- as.formula(ModelForm)
>
> # Read in the 1st input file so that we have the dimension information
> Data <- read.AFNI(Model[1, "InputFile"])
> dimx <- Data$dim[1]
> dimy <- Data$dim[2]
> dimz <- Data$dim[3]
>
> if (!is.na(mask)) Mask <- read.AFNI(mask)$brk
>
> if (length(grep('tlrc', Model[1, "InputFile"]))==1) outView <- "tlrc"
> if (length(grep('orig', Model[1, "InputFile"]))==1) outView <- "orig"
>
>
> # initialization
> IData <- array(data=NA, dim=c(dimx, dimy, dimz, NoFile))
>
> IData[,,,1] <- Data$brk
Error in IData[, , , 1] <- Data$brk :
number of items to replace is not a multiple of replacement length
Execution halted
Subject Author Posted

3dICC.R problems

Matthew Hoptman August 05, 2014 10:37AM

Re: 3dICC.R problems

gang August 05, 2014 01:07PM

Re: 3dICC.R problems

Matthew Hoptman August 06, 2014 09:22AM