Classes

LinearOperator

class talon.core.LinearOperator(generators, indices_of_generators, weights)[source]
__init__(generators, indices_of_generators, weights)[source]

Linear operator that maps tractography to signal space. The linear operator can be used to compute products with a vector.

Parameters
  • generators – np.array where each row is a generator.

  • indices_of_generators – COO sparse matrix that tells which generator is called where in the linear operator.

  • weights – COO sparse matrix that encodes the weight applied to each generator indexed by indices_of_generators. It has the same dimension as indices_of_generators.

Raises
  • TypeError – If generators is not a numpy ndarray of float.

  • TypeError – If indices_of_generators is not a COO scipy matrix.

  • TypeError – If weights is not a COO scipy matrix of float64.

  • ValueError – If weights does not have the same dimension as indices_of_generators.

  • ValueError – If weights and indices_of_generators don’t have the same sparsity pattern.

property columns

Returns the indices of the nonzero columns.

Type

int

property generator_length

length of each generator (constant across generators).

Type

int

property generators

Returns the generators of the linear operator.

Type

np.ndarray

property indices

Returns the generator indices.

Type

np.ndarray

property nb_atoms

Number of atoms (columns) in the linear operator.

Type

int

property nb_data

Number of data points.

Type

int

property nb_generators

Number of generators.

Type

int

property rows

Returns the indices of the nonzero rows.

Type

int

property shape

Shape of the linear operator.

The shape is given by the number of rows and columns of the linear operator. The number of rows is equal to the number of data points times the length of the generators. The number of columns is equal to the number of atoms.

Type

tuple of int

todense()[source]

Return the dense matrix associated to the linear operator.

Note

The output of this method can be very memory heavy to store. Use at your own risk.

Returns

full matrix representing the linear operator.

Return type

ndarray

property transpose

the transpose of the linear operator.

Type

TransposedLinearOperator

property weights

The weights of the nonzero elements

Type

np.ndarray

ConcatenatedLinearOperator

class talon.core.ConcatenatedLinearOperator(operators, axis)[source]
__init__(operators, axis)[source]

Concatenated LinearOperator object

The ConcatenatedLinearOperator class implements the vertical or horizontal concatenation of LinearOperator objects. It is endowed with the multiplication operation (@).

Parameters
  • operators – list or tuple of LinearOperator objects to be concatenated in the same axis.

  • axis – int direction in which we want to concatenate the LinearOperator or ConcatenatedLinearOperator objects that we want to concatenate. Vertical concatenation is obtained for axis = 0 and horizontal concatenation is obtained for axis = 1 as in np.concatenate. (Default: 0)

Raises
  • TypeError – If any element of operator is not an instance of LinearOperator or ConcatenatedLinearOperator.

  • TypeError – If operators is not a list or a tuple.

  • ValueError – If axis is not 0 or 1.

  • ValueError – If operators is an empty list or tuple.

  • ValueError – If the operators do not have compatible dimensions.

property axis

axis in which the concatenation was performed.

Type

int

property operators

list of concatenated operators.

Type

list

property shape

Shape of the concatenated linear operator.

Type

tuple of int

todense()[source]

Return the dense matrix associated to the linear operator.

Note

The output of this method can be very memory heavy to store. Use at your own risk.

Returns

full matrix representing the linear operator.

Return type

ndarray

property transpose

transpose of the linear operator.

Type

TransposedConcatenatedLinearOperator