17#ifndef __dwi_tractography_sift_model_base_h__
18#define __dwi_tractography_sift_model_base_h__
47#define SIFT_MODEL_OUTPUT_FIXEL_IMAGES
54 namespace Tractography
84 FOD (lobe.get_integral()),
87 dir (lobe.get_mean_dir()) { }
94 const Eigen::Vector3d& get_dir()
const {
return dir; }
100 void clear_TD() {
TD = 0.0; }
123 template <
class Fixel>
182 void output_error_images (
const std::string&,
const std::string&,
const std::string&)
const;
193 template <
class Fixel>
202 have_null_lobes = fmls.get_create_null_lobe();
208 template <
class Fixel>
213 if (!act_5tt.valid()) {
214 INFO (
"Cannot scale fibre densities according to GM fraction; no ACT image data provided");
220 for (
auto l =
Loop(v) (v, act_5tt); l; ++l) {
222 const default_type multiplier = 1.0 - tissues.get_cgm() - (0.5 * tissues.get_sgm());
224 i().scale_FOD (multiplier);
225 FOD_sum += i().get_weight() * i().get_FOD();
233 template <
class Fixel>
239 const track_t count = (properties.find (
"count") == properties.end()) ? 0 : to<track_t>(properties[
"count"]);
246 mapper.set_use_precise_mapping (
true);
254 INFO (
"Proportionality coefficient after streamline mapping is " +
str (mu()));
260 template <
class Fixel>
267 assign_pos_of (in.vox).to (v);
270 assign_pos_of (in.vox).to (proc_mask);
271 const float mask_value = proc_mask.value();
274 i().set_weight (mask_value);
275 FOD_sum += i().get_FOD() * mask_value;
284 template <
class Fixel>
288 for (Mapping::SetDixel::const_iterator i = in.begin(); i != in.end(); ++i) {
291 fixels[fixel_index] += i->get_length();
292 total_contribution += fixels[fixel_index].get_weight() * i->get_length();
295 TD_sum += total_contribution;
302 template <
class Fixel>
307 for (
auto i = fixels.cbegin()+1; i != fixels.end(); ++i)
308 cost += i->get_cost (current_mu);
314 template <
class Fixel>
317 save (proc_mask, path);
321 template <
class Fixel>
324 if (!have_act_data())
325 throw Exception (
"Cannot export 5TT image; no such data present");
326 save (act_5tt, path);
332 template <
class Fixel>
335 output_target_image (prefix +
"_target.mif");
336#ifdef SIFT_MODEL_OUTPUT_SH_IMAGES
337 output_target_image_sh (prefix +
"_target_sh.mif");
339#ifdef SIFT_MODEL_OUTPUT_FIXEL_IMAGES
340 output_target_image_fixel (prefix +
"_target_fixel.msf");
342 output_tdi (prefix +
"_tdi.mif");
344 output_tdi_null_lobes (prefix +
"_tdi_null_lobes.mif");
345#ifdef SIFT_MODEL_OUTPUT_SH_IMAGES
346 output_tdi_sh (prefix +
"_tdi_sh.mif");
348#ifdef SIFT_MODEL_OUTPUT_FIXEL_IMAGES
349 output_tdi_fixel (prefix +
"_tdi_fixel.msf");
351 output_error_images (prefix +
"_max_abs_diff.mif", prefix +
"_diff.mif", prefix +
"_cost.mif");
352#ifdef SIFT_MODEL_OUTPUT_FIXEL_IMAGES
353 output_error_fixel_images (prefix +
"_diff_fixel.msf", prefix +
"_cost_fixel.msf");
355 output_scatterplot (prefix +
"_scatterplot.csv");
356 output_fixel_count_image (prefix +
"_fixel_count.mif");
357 output_untracked_fixels (prefix +
"_untracked_count.mif", prefix +
"_untracked_amps.mif");
const DWI::Directions::FastLookupSet & dirs
size_t dixel2fixel(const Dixel &) const
Fixel_TD_map(const Header &H, const DWI::Directions::FastLookupSet &directions)
A class to read streamlines data.
default_type get_cost_unweighted(const default_type mu) const
void output_tdi_fixel(const std::string &) const
void output_all_debug_images(const std::string &) const
ModelBase(Image< float > &dwi, const DWI::Directions::FastLookupSet &dirs)
ModelBase(const ModelBase &)=delete
void output_target_image_fixel(const std::string &) const
void output_5tt_image(const std::string &)
void output_untracked_fixels(const std::string &, const std::string &) const
void output_target_image_sh(const std::string &) const
default_type calc_cost_function() const
void output_target_image(const std::string &) const
void output_error_images(const std::string &, const std::string &, const std::string &) const
void output_scatterplot(const std::string &) const
void output_proc_mask(const std::string &)
virtual bool operator()(const FMLS::FOD_lobes &in)
void output_tdi_null_lobes(const std::string &) const
void output_fixel_count_image(const std::string &) const
void output_tdi_sh(const std::string &) const
void output_tdi(const std::string &) const
bool have_act_data() const
void perform_FOD_segmentation(Image< float > &)
void output_error_fixel_images(const std::string &, const std::string &) const
void map_streamlines(const std::string &)
ssize_t size(size_t axis) const
constexpr T pow2(const T &v)
FORCE_INLINE LoopAlongAxes Loop()
void check(const ImageType &H)
convenience function to check if an input image can contain SH coefficients
size_t LforN(int N)
returns the largest lmax given N parameters
__Multi< typename std::remove_reference< Functor >::type > multi(Functor &&functor, size_t nthreads=threads_to_execute())
used to request multiple threads of the corresponding functor
void run_queue(Source &&source, const Item &item, Sink &&sink, size_t capacity=128)
convenience function to set up and run a 2-stage multi-threaded pipeline.
__Batch< Item > batch(const Item &, size_t number=128)
used to request batched processing of items
const vector< ParsedOption > get_options(const std::string &name)
return all command-line options matching name
size_t determine_upsample_ratio(const Header &, const float, const float)
void initialise_processing_mask(Image< float > &, Image< float > &, Image< float > &)
PointType::Scalar length(const vector< PointType > &tck)
std::string basename(const std::string &name)
double default_type
the default type used throughout MRtrix
std::string str(const T &value, int precision=0)
std::enable_if< is_adapter_type< typenamestd::remove_reference< ImageType >::type >::value, std::string >::type save(ImageType &&x, const std::string &filename, bool use_multi_threading=true)
save contents of an existing image to file (for debugging only)