MRC load problem
martinschorb opened this issue · 7 comments
Dear all,
when I try to load an mrc file created with SerialEM (independent of fiel type, examples attached), I get the following error:
Invalid machine stamp: 0x44 0x00 0x00 0x00
Error in header labels: nlabl is 2 but 10 labels contain text
mrcfile.version gives me
<module 'mrcfile.version' from 'xxx/anaconda2/lib/python2.7/site-packages/mrcfile/version.pyc'>
and is not callable as a function
How can I figure out whether my installation is functional?
Thanks,
Martin
Hi Martin,
Thanks for getting in touch. I'll have a look at the files you attached and see if I can work out what the problem is.
In the meantime, you can check the version of the library using mrcfile.__version__
. (This is the standard way to find module versions in Python.)
To check your installation works, you could try to download and open one of the MRC files included in the test data, for example this one. Or, you could try to open one of your files and give the extra argument permissive=True
when you call the open
function, which will make it try to ignore errors in the header and open the file anyway, if it can.
Colin
Hi Martin,
I've had a look at the files you sent. They seem generally fine except that the machine stamp in the header is incorrect. You should be able to work with them quite happily using the mrcfile
library, except that when you open the files you'll need to use permissive=True
to tell it to ignore the machine stamp problem.
If you want to fix the files, you can do it like this:
import mrcfile
with mrcfile.open('<name>', mode='r+', permissive=True) as mrc:
mrc.update_header_from_data()
Then next time, you should be able to open the file in the normal way without worrying about the permissive
option.
I'm curious about why the files have the mistake in the first place - normally, files from SerialEM are fine. What version of SerialEM are you using?
Also, while looking at your files I've come across a couple of other minor bugs in mrcfile
, so thank you for that! Luckily there's nothing serious, but I'll get on and fix them when I can.
Colin
Hi Martin,
Yes, it probably is a good idea to contact David Mastronarde about this. I've checked an older file I had which was written by SerialEM and it's fine, so this looks like a change in behaviour in the new version.
The machine stamp is supposed to contain 0x44 0x44 0x00 0x00
or 0x44 0x41 0x00 0x00
(those are in hex - it's 68 68 0 0
or 68 65 0 0
in decimal).
This is described in the MRC2014 format spec and the IMOD documentation (search for 'machst' or 'stamp' for the relevant parts), so the fact that SerialEM is producing files which don't agree with the specification is definitely a concern.
Colin
Hello again,
I'm going to close this issue now because I don't think there's any change needed in the mrcfile
code. Please feel free to reply and reopen it if you think there's still a problem.
Cheers,
Colin