export#

Functions#

array_to_checksum(arr)

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

array_to_image(arr, filename[, format, norm])

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

array_to_npy(arr, filename)

Save a numpy array to npy-file.

array_to_mat(arr, filename)

Save a numpy array to a mat-file.

array_to_pickle(arr, filename)

Save a numpy array to a pickle-file.

arrays_to_checksum(stim[, keys])

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

to_json(stim, filename)

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

to_mat(stim, filename)

Save stimulus-dict(s) as mat-file

to_pickle(stim, filename)

Save stimulus-dict(s) as pickle-file

stimupy.utils.export.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

stimupy.utils.export.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

stimupy.utils.export.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.

stimupy.utils.export.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.

stimupy.utils.export.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.

stimupy.utils.export.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]

stimupy.utils.export.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.

stimupy.utils.export.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.

stimupy.utils.export.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.