-
Notifications
You must be signed in to change notification settings - Fork 0
happy.io
Jan Kukačka edited this page Mar 11, 2022
·
2 revisions
Module for reading and writing files.
- load: load a file
- save: save data to a file
- ensure_folder: check if a folder exists and create it if not
Loads file. Handles multiple formats (.mat, .nii, .nii.gz, .hdr, .mha, .npy, .npz, .pkl, .json, .csv) and selects the appropriate method to open them.
-
filename
: string with the file path or file_info dictionary containing the "filename" record. -
kwargs
:-
key
: string. Key in .mat or .npz file. If no key is given, this method tries to infer it automatically and if multiple keys are available, returns the whole dictionary.
-
Saves data to a file. Supports various file formats (Nifti: .nii.gz, .gif, Pickle: .pkl)
-
filename
: string with the file path or file_info dictionary containing the "filename" record. -
data
: array or dict or whatever suitable data to save. -
overwrite
: bool. If the file exists, is it okay to overwrite it? Default False. -
parents
: bool. Should the parent directories be created if they don't already exist? Default False. -
kwargs
:-
is_vector
: for nifti images. Seesave_nifti
for details. -
spacing
: for nifti images. Seesave_nifti
for details. -
directoon
: for nifti images. Seesave_nifti
for details. -
origin
: for nifti images. Seesave_nifti
for details. -
key
: string. Key in .mat or .npz file.
-
Make sure a folder exists.
-
path
: path to the folder whose existence should be ensured
-
True
if it exists or was created,False
if this function failed to ensure its existence.