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


C++ Image::BackgroundCorrect方法代码示例

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


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

示例1: assert

void BFReference::CalcSignalReference2(const std::string &datFile, const std::string &bgFile,
				      Mask &mask, int traceFrame) {
  Image bfImg;
  Image bfBkgImg;
  bfImg.SetImgLoadImmediate (false);
  bfBkgImg.SetImgLoadImmediate (false);
  bool loaded = bfImg.LoadRaw(datFile.c_str());
  bool bgLoaded = bfBkgImg.LoadRaw(bgFile.c_str());
  if (!loaded) {
    ION_ABORT("*Error* - No beadfind file found, did beadfind run? are files transferred?  (" + datFile + ")");
  }
  if (!bgLoaded) {
    ION_ABORT("*Error* - No beadfind background file found, did beadfind run? are files transferred?  (" + bgFile + ")");
  }
  const RawImage *raw = bfImg.GetImage();
  
  assert(raw->cols == GetNumCol());
  assert(raw->rows == GetNumRow());
  assert(raw->cols == mask.W());
  assert(raw->rows == mask.H());
  int StartFrame = bfImg.GetFrame(-663); //5
  int EndFrame = bfImg.GetFrame(350); //20
  int NNinnerx = 1, NNinnery = 1, NNouterx = 12, NNoutery = 8;
  cout << "DC start frame: " << StartFrame << " end frame: " << EndFrame << endl;
  bfImg.FilterForPinned(&mask, MaskEmpty, false);
  bfImg.XTChannelCorrect();
  // bfImg.XTChannelCorrect(&mask);
  Traces trace;  
  trace.Init(&bfImg, &mask, FRAMEZERO, FRAMELAST, FIRSTDCFRAME,LASTDCFRAME);
  bfImg.Normalize(StartFrame, EndFrame);
  if (mDoRegionalBgSub) {
     trace.SetMeshDist(0);
  }
  trace.CalcT0(true);
  if (mDoRegionalBgSub) {
    GridMesh<float> grid;
    grid.Init(raw->rows, raw->cols, mRegionYSize, mRegionXSize);
    int numBin = grid.GetNumBin();
    int rowStart = -1, rowEnd = -1, colStart = -1, colEnd = -1;
    for (int binIx = 0; binIx < numBin; binIx++) {
      cout << "BG Subtract Region: " << binIx << endl;
      grid.GetBinCoords(binIx, rowStart, rowEnd, colStart, colEnd);
      Region reg;
      reg.row = rowStart;
      reg.h = rowEnd - rowStart;
      reg.col = colStart;
      reg.w = colEnd - colStart;
      bfImg.BackgroundCorrectRegion(&mask, reg, MaskAll, MaskEmpty, NNinnerx, NNinnery, NNouterx, NNoutery, NULL);
    }
  }
  else {
    bfImg.BackgroundCorrect(&mask, MaskEmpty, MaskEmpty, NNinnerx, NNinnery, NNouterx, NNoutery, NULL);
  }
  int length = GetNumRow() * GetNumCol();
  mBfMetric.resize(length, std::numeric_limits<double>::signaling_NaN());
  for (int wIx = 0; wIx < length; wIx++) {
    if (mask[wIx] & MaskExclude || mask[wIx] & MaskPinned) 
      continue;
    int t0 = (int)trace.GetT0(wIx);
    mBfMetric[wIx] = 0;
    float zSum  = 0;
    int count = 0;
    for (int fIx = min(t0-20, 0); fIx < t0-10; fIx++) {
      zSum += bfImg.At(wIx,fIx);
      count ++;
    }
    for (int fIx = t0+3; fIx < t0+15; fIx++) {
      mBfMetric[wIx] += (bfImg.At(wIx,fIx) - (zSum / count));
    }
  }
  bfImg.Close();
  for (int i = 0; i < length; i++) {
    if (mask[i] & MaskExclude || mWells[i] == Exclude) {
      mWells[i] = Exclude;
    }
    else {
      mask[i] = MaskIgnore;
    }
  }
  cout << "Filling reference. " << endl;
  FillInReference(mWells, mBfMetric, mGrid, mMinQuantile, mMaxQuantile, mNumEmptiesPerRegion);
  for (int i = 0; i < length; i++) {
    if (mWells[i] == Reference) {
      mask[i] = MaskEmpty;
    }
  }
}
开发者ID:golharam,项目名称:TS,代码行数:87,代码来源:BFReference.cpp

示例2: main

