def get_all_nifti_data(directory, map_names=None, deferred=True):
"""Get the data of all the nifti volumes in the given directory.
If map_names is given we will only load the given map names. Else, we load all .nii and .nii.gz files in the
given directory.
Args:
directory (str): the directory from which we want to read a number of maps
map_names (list of str): the names of the maps we want to use. If given, we only use and return these maps.
deferred (boolean): if True we return an deferred loading dictionary instead of a dictionary with the values
loaded as arrays.
Returns:
dict: A dictionary with the volumes. The keys of the dictionary are the filenames
without the extension of the .nii(.gz) files in the given directory.
"""
proxies = load_all_niftis(directory, map_names=map_names)
if deferred:
return DeferredActionDict(lambda _, item: item.get_data(), proxies)
else:
return {k: v.get_data() for k, v in proxies.items()}
评论列表
文章目录