void setPrefixAndRegisterAsTemp(std::string const & prefix, uint64_t const numbwt, uint64_t const numgt) { setPrefix(prefix, numbwt, numgt); for ( uint64_t i = 0; i < getGT().size(); ++i ) ::libmaus2::util::TempFileRemovalContainer::addTempFile(getGT()[i]); for ( uint64_t i = 0; i < getBWT().size(); ++i ) ::libmaus2::util::TempFileRemovalContainer::addTempFile(getBWT()[i]); ::libmaus2::util::TempFileRemovalContainer::addTempFile(getHWT()); ::libmaus2::util::TempFileRemovalContainer::addTempFile(getHist()); ::libmaus2::util::TempFileRemovalContainer::addTempFile(getSampledISA()); }
int VcfRecord::getAlleleCount(unsigned int index, VcfSubsetSamples* sampleSubset) { unsigned int numAlts = getNumAlts(); if(index > numAlts) { // Index out of range. // Throw an exception. throw(std::runtime_error("VcfRecord::getAlleles called with an index that is greater than the number of alternates.")); return(-1); } if(myAlleleCount.size() == 0) { unsigned int gt = 0; myAlleleCount.resize(numAlts+1, 0); // Loop through the samples, counting the number of each allele. for(int sampleNum = 0; sampleNum < getNumSamples(); sampleNum++) { if((sampleSubset != NULL) && !(sampleSubset->keep(sampleNum))) { // Skip this sample. continue; } for(int gtNum = 0; gtNum < getNumGTs(sampleNum); gtNum++) { gt = getGT(sampleNum, gtNum); if((gt < 0) || (gt > numAlts)) { // Out of range GT, so continue to the next gt continue; } // Increment the minor allele count ++myAlleleCount[gt]; } } } // Alternate allele, so return the alternate. return(myAlleleCount[index]); }
// ###################################################################### int main(const int argc, const char **argv) { MYLOGVERB = LOG_INFO; // suppress debug messages volatile int signum = 0; catchsignals(&signum); ModelManager manager("Test Motion Energy"); nub::ref<InputFrameSeries> ifs(new InputFrameSeries(manager)); manager.addSubComponent(ifs); nub::ref<OutputFrameSeries> ofs(new OutputFrameSeries(manager)); manager.addSubComponent(ofs); nub::ref<FoeDetector> fd(new FoeDetector(manager)); manager.addSubComponent(fd); if (manager.parseCommandLine((const int)argc, (const char**)argv, "<stimuli> <options>", 0, 9) == false) return(1); fd->reset(NUM_PYR_LEVEL, NUM_DIRS, NUM_SPEEDS); std::string stimuli("Image"); if(manager.numExtraArgs() > 0) stimuli = manager.getExtraArgAs<std::string>(0); LINFO("Stimuli: %s", stimuli.c_str()); manager.start(); Timer timer(1000000); timer.reset(); // reset the timer int frame = 0; PauseWaiter p; uint step; step = 0; // to get to the good part //for(uint i = 0; i < 50; i++) //was 25 // ifs->updateNext(); // get ground truth file std::string gtFilename ("/lab/tmpib/u/siagian/neuroscience/Data/FOE/driving_nat_Browning.txt"); std::vector<Point2D<int> > gt = getGT(gtFilename); int ldpos = gtFilename.find_last_of('.'); std::string prefix = gtFilename.substr(0, ldpos); // for finding ground truth rutz::shared_ptr<XWinManaged> win; float totalErr = 0.0; std::vector<std::string> args; for(uint i = 0; i < manager.numExtraArgs(); i++) args.push_back(manager.getExtraArgAs<std::string>(i)); Image<byte> prevLum; Image<PixRGB<byte> > prevImage; Image<PixRGB<byte> > prevImage2; while (1) { if (signum != 0) { LINFO("quitting because %s was caught", signame(signum)); break; } if (ofs->becameVoid()) { LINFO("quitting because output stream was closed or became void"); break; } if (p.checkPause()) continue; const FrameState is = ifs->updateNext(); if (is == FRAME_COMPLETE) break; // done receiving frames Image< PixRGB<byte> > input = ifs->readRGB(); if(frame == 0) { uint width = input.getWidth(); uint height = input.getHeight(); win.reset(new XWinManaged(Dims(width, height), 0, 0, "GT")); } // empty image signifies end-of-stream if (!input.initialized()) break; Image<byte> lum = luminance(input); Point2D<float> pshift(0.0,0.0); if(step != 0) { // calculate planar shift using SIFT lum = calculateShift(lum,prevLum, ofs); } if( manager.numExtraArgs() > 0) lum = getImage(stimuli, args, fd, step); // for saving videos prevImage2 = prevImage; prevImage = input; if (!lum.initialized()) break; step++; // compute the focus of expansion (FOE) Point2D<int> foe = fd->getFoe(lum, FOE_METHOD_TEMPLATE, false); //Point2D<int> foe = fd->getFoe(lum, FOE_METHOD_AVERAGE); LINFO("[%d]Foe: %d %d", frame, foe.i, foe.j); // illustration of the size of the receptive field if(!stimuli.compare("ShowRF")) { uint rfI = 44; uint rfJ = 152; lum.setVal(rfI, rfJ, 300.0F); drawRect(lum, Rectangle::tlbrI(144,36,159,51), byte(255)); drawRect(lum, Rectangle::tlbrI(148,40,155,47), byte(255)); drawRect(lum, Rectangle::tlbrI(rfJ-8, rfI-8, rfJ+8, rfI+8), byte(255)); drawRect(lum, Rectangle::tlbrI(rfJ-16,rfI-16,rfJ+16,rfI+16), byte(255)); } ofs->writeGrayLayout(fd->getMTfeaturesDisplay(lum), "MT Features", FrameInfo("motion energy output images", SRC_POS)); // write the file if(frame >= 4) { float err = foe.distance(gt[frame-2]); totalErr += err; LINFO("Foe: %d %d: GT: %d %d --> %f --> avg: %f", foe.i, foe.j, gt[frame-2].i, gt[frame-2].j, err, totalErr/(frame-3)); Image<PixRGB<byte> > simg = prevImage2; drawCross(simg, foe , PixRGB<byte>(0,255,0), 10, 2); drawCross(simg, gt[frame-2], PixRGB<byte>(255,0,0), 10, 2); win->drawImage(simg,0,0); //Raster::WriteRGB(simg, sformat("%s_STnPS_%06d.ppm", prefix.c_str(), frame-2)); } //ofs->writeGrayLayout // (lum, "test-FOE Main", FrameInfo("foe output", SRC_POS)); const FrameState os = ofs->updateNext(); //LINFO("frame[%d]: %8.3f %8.3f", frame, pshift.i, pshift.j); Raster::waitForKey(); if (os == FRAME_FINAL) break; prevLum = lum; frame++; } LINFO("%d frames in %gs (%.2ffps)\n", frame, timer.getSecs(), frame / timer.getSecs()); // stop all our ModelComponents manager.stop(); // all done! return 0; }
// Spike logic is driven by TrgSpikeParams: // {periEvtSecs, refractSecs, inarow, nS, T}. // Corresponding states defined above. // void TrigSpike::run() { Debug() << "Trigger thread started."; setYieldPeriod_ms( 100 ); initState(); while( !isStopped() ) { double loopT = getTime(); bool inactive; // ------- // Active? // ------- inactive = ISSTATE_Done || !isGateHi(); if( inactive ) goto next_loop; // ------------- // If gate start // ------------- // Set gateHiT as place from which to start // searching for edge in getEdge(). if( !imCnt.edgeCt || !niCnt.edgeCt ) { usrFlt->reset(); double gateT = getGateHiT(); if( imQ && !imQ->mapTime2Ct( imCnt.edgeCt, gateT ) ) goto next_loop; if( niQ && !niQ->mapTime2Ct( niCnt.edgeCt, gateT ) ) goto next_loop; } // -------------- // Seek next edge // -------------- if( ISSTATE_GetEdge ) { if( p.trgSpike.stream == "imec" ) { if( !getEdge( imCnt, imQ, niCnt, niQ ) ) goto next_loop; } else { if( !getEdge( niCnt, niQ, imCnt, imQ ) ) goto next_loop; } QMetaObject::invokeMethod( gw, "blinkTrigger", Qt::QueuedConnection ); // --------------- // Start new files // --------------- imCnt.remCt = -1; niCnt.remCt = -1; { int ig, it; if( !newTrig( ig, it, false ) ) break; setSyncWriteMode(); } SETSTATE_Write(); } // ---------------- // Handle this edge // ---------------- if( ISSTATE_Write ) { if( !writeSome( DstImec, imQ, imCnt ) || !writeSome( DstNidq, niQ, niCnt ) ) { break; } // ----- // Done? // ----- if( imCnt.remCt <= 0 && niCnt.remCt <= 0 ) { endTrig(); usrFlt->reset(); imCnt.edgeCt += imCnt.refracCt; niCnt.edgeCt += niCnt.refracCt; if( ++nS >= nCycMax ) SETSTATE_Done; else SETSTATE_GetEdge; } } // ------ // Status // ------ next_loop: if( loopT - statusT > 0.25 ) { QString sOn, sWr; int ig, it; getGT( ig, it ); statusOnSince( sOn, loopT, ig, it ); statusWrPerf( sWr ); Status() << sOn << sWr; statusT = loopT; } // ------------------- // Moderate fetch rate // ------------------- yield( loopT ); } endRun(); Debug() << "Trigger thread stopped."; emit finished(); }