'How to read multiple Nifti files from the same folder with Nibabel?

I did see a couple of tuts related to Nibabel, that work fine when you are reading only one nii image, but I need to read 167 files from the same folder, and I don't understand how to do it. I tried using glob as we use it for OpenCV, but it doesn't work similarly with Nibabel.

data = glob.glob('path to my data' + '*.nii.gz')
print(len(data))
print(data)
data = np.asarray(data)
print(data)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source