Extracting stage positions from mrc files
Added by Joel Lüthi about 9 years ago
Hi,
We're currently setting up Leginon at our institution and we want to acquire both larger areas that will be stitched together as well as overlapping images tracing single DNA molecules.
In order to stitch these images together, we want to extract the positional information contained in the mrc image files. In the web viewer, I have seen that images record their "stage position" for both x and y. But I haven't found a tool that can extract this information from the mrc file.
Thus my question:
Is there a tool to extract the stage position from mrc files? Or is there a way to read them from the file directly, opening it as a text file? So far, we haven't had any success figuring out how the mrc file is encoded and only got gibberish when trying to open it as a text file with different encodings. And while fiji can open mrc files, I can't find the stage-position information in fiji anymore.
Alternatively: Has anyone already implemented a node which would log the current position from each image to a text file? Would such an approach be recommended?
Any ideas or suggestions are welcome.
Thanks in advance & thank you all so much for all the work you've put into developing leginon. It's a great resource for us to implement automated image acquiring with the EM.
Best,
Joel
Replies (2)
RE: Extracting stage positions from mrc files - Added by Anchi Cheng about 9 years ago
Leginon does not save data collection metadata in the image. They stay in the mysql database, and need query to get the values out which is how the image report page got its values.
The mrc file Leginon saves is the extended-header-free basice mrc file. The data are binary values.
You have two choices. Both are fairly simple
First, I attach a simple python script that you can run on the same computer where you ran leginon from.
in an x-terminal of linux system, you would type this to start:
python ./imagepositions.py
Enter the preset you want the information and choose the scope parameter.
Second, we wrote a program to create a montage mrc file off a list a long time ago (for printing pretty poster). It takes all the calibration matrix and scope parameter to makes a montage mrc image. You can use that. This does not do fine alignment between tiles like the ones more complex programs do, though.
- Create a text file containing the filenames of the images you want to make the montage. one image per line. It does not need file directory just something like "15oct26a_00002sq_00004hl.mrc"
- You will need to know where leginon is installed, since this uses a program in there. I usually just simply find the package location from python import like this:
python python> import leginon python> leginon
The first line starts python command line interface. The last command will output a path. That is where "leginon" packages reside. - Run montage.py in leginon package with -o option and give an output mrc file name like this:
python your_leginon_package_path/montage.py -i your_filelist -o output.mrc
imagepositions.py (1.31 KB) imagepositions.py |
RE: Extracting stage positions from mrc files - Added by Joel Lüthi about 9 years ago
Hi Anchi
Thanks a lot for the quick response and the script! Your python script to extract the stage position works very well for us. We may adapt it in the future to automatically log these informations to a text file, which is much easier now that we have the script which already prints these values to the console.
Best,
Joel