当前位置: 首页>>代码示例>>C++>>正文


C++ Cube::ReadFile方法代码示例

本文整理汇总了C++中Cube::ReadFile方法的典型用法代码示例。如果您正苦于以下问题:C++ Cube::ReadFile方法的具体用法?C++ Cube::ReadFile怎么用?C++ Cube::ReadFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cube的用法示例。


在下文中一共展示了Cube::ReadFile方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: printf

int
Resample::UseCorner(const string &refname)
{
  Cube refcube;
  stringstream tmps;
  if (refcube.ReadFile(refname)) {
    Tes reftes;
    if (!(reftes.ReadFile(refname))) {
      refcube=reftes[0];
    }
    else {
      printf("*** resample: invalid reference file: %s\n",refname.c_str());
      return 501;       // panic and exit
    }
  }
  // first get the corner coordinates of both images
  tokenlist ourline,refline;
  ourline.ParseLine(mycube->GetHeader("AbsoluteCornerPosition:"));
  refline.ParseLine(refcube.GetHeader("AbsoluteCornerPosition:"));
  if (ourline.size()!=3) {
    tmps.str("");
    tmps << "resample: input image file doesn't have an absolute corner position tag";
    printErrorMsg(VB_ERROR,tmps.str());
    return 101;
  }
  if (refline.size()!=3) {
    tmps.str("");
    tmps << "resample: reference image file doesn't have an absolute corner position tag";
    printErrorMsg(VB_ERROR,tmps.str());
    return 101;
  }
  double ourpos[3],refpos[3];
  ourpos[0]=strtod(ourline[0]);
  ourpos[1]=strtod(ourline[1]);
  ourpos[2]=strtod(ourline[2]);
  refpos[0]=strtod(refline[0]);
  refpos[1]=strtod(refline[1]);
  refpos[2]=strtod(refline[2]);
  
  // find the start point
  x1=(refpos[0]-ourpos[0])/mycube->voxsize[0];
  y1=(refpos[1]-ourpos[1])/mycube->voxsize[1];
  z1=(refpos[2]-ourpos[2])/mycube->voxsize[2];
  // the sampling interval should provide for 4x resolution in-plane
  xstep=(refcube.voxsize[0]/4.0)/mycube->voxsize[0];
  ystep=(refcube.voxsize[1]/4.0)/mycube->voxsize[1];
  zstep=refcube.voxsize[2]/mycube->voxsize[2];
  // the number of voxels should be the width of the target image
  nx=refcube.dimx*4;
  ny=refcube.dimy*4;
  nz=refcube.dimz;
  return 0;
}
开发者ID:Ampelbein,项目名称:voxbo,代码行数:53,代码来源:resample.cpp

示例2:

void
Extractor::init(tokenlist &args)
{
  // defaults
  xvflag=0;
  newdim[0]=41;
  newdim[1]=51;
  newdim[2]=27;

  newcube.voxsize[0]=3.75;
  newcube.voxsize[1]=3.75;
  newcube.voxsize[2]=5.00;

  newcube.origin[0]=21;
  newcube.origin[1]=31;
  newcube.origin[2]=10;

  original.ReadFile(args[0]);

  if (args.size()==1)
    newcube.SetFileName((string)"m"+original.GetFileName());

  if (args.size()==2 || args.size()==3) {
    newcube.SetFileName(args[1]);
    if (args.size()==3) {
      xval=strtol(args[2]);
      xvflag=1;
    }
  }

  if (args.size()==11 || args.size()==12) {
    newcube.SetFileName(args[1]);
    newdim[0]=strtol(args[2]);
    newdim[1]=strtol(args[3]);
    newdim[2]=strtol(args[4]);
    
    newcube.voxsize[0]=strtod(args[5]);
    newcube.voxsize[1]=strtod(args[6]);
    newcube.voxsize[2]=strtod(args[7]);
    
    newcube.origin[0]=strtol(args[8]);
    newcube.origin[1]=strtol(args[9]);
    newcube.origin[2]=strtol(args[10]);
    if (args.size()==12) {
      xval=strtol(args[11]);
      xvflag=1;
    }
  }
  newcube.SetVolume(newdim[0],newdim[1],newdim[2],original.datatype);
}
开发者ID:kimberg,项目名称:voxbo,代码行数:50,代码来源:extractmask.cpp

