eigenstrapping.datasets.txt2memmap

eigenstrapping.datasets.txt2memmap(dist_file, output_dir, prefix=None, suffix=None, maskfile=None, delimiter=' ')[source]

Export distance matrix to memory-mapped array.

Parameters:
  • dist_file (filename) – Path to delimiter-separated distance matrix file

  • output_dir (filename) – Path to directory in which output files will be written

  • prefix (str) – Prefix to add to start of filenames {‘distmat.npy’, ‘index.npy’}, default None

  • suffix (str) – Suffix to add to end of filenames {‘distmat.npy’, ‘index.npy’}, default None

  • maskfile (filename or np.ndarray or None, default None) – Path to a neuroimaging/txt file containing a mask, or a mask represented as a numpy array. Mask scalars are cast to boolean, and all elements not equal to zero will be masked.

  • delimiter (str) – Delimiting character in dist_file

Returns:

Keys are ‘D’ and ‘index’; values are absolute paths to the corresponding binary files on disk.

Return type:

dict

Notes

Each row of the distance matrix is sorted before writing to file. Thus, a second mem-mapped array is necessary, the i-th row of which contains argsort(d[i]). If maskfile is not None, a binary mask.txt file will also be written to the output directory.

:raises IOError : output_dir doesn’t exist: :raises ValueError : Mask image and distance matrix have inconsistent sizes: