tedana.utils.utils¶
Utilities for tedana package
Functions
andb (arrs) |
Sums arrays in arrs |
dice (arr1, arr2) |
Compute Dice’s similarity index between two numpy arrays. |
filewrite (data, filename, ref_img[, gzip, …]) |
Writes data to filename in format of ref_img |
fitgaussian (data) |
Returns estimated gaussian parameters of a 2D distribution found by a fit |
gaussian (height, center_x, center_y, …) |
Returns gaussian function |
get_dtype (data) |
Determines neuroimaging format of data |
getfbounds (n_echos) |
Gets estimated F-statistic boundaries based on number of echos |
load_data (data[, n_echos]) |
Coerces input data files to required 3D array output |
load_image (data) |
Takes input data and returns a sample x time array |
make_adaptive_mask (data[, minimum, getsum]) |
Makes map of data specifying longest echo a voxel can be sampled with |
make_gii_darray (ref_array, data[, copy_meta]) |
Converts data into GiftiDataArray format like ref_array |
make_min_mask (data) |
Generates a 3D mask of data |
moments (data) |
Returns gaussian parameters of a 2D distribution by calculating its moments |
new_gii_like (ref_img, data[, copy_header, …]) |
Coerces data into GiftiImage format like ref_img |
new_nii_like (ref_img, data[, affine, …]) |
Coerces data into NiftiImage format like ref_img |
unmask (data, mask) |
Unmasks data using non-zero entries of mask |
-
andb
(arrs)[source]¶ Sums arrays in arrs
Parameters: arrs (list) – List of boolean or integer arrays to be summed Returns: result – Integer array of summed arrs Return type: numpy.ndarray
-
dice
(arr1, arr2)[source]¶ Compute Dice’s similarity index between two numpy arrays. Arrays will be binarized before comparison.
Parameters: arr2 (arr1,) – Input arrays, arrays to binarize and compare. Returns: dsi – Dice-Sorenson index. Return type: float References
-
filewrite
(data, filename, ref_img, gzip=False, copy_header=True, copy_meta=False)[source]¶ Writes data to filename in format of ref_img
If ref_img dtype is GIFTI, then data is assumed to be stacked L/R hemispheric and will be split and saved as two files
Parameters: - data ((S [x T]) array_like) – Data to be saved
- filename (str) – Filepath where data should be saved to
- ref_img (str or img_like) – Reference image
- gzip (bool, optional) – Whether to gzip output (if not specified in filename). Only applies if output dtype is NIFTI. Default: False
- copy_header (bool, optional) – Whether to copy header from ref_img to new image. Default: True
- copy_meta (bool, optional) – Whether to copy meta from ref_img to new image. Only applies if output dtype is GIFTI. Default: False
Returns: name – Path of saved image (with added extensions, as appropriate)
Return type:
-
fitgaussian
(data)[source]¶ Returns estimated gaussian parameters of a 2D distribution found by a fit
Parameters: data (array_like) – 2D data array Returns: p – Array with height, center_x, center_y, width_x, width_y of data Return type: array_like References
-
gaussian
(height, center_x, center_y, width_x, width_y)[source]¶ Returns gaussian function
Parameters: Returns: Gaussian function with provided parameters
Return type: lambda
References
-
get_dtype
(data)[source]¶ Determines neuroimaging format of data
Parameters: data (list-of-str or str or img_like) – Data to determine format of Returns: dtype – Format of input data Return type: {‘NIFTI’, ‘GIFTI’, ‘OTHER’} str
-
getfbounds
(n_echos)[source]¶ Gets estimated F-statistic boundaries based on number of echos
Parameters: n_echos (int) – Number of echoes Returns: fmin, fmid, fmax – Minimum, mid, and max F bounds Return type: float
-
load_data
(data, n_echos=None)[source]¶ Coerces input data files to required 3D array output
Parameters: - data ((X x Y x M x T) array_like or list-of-img_like) – Input multi-echo data array, where X and Y are spatial dimensions, M is the Z-spatial dimensions with all the input echos concatenated, and T is time. A list of image-like objects (e.g., .nii or .gii) are accepted, as well
- n_echos (int, optional) – Number of echos in provided data array. Only necessary if data is array_like. Default: None
Returns: - fdata ((S x E x T)
numpy.ndarray
) – Output data where S is samples, E is echos, and T is time - ref_img (str) – Filepath to reference image for saving output files
-
load_image
(data)[source]¶ Takes input data and returns a sample x time array
Parameters: data ((X x Y x Z [x T]) array_like or img_like object) – Data array or data file to be loaded and reshaped Returns: fdata – Reshaped data, where S is samples and T is time Return type: (S [x T]) numpy.ndarray
-
make_adaptive_mask
(data, minimum=True, getsum=False)[source]¶ Makes map of data specifying longest echo a voxel can be sampled with
Parameters: Returns: - mask ((S, )
numpy.ndarray
) – Boolean array of voxels that have sufficient signal in at least one echo - masksum ((S, )
numpy.ndarray
) – Valued array indicating the number of echos with sufficient signal in a given voxel. Only returned if getsum = True
- mask ((S, )
-
make_gii_darray
(ref_array, data, copy_meta=False)[source]¶ Converts data into GiftiDataArray format like ref_array
Parameters: Returns: gii – Output data array instance
Return type:
-
make_min_mask
(data)[source]¶ Generates a 3D mask of data
Only samples that are consistently (i.e., across time AND echoes) non-zero in data are True in output
Parameters: data ((S x E x T) array_like) – Multi-echo data array, where S is samples, E is echos, and T is time Returns: mask – Boolean array Return type: (S, ) numpy.ndarray
-
moments
(data)[source]¶ Returns gaussian parameters of a 2D distribution by calculating its moments
Parameters: data (array_like) – 2D data array Returns: - height (float)
- center_x (float)
- center_y (float)
- width_x (float)
- width_y (float)
References
-
new_gii_like
(ref_img, data, copy_header=True, copy_meta=False)[source]¶ Coerces data into GiftiImage format like ref_img
Parameters: Returns: gii – GiftiImage
Return type:
-
new_nii_like
(ref_img, data, affine=None, copy_header=True)[source]¶ Coerces data into NiftiImage format like ref_img
Parameters: Returns: nii – NiftiImage
Return type:
-
unmask
(data, mask)[source]¶ Unmasks data using non-zero entries of mask
Parameters: - data ((M [x E [x T]]) array_like) – Masked array, where M is the number of True values in mask
- mask ((S,) array_like) – Boolean array of S samples that was used to mask data. It should have exactly M True values.
Returns: out – Unmasked data array
Return type: (S [x E [x T]])
numpy.ndarray