示例3:

int
process_singlemask(vector<VBRegion> &rlist,string fname)
{
  Cube mask;
  if (mask.ReadFile(fname)) {
    return 101;
  }
  VBRegion reg;
  reg=findregion_mask(mask,vb_gt,0.0);
  reg.name=xfilename(fname);
  if (!(reg.voxels.size()))
    return 102;
  rlist.push_back(reg);
  return 0;
}
开发者ID:kimberg,项目名称:voxbo,代码行数:15,代码来源:sumrfx.cpp

示例4: printf

void
do_sumrfx(const string &fname,const string &mname,double thresh,vector<VBRegion> &rlist)
{
  int i,j,k;
  Tes rfx;
  Cube mask;

  rfx.ReadFile(fname);
  if (!rfx.data_valid) {
    printf("sumrfx: invalid 4D file %s.\n",fname.c_str());
    return;
  }
  // specified mask, intersect with tes mask
  if (mname.size()) {
    mask.ReadFile(mname);
    for (i=0; i<mask.dimx; i++)
      for (j=0; j<mask.dimy; j++)
	for (k=0; k<mask.dimz; k++)
	  if (rfx.GetMaskValue(i,j,k)<0.5)
	    mask.SetValue(i,j,k,0);
  }
  // default mask
  else {
    mask.SetVolume(rfx.dimx,rfx.dimy,rfx.dimz,vb_byte);
    for (i=0; i<mask.dimx; i++)
      for (j=0; j<mask.dimy; j++)
	for (k=0; k<mask.dimz; k++)
	  mask.SetValue(i,j,k,rfx.GetMaskValue(i,j,k));
  }
  if (!mask.data_valid) {
    printf("sumrfx: invalid mask file %s.\n",mname.c_str());
    return;
  }

  if (mask.dimx != rfx.dimx || mask.dimy != rfx.dimy || mask.dimz != rfx.dimz) {
    printf("sumrfx: mask and rfx volume dimensions don't match\n");
    return;
  }

  printf("sumrfx: thresh %.2f mask file: %s\n",thresh,mname.c_str());

  for (i=0; i<rfx.dimt; i++) {
    Cube mycube;
    rfx.getCube(i,mycube);
    if (!mycube.data_valid) continue;
    do_sumcube(rfx.GetFileName(),i,mycube,mask,thresh,rlist);
  }
}
开发者ID:kimberg,项目名称:voxbo,代码行数:48,代码来源:sumrfx.cpp

示例5:

int
Resample::SetAlign(const string mode,const string ref)
{
  Cube refcube;
  if (refcube.ReadFile(refname))
    return 100;
  if (mode=="-aa" || mode=="-ax") {
    if (ref=="origin")
      x1=(float)mycube->origin[0]-(((float)refcube.origin[0]*refcube.voxsize[0])/mycube->voxsize[0]);
  }
  if (mode=="-aa" || mode=="-ay") {
    if (ref=="origin")
      y1=(float)mycube->origin[1]-(((float)refcube.origin[1]*refcube.voxsize[1])/mycube->voxsize[1]);
  }
  if (mode=="-aa" || mode=="-az") {
    if (ref=="origin")
      z1=(float)mycube->origin[2]-(((float)refcube.origin[2]*refcube.voxsize[2])/mycube->voxsize[2]);
  }
  return 0;
}
开发者ID:Ampelbein,项目名称:voxbo,代码行数:20,代码来源:resample.cpp

示例6: if

