Package request: MRC file reader and writer

Hello there,

First of all, I hope package requests are appropriate here. I will try my best to make this request as constructive as can be. If requests are not appropriate, I apologize, and I won’t take it personally if the discussion gets closed.

I think it would be very beneficial to have a Julia package implementing reading and writing of files in the MRC format . One application of this format is to store 2D and 3D images from cryogenic electron microscopy. Since MRC files are images, it would probably make sense to integrate this package with ImageIO.jl. Reading an MRC file should ideally give a simple 2D or 3D array, compatible with the image processing packages already available in Julia.

There is a Python package to read MRC files into numpy arrays and write such arrays out to MRC files: mrcfile. So, I anticipate people will recommend using this package through PyCall.jl. This is probably possible, I have not tried, but it would be far from ideal since it entails having to manage a Python installation. The good part though is that this package’s license (3-clause BSD) allows drawing inspiration from it as much as one would need.

I would try to build a Julia package to read/write MRC files myself, but I am much too ignorant about too many things for this to be a tractable project: I don’t know enough Python to understand how the mrcfile package works, nor enough Julia to implement all this. So, if anybody would like to take on this project, I will be very happy to help: I can help design an API; I can provide MRC files for testing purposes (the EMDB is also a good resource); maybe I can even do some coding if you can walk me through the logic of the implementation like I’m 5 and give me pointers (happy to read documentation any time, if it helps accomplishing this).

Thank you in advance!

2 Likes

The format looks fairly simple (header + data), search for read binary file and similar. Just define a struct for the header, read that, etc.

@Tamas_Papp thank you, but I posted this precisely because the file format and design of a reader, however simple they may be, are way beyond my programming skills. I have no formal background in computer science: I can use existing packages to do things at a high level, but not much else. And this is not the main thing I do for a living, so the time I can dedicate to learning this is unfortunately very limited; but I would be more than happy to be involved and learn if someone is interested in driving this project.

Since you quoted me partially, let me emphasize what came just before this quote in a way that better reflects my programming abilities:

1 Like

I know some very bright kids around the age of 5–6, but none of them program in languages like Julia (they use Lego Mindstorms and Scratch). So if this truly reflects your programming skills, you may be in an impossible position.

I imagine that a package like this will be written if someone needs it, or is paid to do it. You will of course get help here if you ask questions.

1 Like

I will try to get this started and will ask questions as I go, but it will be slow.

Hyperspy can read/write it. I wrote a small wrapper using PyCall for a similar case to read DM3 files.

Supported formats: Loading and saving data — HyperSpy 1.6.2 documentation

Also TiffImages.jl might provide some insights on how to write a file reader/writer.

2 Likes

Very helpful, thank you.