I have a python3.6 program, using nibabel package to analyze medical images in NIFTI format.
import glob
import nibabel as nib
health = [nib.load(pt) for pt in glob.glob(healthdir+'*.nii')] # len = 200
health_data = [h.get_data() for h in health]
It occurred OSError: [Errno 24] Too many open files
in the last line. I used following code and found out that it occurred the error in the last element.
health_data = []
for i in range(len(health)):
try:
health_data.append(health[i].get_data())
except:
print(i) # 199
I have tried to search relative topic such as
Nibabel: IOError: [Errno 24] Too many open files:. However, it doesn't solve the problem. Also, I prefer not to use ulimit
. Thanks!