Beispiel #1
0
void BkgTrace::GenerateAllBeadTrace (Region *region, BeadTracker &my_beads, SynchDat &chunk, int iFlowBuffer, bool matchSdat)
{
  //  ION_ASSERT(chunk.NumFrames(my_beads.params_nn[0].x,my_beads.params_nn[0].y) >= (size_t)time_cp->npts(), "Wrong data points.");
  ION_ASSERT(chunk.NumFrames(region->row, region->col) >= (size_t)time_cp->npts(), "Wrong data points.");
    for (int nbd = 0;nbd < my_beads.numLBeads;nbd++) // is this the right iterator here?
      {
        int rx = my_beads.params_nn[nbd].x;  // should x,y be stored with traces instead?
        int ry = my_beads.params_nn[nbd].y;

        FG_BUFFER_TYPE *fg = &fg_buffers[bead_flow_t*nbd+time_cp->npts()*iFlowBuffer];
        if (matchSdat) {
	  for (int i = 0; i < time_cp->npts(); i++) {
	    fg[i] = chunk.At(ry + region->row, rx + region->col, i);
	  }
	}
	else {
	  std::vector<float> tmp(time_cp->npts(), 0);
	  chunk.InterpolatedAt(ry + region->row, rx + region->col, time_cp->mTimePoints, tmp);
	  for (int i = 0; i < time_cp->npts(); i++) {
	    fg[i] = tmp[i];
	  }
	}
        float offset = BkgTrace::ComputeDcOffset(fg, *time_cp, 0.0f, time_cp->t0-2);
        for (int i = 0; i < time_cp->npts(); i++) {
          fg[i] = round(fg[i] - offset);
        }
    }
    KeepEmptyScale(region, my_beads,chunk, iFlowBuffer);
}
Beispiel #2
0
void ImageSpecClass::ReadFirstImage(Image &img, SystemContext &sys_context, ImageControlOpts &img_control, SpatialContext &loc_context )
{
  img.SetImgLoadImmediate ( false );
  img.SetNumAcqFiles ( 1 );
  img.SetIgnoreChecksumErrors ( img_control.ignoreChecksumErrors );
  bool datIsSdat = false;
  char *firstAcqFile = ( char * ) malloc ( strlen ( sys_context.dat_source_directory ) + strlen (
                         img_control.acqPrefix ) + 10 );
  sprintf ( firstAcqFile, "%s/%s%04d.dat", sys_context.dat_source_directory, img_control.acqPrefix, 0 );
  /* Check to see if our dat file is really an sdat file in disguise, if so updat our suffix and doing sdats. */
  if (H5File::IsH5File(firstAcqFile)) {
    datIsSdat = true;
    img_control.sdatSuffix = "dat";
    img_control.doSdat = true;
  }
  char *firstSdatAcqFile = ( char * ) malloc ( strlen ( sys_context.dat_source_directory ) + strlen (
                         img_control.acqPrefix ) + 11 );
  sprintf ( firstSdatAcqFile, "%s/%s%04d.%s", sys_context.dat_source_directory, img_control.acqPrefix, 0, img_control.sdatSuffix.c_str() );

  if (isFile(firstAcqFile) && !datIsSdat) {
    if ( !img.LoadRaw ( firstAcqFile, 0, true, false ) )
      {
        exit ( EXIT_FAILURE );
      }
  }
  else if(isFile(firstSdatAcqFile)) {
    TraceChunkSerializer reader;
    SynchDat sdat;
    reader.Read(firstSdatAcqFile, sdat);
    img.InitFromSdat(&sdat);
    if (loc_context.regionXSize == 0){ // not explicitly set, set now
      loc_context.regionXSize = sdat.GetColStep();
      loc_context.regionYSize = sdat.GetRowStep();
    }
    if ((sdat.GetColStep() != (size_t)loc_context.regionXSize) ||
	(sdat.GetRowStep() != (size_t)loc_context.regionYSize)) {
      fprintf(stdout, "Warning: Analysis region sizes width=%d, height=%d do not match sdat region sizes width=%d, height=%d\n", loc_context.regionXSize, loc_context.regionYSize, (int)sdat.GetColStep(), (int)sdat.GetRowStep());
    }
  }
  else {
    exit ( EXIT_FAILURE );
  }
  img.SetOffsetFromChipOrigin ( firstAcqFile );
  free ( firstAcqFile );
  free ( firstSdatAcqFile );

  if ( !loc_context.IsSetRegionXYSize() ){ // not yet set, has to be set now
    loc_context.SetRegionXYSize(50, 50);
  }

  img.SetDir ( sys_context.results_folder );
  img.SetFlowOffset ( img_control.flowTimeOffset );
}
Beispiel #3
0
void RegionalizedData::UpdateTracesFromImage (SynchDat &chunk, int flow)
{
  ION_ASSERT(my_trace.time_cp->npts() <= (int)chunk.NumFrames(region->row, region->col), "Wrong number of frames.")
  my_trace.SetRawTrace(); // buffers treated as raw traces
  // populate bead traces from image file, just filling in data already saved
  my_trace.GenerateAllBeadTrace (region,my_beads,chunk, my_flow.flowBufferWritePos, regionAndTimingMatchSdat);

  // calculate average trace across all empty wells in a region for a flow
  // to FileLoadWorker at Image load time, should be able to go here
  emptytrace = emptyTraceTracker->GetEmptyTrace (*region);

  // sanity check images are what we think
  assert ( emptytrace->imgFrames == (int)chunk.NumFrames(region->row, region->col));
}
Beispiel #4
0
bool TraceChunkSerializer::Write(const char *filename, SynchDat &data) {
  data.mInfo.SetValue(SYNCHDATSERIALIZE_VERSION_KEY, SYNCHDATSERIALIZE_VERSION_VALUE);
  int numEntries = data.mInfo.GetCount();
  vector<string> keys(numEntries);
  vector<string> values(numEntries);
  vector<const char *> keysBuff(numEntries);
  vector<const char *> valuesBuff(numEntries);
  for (int i = 0; i < numEntries; i++) {
    data.mInfo.GetEntry(i, keys[i], values[i]);
    keysBuff[i] = keys[i].c_str();
    valuesBuff[i] = values[i].c_str();
  }
  ClockTimer timer;
  H5File h5(filename);
  bool ok = h5.OpenNew();
  openMicroSec = timer.GetMicroSec();
  if (!ok) { return ok; }
  timer.StartTimer();
  h5.WriteStringVector(INFO_KEYS, &keysBuff[0], keysBuff.size());
  h5.WriteStringVector(INFO_VALUES, &valuesBuff[0], keysBuff.size());
  ioMicroSec = timer.GetMicroSec();
  ok =  Write(h5, data.GetMesh());
  timer.StartTimer();
  h5.Close();
  H5garbage_collect();
  ioMicroSec += timer.GetMicroSec();
  return ok;
}
Beispiel #5
0
 void AddMetaData(SynchDat &sdat, const RawImage *raw, int acqNum) {
   string s = ToStr(raw->timestamps[0]);
   for (int i = 1; i < raw->frames; i++) {
     s = s + "," + ToStr(raw->timestamps[i]);
   }
   sdat.SetValue("x_block", "0");
   sdat.SetValue("y_block", "0");
   sdat.SetValue("base_frame_rate","66");
   sdat.SetValue("experiment_name","unknown");
   sdat.SetValue("machine_name", "dat");
   sdat.SetValue("serial_number","0");
   sdat.SetValue("oversampling", "0");
   sdat.SetValue("overclocking", "0");
   sdat.SetValue("overclocking", "0");
   sdat.SetValue("acq_num", ToStr(acqNum+1));  // +1 as dats are 0 based and acqs are 1 based
   sdat.SetValue("orig_timestamps", ToStr(s));
   sdat.SetValue("uncompressed_frames", ToStr(raw->uncompFrames));
 }
