예제 #1
0
template <class T> void testFeatTable(const T & table, const char * testName)
{
    FeatureMap testFeatureMap;
    dummyFace.replace_table(TtfUtil::Tag::Feat, &table, sizeof(T));
    gr_face * face = gr_make_face_with_ops(&dummyFace, &face_handle::ops, gr_face_dumbRendering);
    if (!face) throw std::runtime_error("failed to load font");
    bool readStatus = testFeatureMap.readFeats(*face);
    testAssert("readFeats", readStatus);
    fprintf(stderr, testName, NULL);
    testAssertEqual("test num features %hu,%hu\n", testFeatureMap.numFeats(), table.m_header.m_numFeat);

    for (size_t i = 0; i < sizeof(table.m_defs) / sizeof(FeatDefn); i++)
    {
        const FeatureRef * ref = testFeatureMap.findFeatureRef(table.m_defs[i].m_featId);
        testAssert("test feat\n", ref);
        testAssertEqual("test feat settings %hu %hu\n", ref->getNumSettings(), table.m_defs[i].m_numFeatSettings);
        testAssertEqual("test feat label %hu %hu\n", ref->getNameId(), table.m_defs[i].m_label);
        size_t settingsIndex = (table.m_defs[i].m_settingsOffset - sizeof(FeatHeader)
            - (sizeof(FeatDefn) * table.m_header.m_numFeat)) / sizeof(FeatSetting);
        for (size_t j = 0; j < table.m_defs[i].m_numFeatSettings; j++)
        {
            testAssertEqual("setting label %hu %hu\n", ref->getSettingName(j),
                       table.m_settings[settingsIndex+j].m_label);
        }
    }
    gr_face_destroy(face);
}
예제 #2
0
int main(int argc, char * argv[])
{
    gr_face * face = 0;
    try
	{
		if (argc != 2)	throw std::length_error("not enough arguments: need a backing font");

		dummyFace = face_handle(argv[1]);
		testFeatTable<FeatTableTestA>(testDataA, "A\n");
		testFeatTable<FeatTableTestB>(testDataB, "B\n");
		testFeatTable<FeatTableTestB>(testDataBunsorted, "Bu\n");
		testFeatTable<FeatTableTestC>(testDataCunsorted, "C\n");
		testFeatTable<FeatTableTestD>(testDataDunsorted, "D\n");
		testFeatTable<FeatTableTestE>(testDataE, "E\n");

		// test a bad settings offset stradling the end of the table
		FeatureMap testFeatureMap;
		dummyFace.replace_table(TtfUtil::Tag::Feat, &testBadOffset, sizeof testBadOffset);
		face = gr_make_face_with_ops(&dummyFace, &face_handle::ops, gr_face_dumbRendering);
		bool readStatus = testFeatureMap.readFeats(*face);
		testAssert("fail gracefully on bad table", !readStatus);
	}
	catch (std::exception & e)
	{
		fprintf(stderr, "%s: %s\n", argv[0], e.what());
		gr_face_destroy(face);
		return 1;
	}

    gr_face_destroy(face);
    return 0;
}
예제 #3
0
void Test::RunLocalizationTest(RGBImage* image) {
	DLLExecution * executor = new DLLExecution(image);

	executor->executePreProcessingStep1(false);
	executor->executePreProcessingStep2(false);
	executor->executePreProcessingStep3(false);
	executor->executePreProcessingStep4(false);
	executor->prepareLocalization();

	IntensityImage* img = executor->resultPreProcessingStep4;
	HistogramLocalization localizer = HistogramLocalization();

	FeatureMap features = FeatureMap();
	FeatureMap detectedItems = localizer.locateHead(img, features);

	RGB colorRed(244, 67, 54);
	RGBImage * debug = ImageFactory::newRGBImage(executor->resultPreProcessingStep1->getWidth(), executor->resultPreProcessingStep1->getHeight());
	ImageIO::intensityToRGB(*executor->resultPreProcessingStep1, *debug);

	for (int i = 0; i < 3; ++i)
		HereBeDragons::TriumphInLoveFleshStaysNoFatherReason(*debug, Point2D<double>(detectedItems.getFeature(i).getX(), detectedItems.getFeature(i).getY()), colorRed);

	ImageIO::saveRGBImage(*debug, ImageIO::getDebugFileName("localisation.png"));
	ImageIO::showImage(*debug);
}
예제 #4
0
bool CAddonButtonMap::Load(void)
{
  FeatureMap features;
  DriverMap driverMap;
  PrimitiveVector ignoredPrimitives;

  bool bSuccess = false;
  if (auto addon = m_addon.lock())
  {
    bSuccess |= addon->GetFeatures(m_device, m_strControllerId, features);
    bSuccess |= addon->GetIgnoredPrimitives(m_device, ignoredPrimitives);
  }

  // GetFeatures() was changed to always return false if no features were
  // retrieved. Check here, just in case its contract is changed or violated in
  // the future.
  if (bSuccess && features.empty())
    bSuccess = false;

  if (bSuccess)
    driverMap = CreateLookupTable(features);
  else
    CLog::Log(LOGDEBUG, "Failed to load button map for \"%s\"", m_device->DeviceName().c_str());

  {
    CSingleLock lock(m_mutex);
    m_features = std::move(features);
    m_driverMap = std::move(driverMap);
    m_ignoredPrimitives = std::move(CPeripheralAddonTranslator::TranslatePrimitives(ignoredPrimitives));
  }

  return true;
}
예제 #5
0
int main()
{
  // Insert of two features into a map and iterate over the features.
  FeatureMap map;

  Feature feature;
  feature.setRT(15.0);
  feature.setMZ(571.3);
  map.push_back(feature); //append feature 1
  feature.setRT(23.3);
  feature.setMZ(1311.3);
  map.push_back(feature); //append feature 2

  // Iteration over FeatureMap
  for (auto it = map.begin(); it != map.end(); ++it)
  {
    cout << it->getRT() << " - " << it->getMZ() << endl;
  }

  // Calculate and output the ranges
  map.updateRanges();
  cout << "Int: " << map.getMinInt() << " - " << map.getMaxInt() << endl;
  cout << "RT:  " << map.getMin()[0] << " - " << map.getMax()[0] << endl;
  cout << "m/z: " << map.getMin()[1] << " - " << map.getMax()[1] << endl;

  // ... and many more
  return 0;
} //end of main
예제 #6
0
  void InternalCalibration::calibrateMapGlobally(const FeatureMap<> & feature_map, FeatureMap<> & calibrated_feature_map, std::vector<PeptideIdentification> & ref_ids, String trafo_file_name)
  {
    checkReferenceIds_(ref_ids);

    calibrated_feature_map = feature_map;
    // clear the ids
    for (Size f = 0; f < calibrated_feature_map.size(); ++f)
    {
      calibrated_feature_map[f].getPeptideIdentifications().clear();
    }

    // map the reference ids onto the features
    IDMapper mapper;
    Param param;
    param.setValue("rt_tolerance", (DoubleReal)param_.getValue("rt_tolerance"));
    param.setValue("mz_tolerance", param_.getValue("mz_tolerance"));
    param.setValue("mz_measure", param_.getValue("mz_tolerance_unit"));
    mapper.setParameters(param);
    std::vector<ProteinIdentification> vec;
    mapper.annotate(calibrated_feature_map, ref_ids, vec);

    // calibrate
    calibrateMapGlobally(calibrated_feature_map, calibrated_feature_map, trafo_file_name);

    // copy the old ids
    calibrated_feature_map.setUnassignedPeptideIdentifications(feature_map.getUnassignedPeptideIdentifications());
    for (Size f = 0; f < feature_map.size(); ++f)
    {
      calibrated_feature_map[f].getPeptideIdentifications().clear();
      if (!feature_map[f].getPeptideIdentifications().empty())
      {
        calibrated_feature_map[f].setPeptideIdentifications(feature_map[f].getPeptideIdentifications());
      }
    }
  }
  ExitCodes main_(int, const char **)
  {

    String in = getStringOption_("in");
    String out = getStringOption_("out");
    String tr_file = getStringOption_("tr");
    bool force = getFlag_("force");

    boost::shared_ptr<PeakMap > exp ( new PeakMap );
    MzMLFile mzmlfile;
    mzmlfile.setLogType(log_type_);
    mzmlfile.load(in, *exp);

    TargetedExpType transition_exp;
    TraMLFile().load(tr_file, transition_exp);

    FeatureMap output;
    OpenSwath::SpectrumAccessPtr input = SimpleOpenMSSpectraFactory::getSpectrumAccessOpenMSPtr(exp);
    run_(input, output, transition_exp, force);

    output.ensureUniqueId();
    StringList ms_runs;
    exp->getPrimaryMSRunPath(ms_runs);
    output.setPrimaryMSRunPath(ms_runs);
    FeatureXMLFile().store(out, output);

    return EXECUTION_OK;
  }