int
VBri::openconfig(string configfile)
{
  ifstream infile;
  infile.open(configfile.c_str());
  if (!infile) {
    QMessageBox::critical(this,"Error","Couldn't open config file.");
    return 2;
  }
  chdir(xdirname(configfile).c_str());

  char buf[STRINGLEN];
  tokenlist args;
  while (infile.getline(buf,STRINGLEN,'\n')) {
    args.ParseLine(buf);
    if (args.size()==0) continue;
    if (args[0][0]=='#' || args[0][0] == ';')
      continue;
    if (args[0]=="image" && args.size()==3) {
      Cube cb;
      if (cb.ReadFile(args[2])) {
        QMessageBox::critical(this,"Error",(format("Couldn't open image %s")%args[2]).str().c_str());
        infile.close();
        return 3;
      }
      find_origin(cb);
      cubelist.push_back(cb);
      cubemap[args[1]]=--cubelist.end();
    }
    else if (args[0]=="left") {
      leftimg=args[1];
    }
    else if (args[0]=="right") {
      rightimg=args[1];
    }
    else if (args[0]=="mask") {
      VBmask vbm;
      vbm.imgname=args[1];
      if (args.size()>2) {
        vbm.rating=strtol(args[2]);
        vbm.xslice=strtol(args[3]);
        vbm.yslice=strtol(args[3]);
        vbm.zslice=strtol(args[3]);
        vbm.notes=args.Tail(4);
      }
      else if (cubemap.count(vbm.imgname)) {
        // FIXME get it from the header...
        vbm.xslice=cubemap[vbm.imgname]->origin[0];
        vbm.yslice=cubemap[vbm.imgname]->origin[1];
        vbm.zslice=cubemap[vbm.imgname]->origin[2];
      }
      masklist.push_back(vbm);
    }
    else if (args[0]=="outfile") {
      if (args.size()>1)
        outfile=args[1];
    }
    else if (args[0]=="randomize") {
      randomizemasks();
    }
    else {
      QMessageBox::critical(this,"Error",((string)"Bad config line: "+buf).c_str());
      infile.close();
      return 4;
    }
  }
  infile.close();
  return 0;
}
开发者ID:kimberg,项目名称:voxbo,代码行数:69,代码来源:vbri.cpp

示例7: if

int
main(int argc,char *argv[])
{
  tokenlist args;
  string maskfile;
  vector<string> filelist;

  args.Transfer(argc-1,argv+1);
  for (size_t i=0; i<args.size(); i++) {
    if (args[i]=="-m" && i<args.size()-1)
      maskfile=args[++i];
    else if (args[i]=="-h") {
      vbcmp_help();
      exit(0);
    }
    else if (args[i]=="-v") {
      vbcmp_version();
      exit(0);
    }
    else
      filelist.push_back(args[i]);
  }

  if (filelist.size() < 2) {
    vbcmp_help();
    exit(0);
  }
  Cube mask;
  if (maskfile.size()) {
    if (mask.ReadFile(maskfile)) {
      cout << format("[E] vbcmp: error reading mask file %s\n")%maskfile;
      exit(2);
    }
  }

  string spacer;
  if (filelist.size()>2) spacer="   ";
  for (size_t i=0; i<filelist.size(); i++) {
    for (size_t j=0; j<filelist.size(); j++) {
      if (i>=j) continue;
      if (filelist.size()>2)
        cout << format("[I] vbcmp: comparing %s and %s\n")%filelist[i]%filelist[j];
      int err1,err2;
      Cube cb1,cb2;
      err1=cb1.ReadFile(filelist[i]);
      err2=cb2.ReadFile(filelist[j]);
      if (!err1 && !err2) {
        cmp3d(cb1,cb2,mask,spacer);
        continue;
      }
      Tes ts1,ts2;
      err1=ts1.ReadFile(filelist[i]);
      err2=ts2.ReadFile(filelist[j]); 
      if (!err1 && !err2) {
        cmp4d(ts1,ts2,mask,spacer);
        continue;
      }
      // try vectors before matrices, because all vectors are matrices
      VB_Vector v1,v2;
      err1=v1.ReadFile(filelist[i]);
      err2=v2.ReadFile(filelist[j]);
      if (!err1 && !err2) {
        cmp1d(v1,v2,spacer);
        continue;
      }
      VBMatrix m1,m2;
      err1=m1.ReadFile(filelist[i]);
      err2=m2.ReadFile(filelist[j]);
      if (!err1 && !err2) {
        cmp2d(m1,m2,spacer);
        continue;
      }
      cout << format("[E] vbcmp: couldn't read %s and %s as same type\n")%filelist[i]%filelist[j];
    }
  }
  exit(100);
}
开发者ID:kimberg,项目名称:voxbo,代码行数:77,代码来源:vbcmp.cpp