Beispiel #6
0
bool TraceChunkSerializer::Read(const char *filename, SynchDat &data) {
  data.Clear();
  if (!H5File::IsH5File(filename)) {
    return false;
  }
  bool result = true;
  try {
    if (!mRecklessAbandon) {
      uint32_t waitTime = mRetryInterval;
      int32_t timeOut = mTotalTimeout;
      //--- Wait up to 3600 seconds for a file to be available
      while ( timeOut > 0 )
        {
          //--- Is the file we want available?
          if ( Image::ReadyToLoad ( filename ) ) {
            break;
          }
          //DEBUG
          fprintf ( stdout, "Waiting to load %s\n", filename );
          sleep ( waitTime );
          timeOut -= waitTime;
        }
    }
    /* Turn off error printing as we're not sure this is actually an hdf5 file. */
    H5File h5(filename);
    result = h5.OpenForReading();

    if (result) {
      h5.SetReadOnly(true);
      result &= Read(h5, data.GetMesh());
      ReadInfo(h5, data);
    }
    h5.Close();
  }
  catch (...) {
    result = false;
  }
  return result;
}
Beispiel #7
0
void RegionalizedData::UpdateTracesFromImage (SynchDat &chunk, FlowBufferInfo &my_flow, int flow, int flow_block_size)
{
  ION_ASSERT(my_trace.time_cp->npts() <= (int)chunk.NumFrames(region->row, region->col), "Wrong number of frames.")
  my_trace.SetRawTrace(); // buffers treated as raw traces
  // populate bead traces from image file, just filling in data already saved
  my_trace.GenerateAllBeadTrace (region,my_beads,chunk, my_flow.flowBufferWritePos, regionAndTimingMatchSdat, flow_block_size);
  float t_mid_nuc =  GetTypicalMidNucTime (&my_regions.rp.nuc_shape);
  float t_offset_beads = my_regions.rp.nuc_shape.sigma;
  my_trace.RezeroBeads(time_c.time_start, t_mid_nuc-t_offset_beads, my_flow.flowBufferWritePos, flow_block_size);
  // calculate average trace across all empty wells in a region for a flow
  // to FileLoadWorker at Image load time, should be able to go here
  emptytrace = emptyTraceTracker->GetEmptyTrace (*region);
}
void SignalProcessingMasterFitter::AllocateRegionDataIfNeeded ( SynchDat &data )
{
  if ( region_data->my_trace.NeedsAllocation() )
  {
    TraceChunk &chunk = data.GetItemByRowCol ( get_region_row(), get_region_col() );
    // timing initialized to match chunk timing
    SetupTimeAndBuffers ( chunk.mSigma, chunk.mTMidNuc, chunk.mT0 );
    //    SetupTimeAndBuffers ( chunk.mSigma, chunk.mTMidNuc, chunk.mT0 );
    if ( chunk.RegionMatch ( *region_data->region ) )
    {
      if ( chunk.TimingMatch ( region_data->time_c.mTimePoints ) )
      {
        // both region and timing match chunk
        region_data->regionAndTimingMatchSdat = true;
      }
    }
  }
}