コード例 #1
0
ファイル: gdti.py プロジェクト: rcherbonnier/caps-clindmri
def tensor2odf(tensors, b, order):
    """ Compute a Cartesian Tensor ODF from a given Higher-order diffusion
    tensor
    Parameters
    ----------
    tensors: list of array [e,] (mandatory)
        a list with tensor independent coefficients
    b: float (mandatory)
        the diffusion b-value

    Returns
    -------
    odfs list of array [e,]
        a list of tensor independant coefficients

    Reference
        Barmpoutnis
    """
    # Unit vectors [321,3]
    g = numpy.loadtxt(get_sphere("symmetric321"))

    # Construct basis
    G = construct_matrix_of_monomials(g, order)
    C = construct_set_of_polynomials(order).T
    BG = construct_matrix_of_integrals(g, order, 100)
    B = numpy.dot(BG, C)

    # loop over elements
    odfs = []
    for tensor in tensors:
        x = scipy.optimize.nnls(B, numpy.exp(-b * numpy.dot(G, tensor)))[0]
        odfs.append(numpy.dot(C, x))

    return odfs
コード例 #2
0
ファイル: gdti.py プロジェクト: dgoyard/caps-clindmri
def tensor2odf(tensors, b, order):
    """ Compute a Cartesian Tensor ODF from a given Higher-order diffusion
    tensor
    Parameters
    ----------
    tensors: list of array [e,] (mandatory)
        a list with tensor independent coefficients
    b: float (mandatory)
        the diffusion b-value

    Returns
    -------
    odfs list of array [e,]
        a list of tensor independant coefficients

    Reference
        Barmpoutnis
    """
    # Unit vectors [321,3]
    g = numpy.loadtxt(get_sphere("symmetric321"))

    # Construct basis
    G = construct_matrix_of_monomials(g, order)
    C = construct_set_of_polynomials(order).T
    BG = construct_matrix_of_integrals(g, order, 100)
    B = numpy.dot(BG, C)

    # loop over elements
    odfs = []
    for tensor in tensors:
        x = scipy.optimize.nnls(B, numpy.exp(-b * numpy.dot(G, tensor)))[0]
        odfs.append(numpy.dot(C, x))

    return odfs
コード例 #3
0
ファイル: gdti.py プロジェクト: dgoyard/caps-clindmri
def quartic_tensor_odf_fit(data_flat, mask_flat, reference_flat, bvals, bvecs,
                            order, delta=100., min_signal=1.,
                            number_of_workers=1):
    """ Compute a Cartesian tensor Odf from a given DW dataset.

    Parameters
    ----------
    data_flat: array (mandatory)
        flattened diffusion data array.
    mask_flat: array (mandatory)
        flattened mask data array.
    reference_flat: array (mandatory)
        flattened reference b0 data array.
    bvals: array (mandatory)
        the diffusion b-values.
    bvecs: array (mandatory)
        the diffusion b-vectors.
    order: int (mandatory)
        the diffusion tensor order.
    delta: float (optional, default 100.)
        the ODF kernel.
    min_signal: float (optional, default 1.)
        replace diffusion signal smaller than this threshold.
    number_of_workers: int (optional, default 1)
        the number of CPUs used during the execution.

    Returns
    -------
    dti_parameters: array [N, e]
        the odf tensor independant coefficients:
        multiplicity is included in tensor coefficients.

   Reference
       Barmpoutnis
    """
    # Contruct basis
    C = construct_set_of_polynomials(order).T
    BG = construct_matrix_of_integrals(bvecs, order, delta)
    B = numpy.dot(BG, C)
    e = C.shape[0]

    # Allocate
    dti_parameters = numpy.empty((len(data_flat), e))

    # NNLS
    nb_cpus = None
    if number_of_workers > 0:
        nb_cpus = number_of_workers
    results = multi_processing(
        nnls_multi, nb_cpus,
        data_flat, reference_flat,
        itertools.repeat(B), itertools.repeat(C),
        itertools.repeat(min_signal), mask_flat,
        itertools.repeat(False))

    # Format result
    for cnt, item in enumerate(results):
        dti_parameters[cnt] = item

    return dti_parameters
コード例 #4
0
ファイル: gdti.py プロジェクト: rcherbonnier/caps-clindmri
def quartic_tensor_odf_fit(data_flat,
                           mask_flat,
                           reference_flat,
                           bvals,
                           bvecs,
                           order,
                           delta=100.,
                           min_signal=1.,
                           number_of_workers=1):
    """ Compute a Cartesian tensor Odf from a given DW dataset.

    Parameters
    ----------
    data_flat: array (mandatory)
        flattened diffusion data array.
    mask_flat: array (mandatory)
        flattened mask data array.
    reference_flat: array (mandatory)
        flattened reference b0 data array.
    bvals: array (mandatory)
        the diffusion b-values.
    bvecs: array (mandatory)
        the diffusion b-vectors.
    order: int (mandatory)
        the diffusion tensor order.
    delta: float (optional, default 100.)
        the ODF kernel.
    min_signal: float (optional, default 1.)
        replace diffusion signal smaller than this threshold.
    number_of_workers: int (optional, default 1)
        the number of CPUs used during the execution.

    Returns
    -------
    dti_parameters: array [N, e]
        the odf tensor independant coefficients:
        multiplicity is included in tensor coefficients.

   Reference
       Barmpoutnis
    """
    # Contruct basis
    C = construct_set_of_polynomials(order).T
    BG = construct_matrix_of_integrals(bvecs, order, delta)
    B = numpy.dot(BG, C)
    e = C.shape[0]

    # Allocate
    dti_parameters = numpy.empty((len(data_flat), e))

    # NNLS
    nb_cpus = None
    if number_of_workers > 0:
        nb_cpus = number_of_workers
    results = multi_processing(nnls_multi, nb_cpus, data_flat, reference_flat,
                               itertools.repeat(B), itertools.repeat(C),
                               itertools.repeat(min_signal), mask_flat,
                               itertools.repeat(False))

    # Format result
    for cnt, item in enumerate(results):
        dti_parameters[cnt] = item

    return dti_parameters