本文整理汇总了C++中math::Matrix::save方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::save方法的具体用法?C++ Matrix::save怎么用?C++ Matrix::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类math::Matrix
的用法示例。
在下文中一共展示了Matrix::save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: save_bvecs_bvals
void save_bvecs_bvals (const Image::Header& header, const std::string& path)
{
std::string bvecs_path, bvals_path;
if (path.size() >= 5 && path.substr (path.size() - 5, path.size()) == "bvecs") {
bvecs_path = path;
bvals_path = path.substr (0, path.size() - 5) + "bvals";
} else if (path.size() >= 5 && path.substr (path.size() - 5, path.size()) == "bvals") {
bvecs_path = path.substr (0, path.size() - 5) + "bvecs";
bvals_path = path;
} else {
bvecs_path = path + "bvecs";
bvals_path = path + "bvals";
}
const Math::Matrix<float>& grad (header.DW_scheme());
Math::Matrix<float> G (grad.rows(), 3);
// rotate vectors from scanner space to image space
Math::Matrix<float> D (header.transform());
Math::Permutation p (4);
int signum;
Math::LU::decomp (D, p, signum);
Math::Matrix<float> image2scanner (4,4);
Math::LU::inv (image2scanner, D, p);
Math::Matrix<float> rotation = image2scanner.sub (0,3,0,3);
Math::Matrix<float> grad_G = grad.sub (0, grad.rows(), 0, 3);
Math::mult (G, float(0.0), float(1.0), CblasNoTrans, grad_G, CblasTrans, rotation);
// deal with FSL requiring gradient directions to coincide with data strides
// also transpose matrices in preparation for file output
std::vector<size_t> order = Image::Stride::order (header, 0, 3);
Math::Matrix<float> bvecs (3, grad.rows());
Math::Matrix<float> bvals (1, grad.rows());
for (size_t n = 0; n < G.rows(); ++n) {
bvecs(0,n) = header.stride(order[0]) > 0 ? G(n,order[0]) : -G(n,order[0]);
bvecs(1,n) = header.stride(order[1]) > 0 ? G(n,order[1]) : -G(n,order[1]);
bvecs(2,n) = header.stride(order[2]) > 0 ? G(n,order[2]) : -G(n,order[2]);
bvals(0,n) = grad(n,3);
}
bvecs.save (bvecs_path);
bvals.save (bvals_path);
}