示例8: if

int
main(int argc,char *argv[])
{
  if (argc<2) {
    vbcmap_help();
    exit(0);
  }

  tokenlist args;
  vector<string>filelist;
  string dvname,ivname,outfile,maskfile,pfile,pmapname;
  args.Transfer(argc-1,argv+1);
  int part=1,nparts=1;
  string perm_mat;
  int perm_index=-1;
  int minlesions=2;
  bool f_yates=0;
  bool f_fisher=0;
  bool f_zscore=0;
  bool f_flip=0;
  bool f_fdr=0;
  bool f_twotailed=0;
  bool f_nodup=0;
  float q=0;

  for (size_t i=0; i<args.size(); i++) {
    if (args[i]=="-v")
      vbcmap_version();
    else if (args[i]=="-h")
      vbcmap_help();
    else if (args[i]=="-2")
      f_twotailed=1;
    else if (args[i]=="-z")
      f_zscore=1;
    else if (args[i]=="-f")
      f_flip=1;
    else if (args[i]=="-x")
      f_fisher=1;
    else if (args[i]=="-y")
      f_yates=1;
    else if (args[i]=="-nodup")
      f_nodup=1;
    else if (args[i]=="-pfile" && i<args.size()-1) {
      pfile=args[++i];
    }
    else if (args[i]=="-pmap" && i<args.size()-1) {
      pmapname=args[++i];
    }
    else if (args[i]=="-m" && i<args.size()-1) {
      maskfile=args[++i];
    }
    else if (args[i]=="-q" && i<args.size()-1) {
      f_fdr=1;
      q=strtod(args[++i]);
    }
    else if (args[i]=="-n" && i<args.size()-1) {
      minlesions=strtol(args[++i]);
      if (minlesions<2) minlesions=2;
    }
    else if (args[i]=="-op" && i<args.size()-2) {
      perm_mat=args[++i];
      perm_index=strtol(args[++i]);
    }
    else if (args[i]=="-p" && i<args.size()-2) {
      part=strtol(args[++i]);
      nparts=strtol(args[++i]);
    }
    else
      filelist.push_back(args[i]);
  }
  if (filelist.size()!=3) {
    vbcmap_help();
    exit(112);
  }
  ivname=filelist[0];
  dvname=filelist[1];
  outfile=filelist[2];

  Cube tmap,mask;
  Tes ts;
  VB_Vector depvar;
  if (ts.ReadFile(ivname)) {
    printf("[E] vbcmap: couldn't get grouping info from %s\n",ivname.c_str());
    exit(101);
  }
  if (depvar.ReadFile(dvname)) {
    printf("[E] vbcmap: couldn't get dependent variable info from %s\n",dvname.c_str());
    exit(102);
  }
  // build our mask
  ts.ExtractMask(mask);

  if (maskfile.size()) {
    Cube tmask;
    if (tmask.ReadFile(maskfile)) {
      printf("[E] vbcmap: couldn't read mask file %s\n",maskfile.c_str());
      exit(103);
    }
    if (!(tmask.dimsequal(mask))) {
      printf("[E] vbcmap: lesion maps and mask files have inconsistent dimensions\n");
//.........这里部分代码省略.........
开发者ID:kimberg,项目名称:voxbo,代码行数:101,代码来源:vbxmap.cpp

示例9: if

int
VBSim::Go(int argc,char *argv[])
{
  tokenlist args;
  rng=NULL;
  dimx=0;
  dimy=0;
  dimz=0;
  dimt=0;
  n_mean=10.0;
  n_variance=5.0;
  n_fwhm=0.0;
  float vx=1.0;
  float vy=1.0;
  float vz=1.0;
  float vt=2000;
  uint32 rngseed=VBRandom();

  args.Transfer(argc,argv);

  if (args.size() == 0) {
    vbsim_help();
    exit(0);
  }

  for (size_t i=0; i<args.size(); i++) {
    // -d x y z for dims
    if (args[i]=="-d" && i<args.size()-4) {
      dimx=strtol(args[i+1]);
      dimy=strtol(args[i+2]);
      dimz=strtol(args[i+3]);
      dimt=strtol(args[i+4]);
      i+=4;
    }
    // -c for loading anatomy
    else if (args[i]=="-c" && i<args.size()-1) {
      anatname=args[i+1];
      i++;
    }
    // -z for voxel sizes
    else if (args[i]=="-z" && i<args.size()-3) {
      vx=strtod(args[++i]);
      vy=strtod(args[++i]);
      vz=strtod(args[++i]);
      vt=strtod(args[++i]);
    }
    // -n for per-volume noise
    else if (args[i]=="-n" && i<args.size()-3) {
      n_mean=strtod(args[i+1]);
      n_variance=strtod(args[i+2]);
      n_fwhm=strtod(args[i+3]);
      i+=3;
    }
    else if (args[i]=="-s" && i<args.size()-1)
      rngseed=strtol(args[++i]);
    else if (args[i]=="-o" && i<args.size()-1) {
      outfile=args[i+1];
      i++;
    }
    else {
      printf("[E] vbsim: unrecognized argument %s\n",args(i));
      return 140;
    }
  }
  if (dimx<1 || dimy<0 || dimz<0 || dimt<0) {
    printf("[E] vbsim: bad dimensions\n");
    return 110;
  }

  // initialize RNG
  rng=gsl_rng_alloc(gsl_rng_mt19937);
  assert(rng);
  gsl_rng_set(rng,rngseed);

  // FIXME tell the user here what we're doing

  // CREATE ANATOMY (constant image)
  if (anatname.size()) {
    if (anat.ReadFile(anatname)) {
      printf("[E] vbsim: couldn't read %s\n",anatname.c_str());
      return 101;
    }
    if (anat.dimx!=dimx || anat.dimy!=dimy || anat.dimz != dimz) {
      printf("[E] vbsim: %s doesn't match your dimensions\n",anatname.c_str());
      return 102;
    }
  }
  else {
    // create volume according to dimensions, add random noise if requested
    anat.SetVolume(dimx,dimy,dimz,vb_float);
  }

  // SPECIAL CASE-- vecs if dimy=dimz=dimt==0
  if (dimt==0 && dimy==0 && dimz==0) {
    printf("[I] vbsim: creating a vector with %d elements with N(%g,%g)\n",dimx,
           n_mean,sqrt(n_variance));
    if (outfile=="")
      outfile="data.ref";
    VB_Vector vv(dimx);
    
//.........这里部分代码省略.........
开发者ID:kimberg,项目名称:voxbo,代码行数:101,代码来源:vbsim.cpp

示例10: if

int
main(int argc,char *argv[])
{
  if (argc==1) {
    vbconv_help();
    exit(0);
  }
  tokenlist args;
  string outfile;
  int floatflag=0,nanflag=0,extractflag=0;
  set<int> includeset,excludeset;
  list<string> filelist;
  VBFF nullff;

  args.Transfer(argc-1,argv+1);
  for (size_t i=0; i<args.size(); i++) {
    if (args[i]=="-f")
      floatflag=1;
    else if (args[i]=="-n")
      nanflag=1;
    else if (args[i]=="-i" && i<args.size()-1) {
      includeset=numberset(args[++i]);
      if (includeset.empty()) {
        cout << "[E] vbconv: invalid inclusion range specified with -i\n";
        exit(111);
      }
    }
    else if (args[i]=="-e" && i<args.size()-1) {
      excludeset=numberset(args[++i]);
      if (excludeset.empty()) {
        cout << "[E] vbconv: invalid exclusion range specified with -e\n";
        exit(111);
      }
    }
    else if (args[i]=="-x" && i<args.size()-1)
      extractflag=1;
    else if (args[i]=="-v") {
      vbconv_version();
      exit(0);
    }
    else if (args[i]=="-h") {
      vbconv_help();
      exit(0);
    }
    else if (args[i]=="-o" && i<args.size()-1)
      outfile=args[++i];
    else {
      filelist.push_back(args[i]);
    }
  }

  if (filelist.size()<1) {
    printf("[E] vbconv: requires at least one input file\n");
    exit(10);
  }
  // if there's no -o flag and exactly two files specified, convert
  // the first to the second
  if (filelist.size()==2 && outfile.size()==0) {
    outfile=filelist.back();
    filelist.pop_back();
  }
  if (outfile.size()==0) {
    printf("[E] vbconv: requires an output filename be provided\n");
    exit(11);
  }

  // multiple files, must be 3D/4D combination
  if (filelist.size()>1) {
    Tes newtes;
    ConvertMultiple(filelist,nanflag,floatflag,newtes);
    if (WriteTes(newtes,outfile,extractflag,floatflag,nanflag,includeset,excludeset))
      exit(223);
    exit(0);  // just in case
  }
  int err;
  // just one file, see what kind
  Cube cb;
  if (cb.ReadFile(filelist.front())==0) {
    cb.fileformat=nullff;
    if (floatflag && cb.datatype!=vb_float)
      cb.convert_type(vb_float);
    if (nanflag)
      cb.removenans();
    if ((err=cb.WriteFile(outfile))) {
      printf("[E] vbconv: error %d writing %s\n",err,outfile.c_str());
      exit(4);
    }
    else {
      printf("[I] vbconv: wrote cube %s\n",outfile.c_str());
      exit(0);
    }
  }
  Tes ts;
  if (ts.ReadFile(filelist.front())==0) {
    ts.fileformat=nullff;
    if ((err=WriteTes(ts,outfile,extractflag,floatflag,nanflag,includeset,excludeset))) {
      printf("[E] vbconv: error %d writing %s\n",err,outfile.c_str());
      exit(4);
    }
    else {
//.........这里部分代码省略.........
开发者ID:kimberg,项目名称:voxbo,代码行数:101,代码来源:vbconv.cpp

示例11: if

int
RenderMe::Go(tokenlist &args)
{
  if (!args.size()) {
    help();
    return 102;
  }
  for (int i=0; i<args.size(); i++) {
    if (args[i]=="-m" && i+1 < args.size()) {
      maskname=args[i+1];
      i++;
    }
    else if (args[i]=="-d" && i+1 < args.size()) {
      overlayname=args[i+1];
      i++;
    }
    else if (args[i]=="-o" && i+1 < args.size()) {
      outfilename=args[i+1];
      i++;
    }
    else if (args[i]=="-a" && i+1 < args.size()) {
      anatomyname=args[i+1];
      i++;
    }
    else if (args[i]=="-1") {
      vbr.twotailed=0;
    }
    else if (args[i]=="-t" && i+2 < args.size()) {
      vbr.low=strtod(args[i+1]);
      vbr.high=strtod(args[i+2]);
      i+=2;
    }
  }

  if (outfilename.size() && !anatomyname.size() && !overlayname.size()) {
    help();
    return 101;
  }

  char tmp[STRINGLEN];

  if (anatomyname.size()) {
    anatomy.ReadFile(anatomyname);
    if (!anatomy.data_valid){
      sprintf(tmp,"vbrender: anatomy file %s not valid",anatomyname.c_str());
      printErrorMsg(VB_ERROR,tmp);
      return 102;
    }
    vbr.anatomy=&anatomy;
  }

  if (overlayname.size()) {
    overlay.ReadFile(overlayname);
    if (!overlay.data_valid){
      sprintf(tmp,"vbrender: statistical overlay file %s not valid",overlayname.c_str());
      printErrorMsg(VB_ERROR,tmp);
      return 102;
    }
    vbr.overlay=&overlay;
  }

  if (maskname.size()) {
    mask.ReadFile(maskname);
    if (!mask.data_valid){
      sprintf(tmp,"vbrender: mask file %s not valid",maskname.c_str());
      printErrorMsg(VB_ERROR,tmp);
      return 102;
    }
    vbr.mask=&mask;
  }

  QImage im;
  if (vbr.RenderSlices())
    return 103;
  if (vbr.SavePNG(outfilename))
    return 103;
  return 0;
}
开发者ID:kimberg,项目名称:voxbo,代码行数:78,代码来源:vbrender.cpp


注:本文中的Cube::ReadFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。