示例#1
0
void run ()
{
  Header H = Header::open (argument[0]);
  Math::SH::check (H);
  auto fod_data = H.get_image<float>();

  Segmented_FOD_receiver receiver (H);

  auto
  opt = get_options ("afd");  if (opt.size()) receiver.set_afd_output  (opt[0][0]);
  opt = get_options ("peak"); if (opt.size()) receiver.set_peak_output (opt[0][0]);
  opt = get_options ("disp"); if (opt.size()) receiver.set_disp_output (opt[0][0]);
  if (!receiver.num_outputs())
    throw Exception ("Nothing to do; please specify at least one output image type");

  opt = get_options ("mask");
  Image<float> mask;
  if (opt.size()) {
    mask = Image<float>::open (std::string (opt[0][0]));
    if (!dimensions_match (fod_data, mask, 0, 3))
      throw Exception ("Cannot use image \"" + str(opt[0][0]) + "\" as mask image; dimensions do not match FOD image");
  }

  FMLS::FODQueueWriter writer (fod_data, mask);

  const DWI::Directions::Set dirs (1281);
  Segmenter fmls (dirs, Math::SH::LforN (H.size(3)));
  load_fmls_thresholds (fmls);

  Thread::run_queue (writer, Thread::batch (SH_coefs()), Thread::multi (fmls), Thread::batch (FOD_lobes()), receiver);
}
示例#2
0
void run ()
{
  Image::Header H (argument[0]);
  Image::Buffer<float> fod_data (H);

  if (fod_data.ndim() != 4)
    throw Exception ("input FOD image should contain 4 dimensions");

  const size_t lmax = Math::SH::LforN (fod_data.dim(3));

  if (Math::SH::NforL (lmax) != size_t(fod_data.dim(3)))
    throw Exception ("Input image does not appear to contain an SH series per voxel");

  const DWI::Directions::Set dirs (1281);
  Segmented_FOD_receiver receiver (H, dirs);

  size_t output_count = 0;
  Options opt = get_options ("afd");
  if (opt.size()) {
    receiver.set_afd_output (opt[0][0]);
    ++output_count;
  }
  opt = get_options ("count");
  if (opt.size()) {
    receiver.set_count_output (opt[0][0]);
    ++output_count;
  }
  opt = get_options ("dec");
  if (opt.size()) {
    receiver.set_dec_output (opt[0][0]);
    ++output_count;
  }
  opt = get_options ("gfa");
  if (opt.size()) {
    receiver.set_gfa_output (opt[0][0]);
    ++output_count;
  }
  opt = get_options ("pseudo_fod");
  if (opt.size()) {
    receiver.set_pseudo_fod_output (opt[0][0]);
    ++output_count;
  }
  opt = get_options ("sf");
  if (opt.size()) {
    receiver.set_sf_output (opt[0][0]);
    ++output_count;
  }
  opt = get_options ("fixel_afd");
  if (opt.size()) {
    receiver.set_fixel_afd_output (opt[0][0]);
    ++output_count;
  }
  opt = get_options ("fixel_peak");
  if (opt.size()) {
    receiver.set_fixel_peak_output (opt[0][0]);
    ++output_count;
  }
  opt = get_options ("fixel_disp");
  if (opt.size()) {
    receiver.set_fixel_disp_output (opt[0][0]);
    ++output_count;
  }
  if (!output_count)
    throw Exception ("Nothing to do; please specify at least one output image type");

  FMLS::FODQueueWriter<Image::Buffer<float>::voxel_type> writer (fod_data);

  opt = get_options ("mask");
  Ptr<Image::Buffer<bool> > mask_buffer_ptr;
  if (opt.size()) {
    mask_buffer_ptr = new Image::Buffer<bool> (std::string (opt[0][0]));
    if (!Image::dimensions_match (fod_data, *mask_buffer_ptr, 0, 3))
      throw Exception ("Cannot use image \"" + str(opt[0][0]) + "\" as mask image; dimensions do not match FOD image");
    writer.set_mask (*mask_buffer_ptr);
  }

  Segmenter fmls (dirs, lmax);
  load_fmls_thresholds (fmls);

  Thread::run_queue (writer, SH_coefs(), Thread::multi (fmls), FOD_lobes(), receiver);

}