Closed jdeschamps closed 1 year ago
Hi! This seems to be unrelated to #130. The issue is deeper (with mrcfile
):
ValueError: Unrecognised machine stamp: 0x44 0x20 0x20 0x20
Something seems to be off with the header of your mrc
file, which is not recognized by mrcfile. Can you try to manually open the file by doing this in ipython?:
with mrcfile.open('/path/to/file.mrc', 'r', header_only=True) as mrc:
print(mrc.header)
If this fails again, try:
with mrcfile.open('/path/to/file.mrc', 'r', header_only=True, permissive=True) as mrc:
print(mrc.header)
I didn't add any machinery to allow permissive=True
for now; if that solves it, maybe I should consider setting it to True
by default.
It fails without permissive=True
, but loads with it:
/home/joran.deschamps/miniconda3/envs/blik/lib/python3.9/site-packages/mrcfile/mrcinterpreter.py:219:
RuntimeWarning: Unrecognised machine stamp: 0x44 0x20 0x20 0x20
warnings.warn(str(err), RuntimeWarning)
(1024, 1024, 512, 2, 0, 0, 0, 1024, 1024, 512, (1024., 1024., 512.), (90., 90., 90.), 1, 2, 3, -995.9688, 480.2282,
-2.2351742e-07, 0, 0, b'\x00\x00\x00\x00\x00\x00\x00\x00', b'', 0, b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', (0., 0., 0.), b'MAP ', [68, 32, 32, 32], -1., 0,
[b'', b'', b'', b'', b'', b'', b'', b'', b'', b''])
Yeah, this happens if the header is a bit messed up for some reason. Corrupted file, or maybe it was written by a software that wasn't very careful about writing correct information in the header. If you want a quick fix, you can edit the code in naaf
for the mrc reader function and add the permissive=True
argument to the mrcfile.mmap
call. I will try to release a half update to naaf and blik to fix both this issue and the other you raised.
Thanks a lot! I will let you be the judge of whether to keep this issue open!
FYI the file was saved using imod, and there is no issue opening it there.
You might want to bring this issue up to the mrcfile
repo then, since this can only be solved there.
In my experience, imod
is super resilient to broken headers, but because of this it might be less careful in writing correct ones :P
The joy of open source dependencies :D
@jdeschamps I just released v0.3.2
as an intermediate version before napari 0.4.17. Feel free to try it out and let me know if things work :)
@jdeschamps update: v0.3.3 is actually fixed, sorry :P
Awesome thanks, I'll let you know if anything arises!
Hi!
Warning: I have a complete lack of understanding of how mrc files are read/written. I also understand that the plugin is in development!
When trying to open an mrc file from a collaborator, I get the following error:
I installed the env following https://github.com/gutsche-lab/blik/issues/130, with
naaf==0.2.3
, which may or may not explain the problem.