예제 #8
0
 ExitCodes main_(int, const char **)
 {
   String in = getStringOption_("in"), out = getStringOption_("out");
   FileTypes::Type in_type = FileHandler::getType(in);
   if (in_type == FileTypes::FEATUREXML)
   {
     FeatureMap<> features;
     FeatureXMLFile().load(in, features);
     for (FeatureMap<>::Iterator feat_it = features.begin();
          feat_it != features.end(); ++feat_it)
     {
       resolveConflict_(feat_it->getPeptideIdentifications());
     }
     addDataProcessing_(features,
                        getProcessingInfo_(DataProcessing::FILTERING));
     FeatureXMLFile().store(out, features);
   }
   else     // consensusXML
   {
     ConsensusMap consensus;
     ConsensusXMLFile().load(in, consensus);
     for (ConsensusMap::Iterator cons_it = consensus.begin();
          cons_it != consensus.end(); ++cons_it)
     {
       resolveConflict_(cons_it->getPeptideIdentifications());
     }
     addDataProcessing_(consensus,
                        getProcessingInfo_(DataProcessing::FILTERING));
     ConsensusXMLFile().store(out, consensus);
   }
   return EXECUTION_OK;
 }
예제 #9
0
CAddonButtonMap::DriverMap CAddonButtonMap::CreateLookupTable(const FeatureMap& features)
{
  using namespace JOYSTICK;

  DriverMap driverMap;

  for (FeatureMap::const_iterator it = features.begin(); it != features.end(); ++it)
  {
    const ADDON::JoystickFeature& feature = it->second;

    switch (feature.Type())
    {
      case JOYSTICK_FEATURE_TYPE_SCALAR:
      {
        driverMap[CPeripheralAddonTranslator::TranslatePrimitive(feature.Primitive(JOYSTICK_SCALAR_PRIMITIVE))] = it->first;
        break;
      }

      case JOYSTICK_FEATURE_TYPE_ANALOG_STICK:
      {
        std::vector<JOYSTICK_FEATURE_PRIMITIVE> primitives = {
          JOYSTICK_ANALOG_STICK_UP,
          JOYSTICK_ANALOG_STICK_DOWN,
          JOYSTICK_ANALOG_STICK_RIGHT,
          JOYSTICK_ANALOG_STICK_LEFT,
        };

        for (auto primitive : primitives)
          driverMap[CPeripheralAddonTranslator::TranslatePrimitive(feature.Primitive(primitive))] = it->first;
        break;
      }

      case JOYSTICK_FEATURE_TYPE_ACCELEROMETER:
      {
        std::vector<JOYSTICK_FEATURE_PRIMITIVE> primitives = {
          JOYSTICK_ACCELEROMETER_POSITIVE_X,
          JOYSTICK_ACCELEROMETER_POSITIVE_Y,
          JOYSTICK_ACCELEROMETER_POSITIVE_Z,
        };

        for (auto primitive : primitives)
        {
          CDriverPrimitive translatedPrimitive = CPeripheralAddonTranslator::TranslatePrimitive(feature.Primitive(primitive));
          driverMap[translatedPrimitive] = it->first;

          // Map opposite semiaxis
          CDriverPrimitive oppositePrimitive = CDriverPrimitive(translatedPrimitive.Index(), 0, translatedPrimitive.SemiAxisDirection() * -1, 1);
          driverMap[oppositePrimitive] = it->first;
        }
        break;
      }
        
      default:
        break;
    }
  }
  
  return driverMap;
}
예제 #10
0
bool StudentLocalization::stepFindChinContours(const IntensityImage &image, FeatureMap &features) const {
	
	const Feature & mouthCenter = features.getFeature(Feature::FEATURE_MOUTH_CENTER);
	const Feature & chin = features.getFeature(Feature::FEATURE_CHIN);
	Feature & chinContour = features.getFeature(Feature::FEATURE_CHIN_CONTOUR);

	// The mouth could interfere with the localization of the chin contours.
	// Therefore use an offset based on which mouthcorner is the furthest away.
	// This however could still prove troublesome, so add a slight margin; 
	// represented by the 'magic' number. 
	const double radius = chin.getY() - mouthCenter.getY();


	const double smallestOffsetRadiusFactor = 0.75;
	const double biggestOffsetRadiusFactor = 2;
	//

	// 180° matches half a circle.
	// 0° points to the east in goniometrics, where increasing angles are counter-clockwise.
	// Since the chin is usually on the bottompart of the image, the points either need to be
	// found clockwise (-180), or start looking at an offset.
	// 
	const int halfCircle = 180;
	const int angleStepSize = 10;
	// roughly 19 points need to be found.
	// 0 through 18 does just that.
	for (int i = 0; i <= halfCircle / angleStepSize; ++i)
	{
		// Determine the angle of the line among which we try to look for a point on the chin's contour.
		int angle = halfCircle + i * angleStepSize;
		
		// The size of a step in both the horizontal and verticical direction along the line with the current angle.
		double xDir = std::cos(angle * M_PI / 180.0);
		double yDir = -std::sin(angle * M_PI / 180.0);
		
		// Normalized size of a step that is made alongside the current angle.
		const double increment = 1;

		// Make multiple steps alongside the current angle within bounds where it is likely a contour for the chin.
		for (double distance = radius * smallestOffsetRadiusFactor; distance < radius * biggestOffsetRadiusFactor; distance += increment)
		{
			// Determine the location to check for a contour of the chin.
			double xCheck = mouthCenter.getX() + (xDir * distance);
			double yCheck = mouthCenter.getY() + (yDir * distance);
			// Image should be thresholded grayscale, where the pixels are eiher 0 or 255; check in the middle of it.
			const unsigned char treshhold = 128;
			if (image.getPixel(xCheck, yCheck) <= treshhold)
			{
				chinContour.addPoint(Point2D<double>(xCheck, yCheck));
				std::cout << "Found contour at: " << xCheck << "; " << yCheck << "\n";
				break;
			}
		}
	}

	return (chinContour.getPoints().size() > 0);
}
예제 #11
0
파일: feature.hpp 프로젝트: abhi2705/mlpack
 double length_sq() {
     double l = 0.0;
     FeatureIterator fit;
     for (fit = feat_map.begin(); fit != feat_map.end(); fit++) {
         Feature &f = fit->second;
         l += f.value * f.value;
     }
     return l;
 }