int main(int argc, char *argv[])
{
	int numCycles = 2;//int numCycles = 25;
	int numFlows = numCycles*4;
	int numFrames = 100;
	int hasWashFlow = 1;

    int n; // number of elements read

	// inputs:
	//    beadmask
	//    ignore mask
	//    target mask
	//    weka vector

	// for each flow:
	// X.  memmap acq file
	// 1.  save raw traces for each target bead
	// 2.  calc and save nsub trace for each target bead

	// for each target bead:
	// X.  write out all raw traces for all flows
	// 1.  write out (raw - nsub) for all flows
	// 2.  write out (raw - nsub) - (0-mer[nuc] - nsub) for all flows
	// 3.  write out weka*(raw - nsub) for all flows

	// char *beadMaskName = "Beads300x300";
	// char *targetMaskName = "Golden";
	// char *wekaVector = NULL;
	char *coordFile = "/home/ion/JD1114.blastn.coords";

	// set a few defaults
	char *dirExt = ".";

	// process cmd line args
	int argcc = 1;
	while (argcc < argc) {
		switch (argv[argcc][1]) {
			case 'd': // directory to pull raw data from
				argcc++;
				dirExt = argv[argcc];
			break;

			case 'f': // coord file
				argcc++;
				coordFile = argv[argcc];
			break;
		}
		argcc++;
	}

        // crazy, but only way to get rows/cols right now is from mask.
        Mask mask(1,1);
	char maskPath[MAX_PATH_LENGTH];
	sprintf(maskPath, "%s/bfmask.bin", dirExt);
        // mask.SetMask(maskPath);
        mask.SetMask("/results/analysis/output/IonEast/Flux_v.029_VZ_069/bfmask.bin");

	// for each flow, make an avg trace from all row/col's requested

	int flow;
	char acqFileName[MAX_PATH_LENGTH];
	char *acqPrefix = "acq_";
	Image   img;
	img.SetMaxFrames(numFrames);
	int frame;
	double beadTrace[numFlows][numFrames];
	memset(beadTrace, 0, sizeof(beadTrace));
	for(flow=0;flow<numFlows;flow++) {
		Mask localMask(&mask);
		sprintf(acqFileName, "%s/%s%04d.dat", dirExt, acqPrefix, (flow + (flow/4)*hasWashFlow));
		img.LoadRaw(acqFileName);
		img.FilterForPinned(&localMask, MaskEmpty);
		img.Normalize(0, 5);
		img.BackgroundCorrect(&localMask, MaskBead, MaskEmpty, 2, 5, NULL);
		//img.BackgroundCorrectMulti(&localMask, MaskBead, MaskEmpty, 2, 5, NULL);

		const RawImage *raw = img.GetImage();
		int frameStride = raw->rows*raw->cols;

		// FILE *fp = fopen("/home/ion/aligReadsPlusCords", "r");
		FILE *fp = fopen(coordFile, "r");
		char line[512];
		int row, col;
		int count = 0;
		while(fgets(line, sizeof(line), fp) != NULL) {
			n = sscanf(line, "%d %d", &row, &col);
            assert(n==2);
			count++;
			for(frame=0;frame<numFrames;frame++) {
				beadTrace[flow][frame] += raw->image[col+row*raw->cols+frame*frameStride];
			}
		}
		fclose(fp);
		for(frame=0;frame<numFrames;frame++) {
			beadTrace[flow][frame] /= count;
		}
	}

	// now dump the avg traces
//.........这里部分代码省略.........
开发者ID:Jorges1000,项目名称:TS,代码行数:101,代码来源:GetTraces.cpp

示例3: CalcReference

void BFReference::CalcReference(const std::string &datFile, Mask &mask, std::vector<float> &metric) {
  Image bfImg;
  bfImg.SetImgLoadImmediate (false);
  bool loaded = bfImg.LoadRaw(datFile.c_str());
  if (!loaded) {
    ION_ABORT("*Error* - No beadfind file found, did beadfind run? are files transferred?  (" + datFile + ")");
  }

  const RawImage *raw = bfImg.GetImage();
  
  assert(raw->cols == GetNumCol());
  assert(raw->rows == GetNumRow());
  assert(raw->cols == mask.W());
  assert(raw->rows == mask.H());
  if (!mDebugFile.empty()) {
    DebugTraces(mDebugFile, mask, bfImg);
  }
  bfImg.FilterForPinned(&mask, MaskEmpty, false);
  // int StartFrame= bfImg.GetFrame((GetDcStart()*1000/15)-1000);
  // int EndFrame = bfImg.GetFrame((GetDcEnd()*1000/15)-1000);
  int StartFrame = bfImg.GetFrame(-663); //5
  int EndFrame = bfImg.GetFrame(350); //20
  cout << "DC start frame: " << StartFrame << " end frame: " << EndFrame << endl;
  bfImg.XTChannelCorrect();
  FilterForOutliers(bfImg, mask, mIqrOutlierMult, mRegionYSize, mRegionXSize);
  bfImg.Normalize(StartFrame, EndFrame);
  // bfImg.XTChannelCorrect(&mask);

  int NNinnerx = 1, NNinnery = 1, NNouterx = 12, NNoutery = 8;
  if (mDoRegionalBgSub) {
    GridMesh<float> grid;
    grid.Init(raw->rows, raw->cols, mRegionYSize, mRegionXSize);
    int numBin = grid.GetNumBin();
    int rowStart = -1, rowEnd = -1, colStart = -1, colEnd = -1;
    for (int binIx = 0; binIx < numBin; binIx++) {
      grid.GetBinCoords(binIx, rowStart, rowEnd, colStart, colEnd);
      Region reg;
      reg.row = rowStart;
      reg.h = rowEnd - rowStart;
      reg.col = colStart;
      reg.w = colEnd - colStart;
      bfImg.BackgroundCorrectRegion(&mask, reg, MaskAll, MaskEmpty, NNinnerx, NNinnery, NNouterx, NNoutery, NULL);
    }
  }
  else {
    bfImg.BackgroundCorrect(&mask, MaskEmpty, MaskEmpty, NNinnerx, NNinnery, NNouterx, NNoutery, NULL);
  }
  Region region;
  region.col = 0;
  region.row = 0;
  region.w = GetNumCol(); //mGrid.GetColStep();
  region.h = GetNumRow(); // mGrid.GetRowStep();

  int startFrame = bfImg.GetFrame(12); // frame 15 on uncompressed 314
  //  int endFrame = bfImg.GetFrame(raw->timestamps[bfImg.Ge]5300); // frame 77 or so
  int endFrame = bfImg.GetFrame(5000); // frame 77 or so
  bfImg.CalcBeadfindMetric_1(&mask, region, "pre", startFrame, endFrame);
  const double *results = bfImg.GetResults();

  int length = GetNumRow() * GetNumCol();
  metric.resize(length);
  copy(&results[0], &results[0] + (length), metric.begin());
  bfImg.Close();
}
开发者ID:golharam,项目名称:TS,代码行数:64,代码来源:BFReference.cpp


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