void testAdaBoost(int colorspace) { ImageLoader loaderTrue("c:\\Images\\true", colorspace); ImageLoader loaderFalse("c:\\Images\\false", colorspace); ImageLoader loaderTest("c:\\Images\\test", colorspace); vector< Image* > slikeTrue = loaderTrue.loadNextImages(); vector< Image* > slikeFalse= loaderFalse.loadNextImages(); Feature::loadBaseFeatures("bftest.txt"); int tmpChans[] = {0, 1, 2}; vector< int > channels(tmpChans, tmpChans + 3 ); //kanali nad kojima ce se raditi vector < Feature > tmp = Feature::generateAll( 20, 20, 3, 1.25, channels ); writeFeatures( tmp ); AdaBoost boost; vector< Feature > level = boost.startTraining( slikeTrue, slikeFalse, tmp, 20); cout << "IZABRANI FEATURE-i" << endl; writeFeatures( level ); vector< Image * > testSlike = loaderTest.loadNextImages(); //testSlike[0]->showImageOverlappedWithFeature( level[1], true ); testSlike[0]->evaluirajLevel( level ); //for(int i=0; i<testSlike.size(); i++) { // testSlike[i]->evaluirajLevel( level ); //} }
void genePredWriteToGtf(struct genePred *gp, char *source, struct hash *dupeHash, FILE *f) /* Write out genePredName to GTF file. */ { int i; char *name = findUniqueName(dupeHash, gp->name); char *geneName = gp->name2; char *chrom = gp->chrom; char strand = gp->strand[0]; int *frames = (gp->optFields & genePredExonFramesFld) ? gp->exonFrames : calcFrames(gp); struct codonCoords firstCodon = findFirstCodon(gp, frames); struct codonCoords lastCodon = findLastCodon(gp, frames); // figure out bounds of CDS and UTR regions, moving stop codon to outside of // CDS. int firstUtrEnd = gp->cdsStart, lastUtrStart = gp->cdsEnd; int cdsStart = gp->cdsStart, cdsEnd = gp->cdsEnd; if ((strand == '+') && codonComplete(&lastCodon)) cdsEnd = movePos(gp, lastUtrStart, -3); if ((strand == '-') && codonComplete(&firstCodon)) cdsStart = movePos(gp, cdsStart, 3); if (addComments) fprintf(f, "###\n# %s %s:%d-%d (%s) CDS: %d-%d\n#\n", gp->name, gp->chrom, gp->txStart, gp->txEnd, gp->strand, gp->cdsStart, gp->cdsEnd); for (i=0; i<gp->exonCount; ++i) { writeGtfLine(f, source, name, geneName, chrom, strand, "exon", gp->exonStarts[i], gp->exonEnds[i], i, -1); if (cdsStart < cdsEnd) writeFeatures(gp, i, source, name, chrom, strand, geneName, firstUtrEnd, cdsStart, cdsEnd, lastUtrStart, frames[i], f); } if (gp->strand[0] == '+') { if (codonComplete(&firstCodon)) writeCodon(f, source, name, geneName, chrom, strand, "start_codon", &firstCodon); if (codonComplete(&lastCodon)) writeCodon(f, source, name, geneName, chrom, strand, "stop_codon", &lastCodon); } else { if (codonComplete(&lastCodon)) writeCodon(f, source, name, geneName, chrom, strand, "start_codon", &lastCodon); if (codonComplete(&firstCodon)) writeCodon(f, source, name, geneName, chrom, strand, "stop_codon", &firstCodon); } if (!(gp->optFields & genePredExonFramesFld)) freeMem(frames); }
void ParticleSorterMpi::run() { int total_nr_images = MDin.numberOfObjects(); features.resize(total_nr_images, NR_FEATURES); // Each node does part of the work long int my_first_image, my_last_image, my_nr_images; divide_equally(total_nr_images, node->size, node->rank, my_first_image, my_last_image); my_nr_images = my_last_image - my_first_image + 1; int barstep; if (verb > 0) { std::cout << "Calculating sorting features for all input particles..." << std::endl; init_progress_bar(my_nr_images); barstep = XMIPP_MAX(1, my_nr_images/ 60); } long int ipart = 0; FOR_ALL_OBJECTS_IN_METADATA_TABLE(MDin) { if (ipart >= my_first_image && ipart <= my_last_image) { if (verb > 0 && ipart % barstep == 0) progress_bar(ipart); calculateFeaturesOneParticle(ipart); } ipart++; } if (verb > 0) progress_bar(my_nr_images); // Combine results from all nodes MultidimArray<double> allnodes_features; allnodes_features.resize(features); MPI_Allreduce(MULTIDIM_ARRAY(features), MULTIDIM_ARRAY(allnodes_features), MULTIDIM_SIZE(features), MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); features = allnodes_features; // Only the master writes out files if (verb > 0) { normaliseFeatures(); writeFeatures(); } }
void CascadeWriter::writeCascade() { xml.writeStartElement("cascade"); xml.writeTextElement("stageType", m_cascadeObj.stageType()); xml.writeTextElement("featureType", m_cascadeObj.featureType()); xml.writeTextElement("height", QString::number(m_cascadeObj.height())); xml.writeTextElement("width", QString::number(m_cascadeObj.width())); writeStageParams(); writeFeatureParams(); xml.writeTextElement("stageNum", QString::number(m_cascadeObj.stageNum())); writeStages(); writeFeatures(); xml.writeEndElement(); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void AbaqusSurfaceMeshWriter::execute() { int32_t err = 0; setErrorCondition(err); dataCheck(); if(getErrorCondition() < 0) { return; } DataContainer::Pointer sm = getDataContainerArray()->getDataContainer(getSurfaceMeshFaceLabelsArrayPath().getDataContainerName()); // Make sure any directory path is also available as the user may have just typed // in a path without actually creating the full path QFileInfo fi(getOutputFile()); QDir parentPath = fi.path(); if(!parentPath.mkpath(".")) { QString ss = QObject::tr("Error creating parent path '%1'").arg(parentPath.absolutePath()); setErrorCondition(-8005); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); return; } TriangleGeom::Pointer triangleGeom = sm->getGeometryAs<TriangleGeom>(); // Store all the unique Spins std::set<int32_t> uniqueSpins; for (int64_t i = 0; i < triangleGeom->getNumberOfTris(); i++) { uniqueSpins.insert(m_SurfaceMeshFaceLabels[i * 2]); uniqueSpins.insert(m_SurfaceMeshFaceLabels[i * 2 + 1]); } FILE* f = fopen(m_OutputFile.toLatin1().data(), "wb"); ScopedFileMonitor fileMonitor(f); err = writeHeader(f, triangleGeom->getNumberOfVertices(), triangleGeom->getNumberOfTris(), uniqueSpins.size() - 1); if(err < 0) { QString ss = QObject::tr("Error writing header for file '%1'").arg(m_OutputFile); setErrorCondition(-8001); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); return; } err = writeNodes(f); if(err < 0) { QString ss = QObject::tr("Error writing nodes for file '%1'").arg(m_OutputFile); setErrorCondition(-8002); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); return; } err = writeTriangles(f); if(err < 0) { QString ss = QObject::tr("Error writing triangles for file '%1'").arg(m_OutputFile); setErrorCondition(-8003); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); return; } err = writeFeatures(f); if(err < 0) { QString ss = QObject::tr("Error writing Features for file '%1'").arg(m_OutputFile); setErrorCondition(-8004); notifyErrorMessage(getHumanLabel(), ss, getErrorCondition()); return; } notifyStatusMessage(getHumanLabel(), "Complete"); }