예제 #12
0
void DeepPyramid::constructFeatureMapPyramid(const Mat& img, vector<FeatureMap>& maps) const {
    vector<Mat> imgPyramid;
    constructImagePyramid(img, imgPyramid);
    for (int i = 0; i < levelCount; i++) {
        FeatureMap map;
        net->processImage(imgPyramid[i], map);
        map.normalize();
        maps.push_back(map);
    }
}
 void SeedListGenerator::convertSeedList(const FeatureMap& features,
                                         SeedList& seeds)
 {
   seeds.clear();
   for (FeatureMap::ConstIterator feat_it = features.begin();
        feat_it != features.end(); ++feat_it)
   {
     DPosition<2> point(feat_it->getRT(), feat_it->getMZ());
     seeds.push_back(point);
   }
 }
예제 #14
0
파일: Main.cpp 프로젝트: OpenMS/OpenMS
int main(int argc, char * argv[])
{

  FeatureMap fm;
  Feature feature;
  fm.push_back(feature);
  std::string s = ExampleLibraryFile::printSomething();
  std::cout << "From external lib: " << s << "\n";
  std::cout << "All good and well!\n";

  return 0;
}
예제 #15
0
CAddonButtonMap::DriverMap CAddonButtonMap::CreateLookupTable(const FeatureMap& features)
{
  DriverMap driverMap;

  for (FeatureMap::const_iterator it = features.begin(); it != features.end(); ++it)
  {
    const ADDON::JoystickFeature& feature = it->second;

    switch (feature.Type())
    {
      case JOYSTICK_FEATURE_TYPE_SCALAR:
      {
        driverMap[CPeripheralAddonTranslator::TranslatePrimitive(feature.Primitive())] = it->first;
        break;
      }

      case JOYSTICK_FEATURE_TYPE_ANALOG_STICK:
      {
        driverMap[CPeripheralAddonTranslator::TranslatePrimitive(feature.Up())] = it->first;
        driverMap[CPeripheralAddonTranslator::TranslatePrimitive(feature.Down())] = it->first;
        driverMap[CPeripheralAddonTranslator::TranslatePrimitive(feature.Right())] = it->first;
        driverMap[CPeripheralAddonTranslator::TranslatePrimitive(feature.Left())] = it->first;
        break;
      }

      case JOYSTICK_FEATURE_TYPE_ACCELEROMETER:
      {
        CDriverPrimitive x_axis(CPeripheralAddonTranslator::TranslatePrimitive(feature.PositiveX()));
        CDriverPrimitive y_axis(CPeripheralAddonTranslator::TranslatePrimitive(feature.PositiveY()));
        CDriverPrimitive z_axis(CPeripheralAddonTranslator::TranslatePrimitive(feature.PositiveZ()));

        driverMap[x_axis] = it->first;
        driverMap[y_axis] = it->first;
        driverMap[z_axis] = it->first;

        CDriverPrimitive x_axis_opposite(x_axis.Index(), x_axis.SemiAxisDirection() * -1);
        CDriverPrimitive y_axis_opposite(y_axis.Index(), y_axis.SemiAxisDirection() * -1);
        CDriverPrimitive z_axis_opposite(z_axis.Index(), z_axis.SemiAxisDirection() * -1);

        driverMap[x_axis_opposite] = it->first;
        driverMap[y_axis_opposite] = it->first;
        driverMap[z_axis_opposite] = it->first;
        break;
      }
        
      default:
        break;
    }
  }
  
  return driverMap;
}
bool StudentLocalization::stepFindHead(const IntensityImage &image, FeatureMap &features) const {
	int yTop = getTopOfHead(image);
	int alpha = 13;
	int* histogram;
	int left, right;
	int diffFirstLast = -1, maxDiffFirstLast = -1;
	int ySides = -1;
	//number of slices the image will be 'cut' into for the histograms
	int count = ((image.getHeight() - yTop - 1) / alpha) + 1;

	for (int i = 0; i < count; i++) {
		//get histogram of current slice
		histogram = getHistogramX(image, alpha, yTop + i * alpha);
		findSidesInHistogram(histogram, image.getWidth(), &left, &right);
		//if no two sides have been found continue to the next slice
		if (left == -1 || right == -1) {
			continue;
		}

		//find the first peak gap between the left and right side to detect the position of the ears
		diffFirstLast = right - left;
		if (diffFirstLast > maxDiffFirstLast) {
			maxDiffFirstLast = diffFirstLast;
		}
		else {
			//if the gap is lower than the max, a peak has been found
			//and the y position of the ears will be set to the middle of the slice 
			//where the peak is detected
			ySides = yTop + (i + 1)  * alpha;
			break;
		}
	}
	//if no peak is detected return false
	if (ySides == -1) {
		return false;
	}

	//set the results in the feature map
	Point2D<double> * pointLeftSideHead = new Point2D<double>(left, ySides);
	Feature * leftSideHead = new Feature(Feature::FEATURE_HEAD_LEFT_SIDE, *pointLeftSideHead);
	features.putFeature(*leftSideHead);

	Point2D<double> * pointRightSideHead = new Point2D<double>(right, ySides);
	Feature * rightSideHead = new Feature(Feature::FEATURE_HEAD_RIGHT_SIDE, *pointRightSideHead);
	features.putFeature(*rightSideHead);

	Point2D<double> * pointTopOfHead = new Point2D<double>((left + right) / 2, yTop);
	Feature * topOfHead = new Feature(Feature::FEATURE_HEAD_TOP, *pointTopOfHead);
	features.putFeature(*topOfHead);
	
	return true;
}
예제 #17
0
  void markFeatureLocations_(FeatureMap & feature_map, MSExperiment<> & exp, QImage & image, bool transpose, QColor color)
  {
    double xcoef = image.width(), ycoef = image.height();
    if (transpose)
    {
      xcoef /= exp.getMaxRT() - exp.getMinRT();
      ycoef /= exp.getMaxMZ() - exp.getMinMZ();
    }
    else
    {
      xcoef /= exp.getMaxMZ() - exp.getMinMZ();
      ycoef /= exp.getMaxRT() - exp.getMinRT();
    }

    for (FeatureMap::Iterator feat_iter = feature_map.begin();
         feat_iter != feature_map.end(); ++feat_iter)
    {
      const ConvexHull2D convex_hull = feat_iter->getConvexHull();
      DBoundingBox<2> box = convex_hull.getBoundingBox();
      double rt = feat_iter->getRT();
      double mz = feat_iter->getMZ();
      double lower_mz = box.minY();
      double lower_rt = box.minX();
      double upper_mz = box.maxY();
      double upper_rt = box.maxX();

      int lx, ly, ux, uy, cx, cy;
      if (transpose)
      {
        lx = int(xcoef * (lower_rt - exp.getMinRT()));
        ly = int(ycoef * (exp.getMaxMZ() - lower_mz));
        ux = int(xcoef * (upper_rt - exp.getMinRT()));
        uy = int(ycoef * (exp.getMaxMZ() - upper_mz));
        cx = int(xcoef * (rt - exp.getMinRT()));
        cy = int(ycoef * (mz - lower_mz));
      }
      else
      {
        lx = int(xcoef * (lower_mz - exp.getMinMZ()));
        ly = int(ycoef * (exp.getMaxRT() - lower_rt));
        ux = int(xcoef * (upper_mz - exp.getMinMZ()));
        uy = int(ycoef * (exp.getMaxRT() - upper_rt));
        cx = int(xcoef * (mz - exp.getMinMZ()));
        cy = int(ycoef * (exp.getMaxRT() - rt));
      }

      addFeatureBox_(ly, lx, uy, ux, image, color);
      addPoint_(cx, cy, image, Qt::black); // mark center
    }
  }
