Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mcencini committed Jan 24, 2024
1 parent 86e53f8 commit ad31f66
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions src/deepmr/io/generic/hdf5.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
)


def read_hdf5(filename: str) -> dict:
def read_hdf5(filepath):
"""
Read HDF5 file as a Python dictionary
Parameters
----------
filename : str
filepath : str
Path to file on disk.
Returns
Expand Down Expand Up @@ -64,20 +64,20 @@ def read_hdf5(filename: str) -> dict:
'someinfo'
"""
filename = get_filepath(filename, True, "h5")
with h5py.File(filename, "r") as h5file:
filepath = get_filepath(filepath, True, "h5")
with h5py.File(filepath, "r") as h5file:
return _recursively_load_dict_contents_from_group(h5file, "/")


def write_hdf5(input: dict, filename: str):
def write_hdf5(input, filepath):
"""
Write a given dictionary to HDF5 file.
Parameters
----------
input : dict
Input dictionary.
filename : str
filepath : str
Path to file on disk.
Example
Expand All @@ -96,7 +96,7 @@ def write_hdf5(input: dict, filename: str):
"""
input = copy.deepcopy(input)
with h5py.File(filename, "w") as h5file:
with h5py.File(filepath, "w") as h5file:
_recursively_save_dict_contents_to_group(h5file, "/", input)


Expand Down
12 changes: 6 additions & 6 deletions src/deepmr/io/generic/matlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
from .pathlib import get_filepath


def read_matfile(filename, return_fullpath=False):
def read_matfile(filepath, return_fullpath=False):
"""
Read matfile as a Python dictionary.
Automatically handle legacy and HDF5 (i.e., -v7.3) formats.
Parameters
----------
filename : str
filepath : str
Path of the file on disk.
return_fullpath : bool, optional
If True, also return expanded file path. The default is False.
Expand Down Expand Up @@ -58,15 +58,15 @@ def read_matfile(filename, return_fullpath=False):
[1]: https://github.com/skjerns/mat7.3/tree/master
"""
filename = get_filepath(filename, True, "mat")
filepath = get_filepath(filepath, True, "mat")
try:
matfile = scipy.io.loadmat(filename)
matfile = scipy.io.loadmat(filepath)
matfile.pop("__globals__", None)
matfile.pop("__header__", None)
matfile.pop("__version__", None)
except:
matfile = mat73.loadmat(filename)
matfile = mat73.loadmat(filepath)

if return_fullpath:
return matfile, filename
return matfile, filepath
return matfile

0 comments on commit ad31f66

Please sign in to comment.