size_t number_of_threads () { if (__number_of_threads) return __number_of_threads; const App::Options opt = App::get_options ("nthreads"); __number_of_threads = opt.size() ? opt[0][0] : File::Config::get_int ("NumberOfThreads", std::thread::hardware_concurrency()); return __number_of_threads; }
Dynamic::Dynamic (const std::string& in, Image::Buffer<float>& fod_data, const Math::RNG& rng, const DWI::Directions::FastLookupSet& dirs) : Base (in, rng, "dynamic", MAX_TRACKING_SEED_ATTEMPTS_DYNAMIC), SIFT::ModelBase<Fixel_TD_seed> (fod_data, dirs), total_samples (0), total_seeds (0), transform (SIFT::ModelBase<Fixel_TD_seed>::info()) #ifdef DYNAMIC_SEED_DEBUGGING , seed_output ("seeds.tck", Tractography::Properties()) #endif { App::Options opt = App::get_options ("act"); if (opt.size()) act = new Dynamic_ACT_additions (opt[0][0]); perform_FOD_segmentation (fod_data); // Have to set a volume so that Seeding::List works correctly for (std::vector<Fixel>::const_iterator i = fixels.begin(); i != fixels.end(); ++i) volume += i->get_weight(); volume *= (fod_data.vox(0) * fod_data.vox(1) * fod_data.vox(2)); // Prevent divide-by-zero at commencement SIFT::ModelBase<Fixel_TD_seed>::TD_sum = DYNAMIC_SEED_INITIAL_TD_SUM; }
void load_tracking_seeds (Properties& properties) { List& list (properties.seeds); App::Options opt = get_options ("seed_sphere"); for (size_t i = 0; i < opt.size(); ++i) { Sphere* seed = new Sphere (opt[i][0], list.get_rng()); list.add (seed); } opt = get_options ("seed_image"); for (size_t i = 0; i < opt.size(); ++i) { SeedMask* seed = new SeedMask (opt[i][0], list.get_rng()); list.add (seed); } opt = get_options ("seed_random_per_voxel"); for (size_t i = 0; i < opt.size(); ++i) { Random_per_voxel* seed = new Random_per_voxel (opt[i][0], list.get_rng(), opt[i][1]); list.add (seed); } opt = get_options ("seed_grid_per_voxel"); for (size_t i = 0; i < opt.size(); ++i) { Grid_per_voxel* seed = new Grid_per_voxel (opt[i][0], list.get_rng(), opt[i][1]); list.add (seed); } opt = get_options ("seed_rejection"); for (size_t i = 0; i < opt.size(); ++i) { Rejection* seed = new Rejection (opt[i][0], list.get_rng()); list.add (seed); } opt = get_options ("seed_gmwmi"); if (opt.size()) { App::Options opt_act = get_options ("act"); if (!opt_act.size()) throw Exception ("Cannot perform GM-WM Interface seeding without ACT segmented tissue image"); for (size_t i = 0; i < opt.size(); ++i) { GMWMI* seed = new GMWMI (opt[i][0], list.get_rng(), str(opt_act[0][0])); list.add (seed); } } // Can't instantiate the dynamic seeder here; internal FMLS segmenter has to use the same Directions::Set as TrackMapperDixel opt = get_options ("seed_dynamic"); if (opt.size()) { if (list.num_seeds()) throw Exception ("If performing dynamic streamline seeding, cannot specify any other type of seed!"); properties["seed_dynamic"] = str(opt[0][0]); } else if (!list.num_seeds()) { throw Exception ("Must provide at least one source of streamline seeds!"); } opt = get_options ("max_seed_attempts"); if (opt.size()) properties["max_seed_attempts"] = std::string (opt[0][0]); opt = get_options ("output_seeds"); if (opt.size()) properties["seed_output"] = std::string (opt[0][0]); }