stimupy.utils.export#

Functions#

array_to_checksum

Hash (md5) array values, and return hex-checksum

array_to_image

Save a 2D numpy array as a grayscale image file.

array_to_npy

Save a numpy array to npy-file.

array_to_mat

Save a numpy array to a mat-file.

array_to_pickle

Save a numpy array to a pickle-file.

arrays_to_checksum

Hash (md5) values of arrays specified in keys, and save only the hex

to_json

Save stimulus-dict(s) as (pretty) JSON

to_mat

Save stimulus-dict(s) as mat-file

to_pickle

Save stimulus-dict(s) as pickle-file

array_to_checksum(arr)[source]#

Hash (md5) array values, and return hex-checksum

Parameters:

arr (numpy.ndarray) – array to be hashed.

Returns:

hex-string representation of hash (MD5) of given array

Return type:

str

array_to_image(arr, filename, format=None, norm=True)[source]#

Save a 2D numpy array as a grayscale image file.

Parameters:
  • arr (numpy.ndarray) – array to be exported. Values will be cropped to [0,255].

  • filename (Path or str) – (full) path to the file to be created.

  • norm (bool) – multiply array by 255, by default True

array_to_npy(arr, filename)[source]#

Save a numpy array to npy-file.

Parameters:
  • arr (numpy.ndarray) – array to be exported.

  • filename (Path or str) – (full) path to the file to be created.

array_to_mat(arr, filename)[source]#

Save a numpy array to a mat-file.

Parameters:
  • arr (numpy.ndarray) – array to be exported.

  • filename (Path or str) – (full) path to the file to be created.

array_to_pickle(arr, filename)[source]#

Save a numpy array to a pickle-file.

Parameters:
  • arr (numpy.ndarray) – array to be exported.

  • filename (Path or str) – (full) path to the file to be created.

arrays_to_checksum(stim, keys=['img', 'mask'])[source]#

Hash (md5) values of arrays specified in keys, and save only the hex

Parameters:
  • stim (dict) – stimulus dictionary to export.

  • keys (str of list of str) – keys of dict for which the hashing should be performed

Returns:

same as input dict but keys now only contain the hex

Return type:

dict[str, Any]

to_json(stim, filename)[source]#

Save stimulus-dict(s) as (pretty) JSON

Parameters:
  • stim (dict) – stimulus dictionary to export.

  • filename (Path or str) – (full) path to the file to be created.

to_mat(stim, filename)[source]#

Save stimulus-dict(s) as mat-file

Parameters:
  • stim (dict) – stimulus dictionary to export.

  • filename (Path or str) – (full) path to the file to be created.

to_pickle(stim, filename)[source]#

Save stimulus-dict(s) as pickle-file

Parameters:
  • stim (dict) – stimulus dictionary to export.

  • filename (Path or str) – (full) path to the file to be created.