bool GMWMI_finder::is_cgm (const Point<float>& p) const { Interp interp (interp_template); interp.scanner2voxel (p); const Tissues tissues (interp); return (tissues.valid() && (tissues.get_sgm() > tissues.get_cgm())); }
int yylex(YYSTYPE* yylval, void* param) { assert(yylval); assert(param); Interp* interp = reinterpret_cast<Interp*>(param); int result = interp->yylex(); *yylval = interp->yylval(); return result; }
bool Dynamic_ACT_additions::check_seed (Point<float>& p) { // Needs to be thread-safe Interp interp (interp_template); interp.scanner (p); const ACT::Tissues tissues (interp); if (tissues.get_csf() > tissues.get_wm() + tissues.get_gm()) return false; if (tissues.get_wm() > tissues.get_gm()) return true; return gmwmi_finder.find_interface (p); }
int main(int argc, char *argv[]) { Q_UNUSED(argc); Q_UNUSED(argv); Interp inter; inter.startInfo(); while(true) { QVector<int> memory; QTextStream input(stdin); QStringList memoryInput = input.readLine().split(QRegExp("\\W+"), QString::SkipEmptyParts); //Help menu if(memoryInput.length() == 1) { if(!QString::compare("h", memoryInput.at(0), Qt::CaseSensitive)) { inter.availableOperationsInfo(); inter.usageInfo(); } else { //Yep... informações em português e sem acentuação //mesmo, não é que nós sejamos analfabetos... //mas a situação exige. qDebug() << "Instrucao invalida"; inter.startInfo(); } } //fill memory else { for(int i = 0; i < memoryInput.length(); i++) { QString arg = memoryInput.at(i); if(!arg.compare("ADD")) { memory.append(-10); } else if (!arg.compare("HALT")) { memory << -5 << 0; } else if (!arg.compare("SUB")) { memory.append(-15); } else if (!arg.compare("MULT")) { memory.append(-20); } else { if(inter.valid(arg)) memory.append(arg.toInt()); else memory << -9; } } //We must always have a halt operation //so the process will always stop memory << -5 << 0; (memory[0] == -20) ? memory.append(1) : memory.append(0); //Interpret instructions inter.interpreter(memory, 0); } } }
Point<float> GMWMI_finder::find_interface (const std::vector< Point<float> >& tck, const bool end, Interp& interp) const { if (tck.size() == 0) return Point<float>(); if (tck.size() == 1) return tck.front(); if (tck.size() == 2) return (end ? tck.back() : tck.front()); // Track is long enough; can do the proper search // Need to generate an additional point beyond the end point typedef Point<float> PointF; size_t last = tck.size() - 1; const PointF p_end (end ? tck.back() : tck.front()); const PointF p_prev (end ? tck[last-1] : tck[1]); // Before proceeding, make sure that the interface lies somewhere in between these two points if (interp.scanner (p_end)) return p_end; const Tissues t_end (interp); if (interp.scanner (p_prev)) return p_end; const Tissues t_prev (interp); if (! (((t_end.get_gm() > t_end.get_wm()) && (t_prev.get_gm() < t_prev.get_wm())) || ((t_end.get_gm() < t_end.get_wm()) && (t_prev.get_gm() > t_prev.get_wm())))) { return p_end; } // Also make sure that the existing endpoint doesn't already obey the criterion if (t_end.get_gm() - t_end.get_wm() < GMWMI_ACCURACY) return p_end; const PointF curvature (end ? ((tck[last]-tck[last-1]) - (tck[last-1]-tck[last-2])) : ((tck[0]-tck[1]) - (tck[1]-tck[2]))); const PointF extrap ((end ? (tck[last]-tck[last-1]) : (tck[0]-tck[1])) + curvature); const PointF p_extrap (p_end + extrap); Point<float> domain [4]; domain[0] = (end ? tck[last-2] : tck[2]); domain[1] = p_prev; domain[2] = p_end; domain[3] = p_extrap; Math::Hermite<float> hermite (GMWMI_HERMITE_TENSION); float min_mu = 0.0, max_mu = 1.0; Point<float> p_best = p_end; size_t iters = 0; do { const float mu = 0.5 * (min_mu + max_mu); hermite.set (mu); const Point<float> p (hermite.value (domain)); interp.scanner (p); const Tissues t (interp); if (t.get_wm() > t.get_gm()) { min_mu = mu; } else { max_mu = mu; p_best = p; if (t.get_gm() - t.get_wm() < GMWMI_ACCURACY) return p_best; } } while (++iters != GMWMI_MAX_ITERS_TO_FIND_BOUNDARY); return p_best; }