1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
/* Copyright (c) 2008-2025 the MRtrix3 contributors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Covered Software is provided under this License on an "as is"
* basis, without warranty of any kind, either expressed, implied, or
* statutory, including, without limitation, warranties that the
* Covered Software is free of defects, merchantable, fit for a
* particular purpose or non-infringing.
* See the Mozilla Public License v. 2.0 for more details.
*
* For more details, see http://www.mrtrix.org/.
*/
#include "command.h"
#include "header.h"
#include "image.h"
#include "image_helpers.h"
#include "surface/mesh.h"
#include "surface/algo/mesh2image.h"
using namespace MR;
using namespace App;
void usage ()
{
AUTHOR = "Robert E. Smith (robert.smith@florey.edu.au)";
SYNOPSIS = "Convert a mesh surface to a partial volume estimation image";
REFERENCES
+ "Smith, R. E.; Tournier, J.-D.; Calamante, F. & Connelly, A. " // Internal
"Anatomically-constrained tractography: Improved diffusion MRI streamlines tractography through effective use of anatomical information. "
"NeuroImage, 2012, 62, 1924-1938";
ARGUMENTS
+ Argument ("source", "the mesh file; note vertices must be defined in realspace coordinates").type_file_in()
+ Argument ("template", "the template image").type_image_in()
+ Argument ("output", "the output image").type_image_out();
}
void run ()
{
// Read in the mesh data
Surface::Mesh mesh (argument[0]);
// Get the template image
Header template_header = Header::open (argument[1]);
check_3D_nonunity (template_header);
template_header.ndim() = 3;
// Ensure that a floating-point representation is used for the output image,
// as is required for representing partial volumes
template_header.datatype() = DataType::Float32;
template_header.datatype().set_byte_order_native();
// Create the output image
Image<float> output = Image<float>::create (argument[2], template_header);
// Perform the partial volume estimation
Surface::Algo::mesh2image (mesh, output);
}
|