mct package¶
Subpackages¶
- mct.cli_scripts package
- Submodules
- mct.cli_scripts.mct_calculate_noise_covariance_matrix module
- mct.cli_scripts.mct_calculate_tnsr module
- mct.cli_scripts.mct_combine_weighted_sum module
- mct.cli_scripts.mct_list_devices module
- mct.cli_scripts.mct_list_methods module
- mct.cli_scripts.mct_method_info module
- mct.cli_scripts.mct_reconstruct module
- mct.cli_scripts.mct_split_volumes module
- Module contents
- mct.reconstruction_methods package
Submodules¶
mct.components_loader module¶
-
mct.components_loader.
get_reconstruction_method_class
(method_name)[source]¶ Load the class of the requested reconstruction method without instantiation.
Parameters: method_name (str) – the name of the reconstruction method to load Returns: the class of the requested reconstruction method Return type: type[mct.processing.ReconstructionMethod] Raises: ValueError
– if the requested method could not be found
-
mct.components_loader.
list_reconstruction_methods
()[source]¶ Get a list of the reconstruction methods by name.
Returns: the list of reconstruction methods Return type: list[str]
-
mct.components_loader.
load_reconstruction_method
(method_name, *args, **kwargs)[source]¶ Load the requested reconstruction method as an object.
Parameters: - method_name (str) – the name of the reconstruction method to load
- *args – passed to the constructor of the requested method
- **kwargs – passed to the constructor of the requested method
Returns: the class of the requested reconstruction method
Return type: mct.processing.ReconstructionMethod
Raises: ValueError
– if the requested method could not be found
mct.reconstruction module¶
-
class
mct.reconstruction.
ReconstructionMethod
[source]¶ Bases:
object
A reconstruction method reconstructs volume(s) from multiple channels.
-
command_line_info
= '\n No info defined for this method.\n '¶
-
reconstruct
(output_directory, volumes=None)[source]¶ Reconstruct the given channels and place the result in a subdirectory in the given directory.
Parameters: - output_directory (str) – the location for the output files
- volumes (list of int) – the indices of the volume we want to reconstruct (0-based).
Returns: the set of results from this reconstruction method
Return type: dict
-
-
class
mct.reconstruction.
SliceBySliceReconstructionMethod
(channels, **kwargs)[source]¶ Bases:
mct.reconstruction.ReconstructionMethod
Create a basic reconstruction method initialized with the given data and settings.
Parameters: - channels (list) – the list of input nifti files, one for each channel element. Every nifti file should be a 4d matrix with on the 4th dimension the time series. The length of this list equals the number of channels.
- slicing_axis (int) – the (x,y,z) axis over which we will loop to reconstruct the volumes. 0=x, 1=y, 2=z.
-
reconstruct
(output_directory, volumes=None)[source]¶ Reconstruct the given channels and place the result in a subdirectory in the given directory.
Parameters: - output_directory (str) – the location for the output files
- volumes (list of int) – the indices of the volume we want to reconstruct (0-based).
Returns: the set of results from this reconstruction method
Return type: dict
mct.utils module¶
-
class
mct.utils.
UnzippedNiftis
(input_filenames, tmp_dir)[source]¶ Bases:
collections.abc.Sequence
Given a list of nifti filenames, this sequence will expose them as (unzipped) nibabel nifti files.
That is, each element of this sequence is a loaded nifti file, loaded using
load_nifti(file_name)
. If one or more of the input niftis are zipped, this class will unzip them to the temporary location and then exposes those as the opened nifti files. At deconstruction, the unzipped niftis will be removed.Parameters: - input_filenames (list of str) – the list of input filenames
- tmp_dir (str) – the location for storing unzipped versions of zipped nifti files
-
mct.utils.
calculate_noise_covariance_matrix
(input_data, normalize=False)[source]¶ Obtain noise covariance matrix from raw data.
The input data (the raw data) is expected to be in complex k-space or x-space.
This function supports 1d, 2d, 3d noise volumes as input and assumes that the noise data of the channels are in the last dimension.
Parameters: - input_data (str) – the input data
- normalise (bool) – If True, then the calculated noise matrix will be normalised.
Returns: a square matrix of the number of channels
Return type: ndarray
-
mct.utils.
calculate_tsnr
(data, axis=-1)[source]¶ Calculate the tSNR of the given data.
By default this will calculate the tSNR on the last axis of the input array. The tSNR is defined as the
mean(data) / std(data)
.Parameters: - data (ndarray) – the data we want to calculate the tSNR off
- axis (int) – the axis on which to compute the tSNR
-
mct.utils.
combine_weighted_sum
(input_channels, weights, output_filename)[source]¶ Combine all the coils using the given weights.
Parameters: - input_channels (list of str) – the list with the input channel filenames
- weights (str or ndarray) – the weights to use for the reconstruction.
- output_filename (str) – the output filename
-
mct.utils.
get_cl_devices
()[source]¶ Get a list of all CL devices in the system.
The indices of the devices can be used in the model fitting/sample functions for ‘cl_device_ind’.
Returns: A list of CLEnvironments, one for each device in the system.
-
mct.utils.
get_mot_config_context
(cl_device_ind)[source]¶ Get the configuration context that uses the given devices by index.
Parameters: cl_device_ind (int or list of int) – the device index or a list of device indices Returns: the configuration action to use Return type: mot.configuration.ConfigAction
-
mct.utils.
load_nifti
(nifti_volume)[source]¶ Load and return a nifti file.
This will apply path resolution if a filename without extension is given. See the function
nifti_filepath_resolution()
for details.Parameters: nifti_volume (string) – The filename of the volume to use. Returns: nibabel.spatialimages.SpatialImage
-
mct.utils.
split_write_volumes
(input_file, output_dir, axis=-1)[source]¶ Split and write the given input volume to separate nifti files.
Parameters: - input_file (str) – the input nifti file to split
- output_dir (str) – the output directory, this will write the split volumes to that directory with the same basename as the input file, with the slice index appended
- axis (int) – the axis to split on