17#ifndef __filter_dwi_brain_mask_h__
18#define __filter_dwi_brain_mask_h__
24#include "filter/base.h"
61 template <
class HeaderType>
73 template <
class InputImageType,
class OutputImageType>
74 void operator() (InputImageType& input, OutputImageType& output) {
87 for (
size_t s = 0; s != shells.
count(); ++s) {
92 for (
auto l =
Loop (0, 3) (input, shell_image); l; ++l) {
109 threshold_filter (shell_image, shell_mask_voxel);
114 for (
auto l =
Loop (0, 3)(mask_image, shell_mask_voxel); l; ++l) {
115 if (shell_mask_voxel.value())
116 mask_image.value() =
true;
125 Median median_filter (mask_image);
126 median_filter (mask_image, temp_image);
131 connected_filter.set_largest_only (
true);
132 connected_filter (temp_image, temp_image);
136 for (
auto l =
Loop (0,3)(temp_image); l; ++l)
137 temp_image.value() = !temp_image.value();
141 connected_filter (temp_image, temp_image);
145 for (
auto l =
Loop (0,3) (temp_image, output); l; ++l)
146 output.value() = !temp_image.value();
default_type get_mean() const
const vector< size_t > & get_volumes() const
static constexpr uint8_t Bit
a filter to compute a whole brain mask from a DWI image.
const Eigen::MatrixXd & grad
a filter to compute the optimal threshold to mask a DataSet.
static Image scratch(const Header &template_header, const std::string &label="scratch image")
implements a progress meter to provide feedback to the user
constexpr I round(const T x)
FORCE_INLINE LoopAlongAxes Loop()
VectorType::Scalar value(const VectorType &coefs, typename VectorType::Scalar cos_elevation, typename VectorType::Scalar cos_azimuth, typename VectorType::Scalar sin_azimuth, int lmax)
void stash_DW_scheme(Header &header, const MatrixType &grad)
'stash' the DW gradient table
MR::default_type value_type
void clear_scheme(Header &header)
clear the phase encoding matrix from a header
double default_type
the default type used throughout MRtrix
std::string str(const T &value, int precision=0)