예제 #18
0
void copy(FeatureMap& dest, const FeatureMap& src)
{
	assert(dest.input_length == src.input_length);
	assert(dest.feature_count == src.feature_count);

	const auto input_length = dest.input_length;
	const auto feature_count = dest.feature_count;

	memcpy(dest.biases(), src.biases(), sizeof(float) * feature_count);
	for(uint32_t k = 0; k < feature_count; k++)
	{
		memcpy(dest.feature(k), src.feature(k), sizeof(float) * input_length);
	}
}
예제 #19
0
  void MapAlignmentTransformer::transformSingleFeatureMap(FeatureMap<> & fmap,
                                                          const TransformationDescription & trafo)
  {
    for (vector<Feature>::iterator fmit = fmap.begin(); fmit != fmap.end(); ++fmit)
    {
      applyToFeature_(*fmit, trafo);
    }

    // adapt RT values of unassigned peptides:
    if (!fmap.getUnassignedPeptideIdentifications().empty())
    {
      transformSinglePeptideIdentification(
        fmap.getUnassignedPeptideIdentifications(), trafo);
    }
  }
예제 #20
0
  void InternalCalibration::applyTransformation_(const FeatureMap<> & feature_map, FeatureMap<> & calibrated_feature_map)
  {
    calibrated_feature_map = feature_map;
    for (Size f = 0; f < feature_map.size(); ++f)
    {
      DoubleReal mz = feature_map[f].getMZ();
      mz = trafo_.apply(mz);
      calibrated_feature_map[f].setMZ(mz);

      // apply transformation to convex hulls and subordinates
      for (Size s = 0; s < calibrated_feature_map[f].getSubordinates().size(); ++s)
      {
        // subordinates
        DoubleReal mz = calibrated_feature_map[f].getSubordinates()[s].getMZ();
        mz = trafo_.apply(mz);
        calibrated_feature_map[f].getSubordinates()[s].setMZ(mz);
      }
      for (Size s = 0; s < calibrated_feature_map[f].getConvexHulls().size(); ++s)
      {
        // convex hulls
        std::vector<DPosition<2> > point_vec = calibrated_feature_map[f].getConvexHulls()[s].getHullPoints();
        calibrated_feature_map[f].getConvexHulls()[s].clear();
        for (Size p = 0; p < point_vec.size(); ++p)
        {
          DoubleReal mz = point_vec[p][1];
          mz = trafo_.apply(mz);
          point_vec[p][1] = mz;
        }
        calibrated_feature_map[f].getConvexHulls()[s].setHullPoints(point_vec);
      }
    }
  }
 void SeedListGenerator::convertSeedList(const SeedList& seeds,
                                         FeatureMap& features)
 {
   features.clear(true); // "true" should really be a default value here...
   Size counter = 0;
   for (SeedList::const_iterator seed_it = seeds.begin();
        seed_it != seeds.end(); ++seed_it, ++counter)
   {
     Feature feature;
     feature.setRT(seed_it->getX());
     feature.setMZ(seed_it->getY());
     feature.setUniqueId(counter);
     features.push_back(feature);
   }
   // // assign unique ids:
   // features.applyMemberFunction(&UniqueIdInterface::setUniqueId);
 }
