tests/testthat/helper01.R

# helper functions for testing
require("oro.nifti")
simulateVol=function(dim=20, data=rnorm(dim*dim*dim))
{
  vol=array(data, dim=c(dim,dim,dim))
  return(vol)
}

createTestVol=function(num=1, tag="A")
{
  set.seed(1986)
  if (num==1)
  {
    dim=20
    vol=simulateVol(dim)
    mask=simulateVol(dim, 1)
    ret=ptfce(img = vol, V=20*20*20, Rd = 20, mask = mask, Nh=50)
    writeNIfTI(vol, "data/test01A_in")
    writeNIfTI(ret$pTFCE, "data/test01A_out")
    writeNIfTI(mask, "data/test01A_mask")

    write(paste(date(), "Test", num),file="data/generated.test.data.log",append=TRUE)
  }
  else
  {
    warning("No such test case!")
  }

}


loadTestVol=function(num, tag="A", inout="in")
{
  readNIfTI(paste("data/test", sprintf("%.2d", num), tag, "_", inout, ".nii.gz" , sep=""))
}
spisakt/pTFCE documentation built on Aug. 22, 2023, 7:42 p.m.