Esempio n. 1
0
void SetUpOrLoadInitialState(CommandLineOpts &inception_state, SeqListClass &my_keys, TrackProgress &my_progress, ImageSpecClass &my_image_spec, SlicedPrequel& my_prequel_setup)
{

  if ( !inception_state.bkg_control.signal_chunks.restart_from.empty() )
  {
    // restarting from saved computational state
    // beadfind, bfmask.bin and beadfind.h5 will be ignored

    // note that if we are here we will never load the separator data
    inception_state.sys_context.GenerateContext (); // find our directories
    inception_state.sys_context.SetUpAnalysisLocation();

    LoadBeadFindState(inception_state, my_keys, my_image_spec);
  }
  else if (inception_state.mod_control.reusePriorBeadfind && inception_state.bkg_control.signal_chunks.restart_from.empty())
  {
    // starting execution fresh, justBeadFind already run
    
    // get any state from beadFind
    LoadBeadFindState(inception_state, my_keys, my_image_spec);

	// save current command line options to state file
	std::string stateFile = inception_state.sys_context.analysisLocation + "/analysisState.json";
    if (rename(stateFile.c_str(),(inception_state.sys_context.analysisLocation+"/analysisState_beadfind.json").c_str()) )
    {
      fprintf(stdout, "Unable to copy beadfind analysisState.json");
    }

    SetUpKeys(my_keys, inception_state.key_context, inception_state.flow_context);
    ProgramState state ( stateFile );
    state.Save ( inception_state,my_keys,my_image_spec );
    state.WriteState();

    // region layout saved in inception_state.loc_context
    // region definitions in background model via my_prequel_setup
    my_prequel_setup.SetRegions ( inception_state.loc_context.numRegions,
				  my_image_spec.rows,my_image_spec.cols,
				  inception_state.loc_context.regionXSize,
				  inception_state.loc_context.regionYSize );
    my_prequel_setup.FileLocations ( inception_state.sys_context.analysisLocation );

  }
 else
 {  
   // starting execution fresh, justBeadFind not run
   inception_state.SetUpProcessing();

   CreateResultsFolder (inception_state.sys_context.GetResultsFolder());
   inception_state.sys_context.SetUpAnalysisLocation();
    
   // convert from old key representatino to more useful modern style  
   SetUpKeys(my_keys, inception_state.key_context, inception_state.flow_context);
  
   //@TODO: side effects here on the entire image class
   // after this point, Images will behave differently when read in
   SetUpToProcessImages ( my_image_spec, inception_state );

   // region layout saved into inception_state.loc_context
   SetUpRegionsForAnalysis ( my_image_spec.rows, my_image_spec.cols, inception_state.loc_context );

   // region layout shared in background model and beadfind via my_prequel_setup
   my_prequel_setup.SetRegions ( inception_state.loc_context.numRegions,
				 my_image_spec.rows,my_image_spec.cols,
				 inception_state.loc_context.regionXSize,
				 inception_state.loc_context.regionYSize );
   my_prequel_setup.FileLocations ( inception_state.sys_context.analysisLocation );
 }
  strncpy(ImageTransformer::PCATest,inception_state.img_control.PCATest,sizeof(ImageTransformer::PCATest)-1);

  fprintf(stdout, "Analysis region size is width %d, height %d\n", inception_state.loc_context.regionXSize, inception_state.loc_context.regionYSize);
}