nibabel icon indicating copy to clipboard operation
nibabel copied to clipboard

How to close image file? can't rewrite image when load it in IPython

Open gourdchen opened this issue 3 years ago • 4 comments

When I load one image to my Ipython kernel, it is difficult to cancel the file occupation. I have tried using image.uncache() and del imange , but it did not work, I still can't remove the file or rewrite it.

gourdchen avatar Jul 11 '21 01:07 gourdchen

Likely a memmap issue. Does adding mmap=False to the load work?

effigies avatar Jul 11 '21 02:07 effigies

Likely a memmap issue. Does adding mmap=False to the load work?

test = nib.load('ststr.nii',mmap=False)
test.uncache()
test.to_filename('ststr.nii')

I just used this codes to test the error, but there is still error: OSError: [Errno 22] Invalid argument: 'ststr.nii'

It seems like that only I restart the IPython kernel, it will release the file occupation.

gourdchen avatar Jul 12 '21 02:07 gourdchen

So you say "Ipython kernel". Is this Jupyter? Are you able to reproduce the issue outside Jupyter?

effigies avatar Jul 14 '21 20:07 effigies

After my testing, I ensure that it is just in the Jupyter

gourdchen avatar Jul 23 '21 09:07 gourdchen