Function compute_T1_M0

Computes first step of pixel-wise fitting of 3 parameters

Contents

Input

Output

Copyrights

(C) All rights reserved.

The code may be used free of charge for non-commercial and educational purposes, the only requirement is that this text is preserved within the derivative work. For any other purpose you must contact the authors for permission. This code may not be redistributed without written permission from the authors.

ABOUT: This software implements basic functionalities of the FIR-MAP algorithm

IMPORTANT: If you use this software you should cite the following in any resulting publication: [1] Michal Staniszewski and Uwe Klose. Improvements of Fast Model-based Acceleration of Parameter Look-Locker T1 Mapping

function [ T1s, M0, M0s, k_factor] = compute_T1_M0( n_size, cons_model_sos, maske, timeInterval, n_iter, T1s, M0, M0s )

    nr = n_size(3); % number of image rows
    k_factor = zeros(nr,nr);
    x = timeInterval';

    % iterate in parallel version
    parfor b=1:nr
        ok_tmp = cons_model_sos(:,:,b); % magnetization curves
        fprintf(['Iter #',num2str(n_iter),'. Compute T1* M0 M0s. Reconstructing col #',num2str(b),'\n']);
        for a=1:nr
            if (logical(maske(a,b)))
                ok = ok_tmp(:,a);
                [ypos,pos] = min(ok);
                ok(1:pos(1)) = 2*ypos - ok(1:pos(1)); % shift curve
                init_guess = [M0s(a,b) T1s(a,b) M0(a,b)];
                expfn = @(p,xd) p(1)-(p(3)+p(1))*exp(-xd/p(2));  % define M(t)
                try
                    pfit = nlinfit(x,ok,expfn,init_guess); % faster non-linear regression
                catch
                    errfn = @(p) sum((expfn(p,x)-ok).^2);  % define sum-squared error
                    pfit = fminsearch(errfn, init_guess);     %run the minimizer - more stable in case of problems
                end
                T1s(a,b) = pfit(2);
                M0s(a,b) = pfit(1);
                M0(a,b) = pfit(3);
                k_factor(a,b) = M0(a,b)/M0s(a,b);
            end
        end
    end
end