예제 #22
0
  void MapAlignmentTransformer::transformRetentionTimes(
    FeatureMap& fmap, const TransformationDescription& trafo,
    bool store_original_rt)
  {
    for (vector<Feature>::iterator fmit = fmap.begin(); fmit != fmap.end();
         ++fmit)
    {
      applyToFeature_(*fmit, trafo, store_original_rt);
    }

    // adapt RT values of unassigned peptides:
    if (!fmap.getUnassignedPeptideIdentifications().empty())
    {
      transformRetentionTimes(fmap.getUnassignedPeptideIdentifications(), trafo,
                              store_original_rt);
    }
  }
void QuantitativeExperimentalDesign::mergeFeatureMaps_(FeatureMap<> & out, const String & experiment, StringList & file_paths)
{
    FeatureMap<> map;

    LOG_INFO << "Merge feature maps: " << endl;
    UInt counter = 1;
    for (StringList::Iterator file_it = file_paths.begin(); file_it != file_paths.end(); ++file_it, ++counter)
    {
        //load should clear the map
        FeatureXMLFile().load(*file_it, map);
        for (FeatureMap<>::iterator it = map.begin(); it != map.end(); ++it)
        {
            it->setMetaValue("experiment", DataValue(experiment));
        }
        out += map;
    }
}
bool StudentLocalization::stepFindChinContours(const IntensityImage &image, FeatureMap &features) const {

	//Get the position of the mouth
	Feature Mouth = features.getFeature(Feature::FEATURE_MOUTH_TOP);
	Point2D<double> MouthPosition;
	
	//Initialise the chin feature
	std::vector<Point2D<double>> ChinPositions;
	Feature Chin = Feature(Feature::FEATURE_CHIN);
	Feature ChinContour = Feature(Feature::FEATURE_CHIN_CONTOUR);
	int y = 0;
	int m = 0;
	
	//Draw a half circle starting from the center of the mouth
	for (int j = HALF_CIRCLE; j > 0; j -= DEGREE_STEP){
		
		//reset the position of the mouth
		MouthPosition.set(Mouth.getX(), Mouth.getY());
		MouthPosition.set(drawLine(j, START_POSITION, MouthPosition));
	
		m = m + 1;

		
		for (int i = 0; i < MEASURE_RANGE; i++){

			MouthPosition.set(drawLine(j, MEASURE_STEP, MouthPosition));
			Intensity pixel = image.getPixel(MouthPosition.getX(), MouthPosition.getY());

			// If the intensity of the current pixel is lower than 2 (which means it is black)
			if (pixel < 2){ 
				
				// If the current angle is within the bounds of the half circle
				if (j < RIGHT_HALF && j > LEFT_HALF){
					ChinContour.addPoint(drawLine(j, 2, MouthPosition));
				}
				else{
					//Draw a point on the mouth position, to indicate the detection failed.
					ChinContour.addPoint(MouthPosition);
				}
				break;
			}
		}	
	}	
	features.putFeature(ChinContour);
	return true;
}
예제 #25
0
void DeepPyramid::processFeatureMap(int filterIdx, const FeatureMap &map, vector<BoundingBox> &detectedObjects) const {
    Size mapSize = map.size();
    Size filterSize = rootFilter[filterIdx]->getMapSize();
    cout << "size: "<<map.size()<<endl;
    for (int width = 0; width < mapSize.width-filterSize.width; width+=stride) {
        for (int height = 0; height < mapSize.height-filterSize.height; height+=stride) {
            FeatureMap extractedMap;
            map.extractFeatureMap(Rect(Point(width, height), filterSize), extractedMap);
            if (rootFilter[filterIdx]->predict(extractedMap) == OBJECT) {
                BoundingBox box;
                box.norm5Box = Rect(Point(width, height), filterSize);
                box.confidence = std::fabs(rootFilter[filterIdx]->predict(extractedMap, true));
                box.map = extractedMap;
                detectedObjects.push_back(box);
            }
        }
    }
}
void QuantitativeExperimentalDesign::applyDesign2Quantifier(PeptideAndProteinQuant & quantifier, TextFile & file, StringList & file_paths)
{
    //        vector< pair<PeptideAndProteinQuant::PeptideData,PeptideAndProteinQuant::ProteinQuant> >& result)
    //create mapping from experimental setting to all respective file names
    map<String, StringList> design2FileBaseName;
    mapFiles2Design_(design2FileBaseName, file);
    //filter out all non-existing files
    map<String, StringList> design2FilePath;
    findRelevantFilePaths_(design2FileBaseName, design2FilePath, file_paths);

    //determine wether we deal with idXML or featureXML
    FileTypes::Type in_type = FileHandler::getType(file_paths.front());

    if (in_type == FileTypes::FEATUREXML)
    {
        FeatureMap<> features;

        for (map<String, StringList>::iterator iter =  design2FilePath.begin(); iter != design2FilePath.end(); ++iter)
        {
            mergeFeatureMaps_(features, iter->first, iter->second);
        }
        LOG_INFO << "Number of proteinIdentifications: " << features.getProteinIdentifications().size() << endl;
        ProteinIdentification & proteins = features.getProteinIdentifications()[0];

        quantifier.quantifyPeptides(features);
        quantifier.quantifyProteins(proteins);
    }
    else
    {
        ConsensusMap consensus;

        for (map<String, StringList>::iterator iter =  design2FilePath.begin(); iter != design2FilePath.end(); ++iter)
        {
            mergeConsensusMaps_(consensus, iter->first, iter->second);
        }

        LOG_INFO << "Number of proteinIdentifications: " << consensus.getProteinIdentifications().size() << endl;
        ProteinIdentification & proteins = consensus.getProteinIdentifications()[0];

        quantifier.quantifyPeptides(consensus);
        quantifier.quantifyProteins(proteins);
    }
}
예제 #27
0
Int main()
{
  FeatureMap map;

  Feature feature;
  feature.setRT(15.0);
  feature.setMZ(571.3);
  map.push_back(feature); //append feature 1
  feature.setRT(23.3);
  feature.setMZ(1311.3);
  map.push_back(feature); //append feature 2


  for (FeatureMap::Iterator it = map.begin(); it != map.end(); ++it)
  {
    cout << it->getRT() << " - " << it->getMZ() << endl;
  }

  return 0;
} //end of main
예제 #28
0
  /// Detailed Constructor
  MSQuantifications::MSQuantifications(FeatureMap<> fm, ExperimentalSettings& es, std::vector<DataProcessing>& dps, std::vector<std::vector<std::pair<String, DoubleReal> > > label) :
    ExperimentalSettings()
  {
    MSQuantifications::QUANT_TYPES quant_type = MSQuantifications::LABELFREE;
    this->setAnalysisSummaryQuantType(quant_type);

    //~ AssayList,InputFiles,SoftwareList
    //~ aus exp.
    this->registerExperiment(es,dps,label);
    
    this->setDataProcessingList(fm.getDataProcessing()); //TODO add dp from experiment (i.e. mzml) ?
    feature_maps_  = std::vector<FeatureMap<> > (1,fm);
  }
 void applyFDRcutoff(FeatureMap & feature_map, double cutoff, String fdr_name)
 {
   FeatureMap out_feature_map = feature_map;
   out_feature_map.clear(false);
   for (Size i = 0; i < feature_map.size(); i++)
   {
     if ((double)feature_map[i].getMetaValue(fdr_name) < cutoff)
     {
       out_feature_map.push_back(feature_map[i]);
     }
   }
   feature_map = out_feature_map;
 }
예제 #30
0
  void EDTAFile::store(const String& filename, const FeatureMap& map) const
  {
    TextFile tf;
    tf.addLine("RT\tm/z\tintensity\tcharge");

    for (Size i = 0; i < map.size(); ++i)
    {
      const Feature& f = map[i];
      tf.addLine(String(f.getRT()) + "\t" + f.getMZ() + "\t" + f.getIntensity() + "\t" + f.getCharge());
    }

    tf.store(filename);

  }