mdt.lib.file_conversions package

Submodules

mdt.lib.file_conversions.npy module

mdt.lib.file_conversions.npy.load_all_npy_files(directory)[source]

Load all the npy files in the given directory.

Parameters:directory (str) – the directory to load the npy files in
Returns:
the loaded npy files with as keys the filename (without the .npy extension) and as value the
memory mapped array
Return type:dict
mdt.lib.file_conversions.npy.samples_npy_to_nifti(samples_npy_fname, used_mask, nifti_header, nifti_fname=None)[source]

Convert a npy file containing sample results to a nifti file.

Since the sample npy files are stored as a two dimensional matrix (with on the first axis the ROI index number and on the second the samples), we need to have the lookup table for the spatial information about the samples.

Parameters:
  • samples_npy_fname (str) – the filename of the samples file to convert
  • used_mask (ndarray or str) – either an three dimensional matrix with the mask or a path to a nifti file.
  • nifti_header (nibabel header) – the header to use for writing the nifti file
  • nifti_fname (str) – the filename of the nifti file. If not given it defaults to the same directory as the samples file.
mdt.lib.file_conversions.npy.volume_map_npy_to_nifti(npy_fname, nifti_header, nifti_fname=None)[source]

Convert a volume-map npy file to a nifti file.

Parameters:
  • npy_fname (str) – the filename of the npy file to load
  • nifti_header (nibabel header) – the header file for the nifti
  • nifti_fname (str) – the filename of the nifti file. If not given it defaults to the same directory as the npy file.

Module contents