tract_querier.tractography

Functions

tract_querier.tractography.tractography_from_file(...)

tract_querier.tractography.tractography_from_files(...)

tract_querier.tractography.tractography_to_file(...)

class tract_querier.tractography.Tractography(tracts=None, tracts_data=None, validate=True, **kwargs)[source]

Bases: object

Class to represent a tractography dataset

Parameters:
tractslist of float array N_i\times 3

Each element of the list is a tract represented as point array, the length of the i-th tract is N_i

tracts_datadict of <data name>= list of float array of N_i\times M

Each element in the list corresponds to a tract, N_i is the length of the i-th tract and M is the number of components of that data type.

validatebool

Check that tracts and tracts_data are valid

Attributes:
extra_args

Methods

add_tract_data_from_array(name, array)

Add a new data element reproducing a constant data value for each of the $M$ tracts.

append(tracts[, tracts_data, validate])

Append tracts and corresponding data to the current set

filter_tracts(criterium)

Filter the tracts in the set according to a criterium function

filtered_tracts_map()

Tract indices included after the filtering

original_tracts()

Tract set used to original construct this tractography object, no subsampling or filtering applied

original_tracts_data()

Tract data contained of the original dataset of this tractography object

subsample_tracts(points_per_tract)

Subsample the tracts in the dataset to a maximum number of points per tract

tracts()

Tracts contained in this tractography object after filtering and subsampling if these operations have been applied

tracts_data()

Tract data contained in this tractography object after filtering and subsampling if these operations have been applied

unfilter_tracts()

Reset any filtering applied to the tracts

unsubsample_tracts()

Reset any subsampling applied to the tracts

are_tracts_filtered

are_tracts_subsampled

property extra_args
append(tracts, tracts_data=None, validate=True)[source]

Append tracts and corresponding data to the current set

Parameters:
tractslist of float array N_i\times 3

Each element of the list is a tract represented as point array, the length of the i-th tract is N_i

tracts_datadict of <data name>= list of float array of N_i\times M

Each element in the list corresponds to a tract, N_i is the length of the i-th tract and M is the number of components of that data type.

validatebool

Check that tracts and tracts_data are valid

unsubsample_tracts()[source]

Reset any subsampling applied to the tracts

unfilter_tracts()[source]

Reset any filtering applied to the tracts

subsample_tracts(points_per_tract)[source]

Subsample the tracts in the dataset to a maximum number of points per tract

Parameters:
points_per_tract: int

Maximum number of points per tract after the operation is executed

filter_tracts(criterium)[source]

Filter the tracts in the set according to a criterium function

Parameters:
criteriumfunction of array N\times 3 -> Bool

A function taking a tract as an array of 3D points and returning True or False with specifying if it should be included

are_tracts_filtered()[source]
are_tracts_subsampled()[source]
original_tracts()[source]

Tract set used to original construct this tractography object, no subsampling or filtering applied

Returns:
tractslist of float array N_i\times3

Each element of the list is a tract represented as point array, the length of the i-th tract is N_i

original_tracts_data()[source]

Tract data contained of the original dataset of this tractography object

Returns:
tract datadict of <data name>= list of float array of N_i\times M

Each element in the list corresponds to a tract, N_i is the length of the i-th tract and M is the number of components of that data type.

filtered_tracts_map()[source]

Tract indices included after the filtering

Returns:
List of tract indices included after the filtering
tracts()[source]

Tracts contained in this tractography object after filtering and subsampling if these operations have been applied

Returns:
tractslist of float array N_i\times 3

Each element of the list is a tract represented as point array, the length of the i-th tract is N_i

tracts_data()[source]

Tract data contained in this tractography object after filtering and subsampling if these operations have been applied

Returns:
tract datadict of <data name>= list of float array of N_i\times M

Each element in the list corresponds to a tract, N_i is the length of the i-th tract and M is the number of components of that data type.

add_tract_data_from_array(name, array)[source]

Add a new data element reproducing a constant data value for each of the $M$ tracts.

After execution, the tract data will have a new set original_tracts_data()[name][i][:] == array[i]

Parameters:
namestr

Name of the new data element

arrayarray of length $M$

Data value for each tract

tract_querier.tractography.tractography_from_trackvis_file(filename)[source]
tract_querier.tractography.tractography_to_trackvis_file(filename, tractography, affine=None, image_dimensions=None)[source]
tract_querier.tractography.tractography_from_files(filenames)[source]
tract_querier.tractography.tractography_from_file(filename)[source]
tract_querier.tractography.tractography_to_file(filename, tractography, **kwargs)[source]
tract_querier.tractography.tractography_from_vtk_files(vtk_file_names)[source]
tract_querier.tractography.tractography_to_vtk_file(vtk_file_name, tractography)[source]
tract_querier.tractography.vtkPolyData_to_tracts(polydata, return_tractography_object=True)[source]

Reads a VTKPolyData object and outputs a tracts/tracts_data pair

Parameters:
polydatavtkPolyData

VTKPolyData Object

Returns:
tractslist of float array N_ix3

Each element of the list is a tract represented as point array, the length of the i-th tract is N_i

tract_datadict of <data name>= list of float array of N_ixM

Each element in the list corresponds to a tract, N_i is the length of the i-th tract and M is the number of components of that data type.

tract_querier.tractography.tracts_to_vtkPolyData(tracts, tracts_data={}, lines_indices=None)[source]