batch convert from .mrc to .tiff or .png

6,367 views
Skip to first unread message

Minglei Zhao

unread,
Feb 4, 2014, 8:55:19 PM2/4/14
to em...@googlegroups.com
Hi All,

Is there a way to batch convert .mrc to .tiff or .png? I can convert to .png file for a single image with e2display.py and "snapshot" button. Converting to .tif with the same process leads to an unreadable image. e2proc2d.py generates unreadable images, too, no matter .tiff or .png. I'm new to the program and thanks for the help.


Cheers,
Minglei

Steven Ludtke

unread,
Feb 4, 2014, 9:42:27 PM2/4/14
to em...@googlegroups.com
Hi Minglei,

I just tried e2proc2d.py

e2proc2d.py image.mrc image.png

If the range of values this produces isn't optimal, you can use:

e2proc2d.py image.mrc image.png --fixintscaling sane

(other options are noscale or a number, e2proc2d.py --help for more info)

Anyway, both of these work well for me with the current version.

e2proc2d.py image.mrc image.tif 

also works fine, but TIFF format can actually be used to represent actual floating point (or 16 bit integer) image data, not just the 8 bit representations generally used in PNG, GIF, etc.  The default output mode in EMAN2 for TIFF format is floating point, and many image processing packages cannot handle floating point tiff images. Some can't even handle 16 bit tiff images. 

While e2proc3d.py has the --outmode option which allows you to specify the output mode to 8/16/32 bit int or float, nobody has gotten around to adding this option to e2proc2d.py apparently, though the library certainly supports it.

----------------------------------------------------------------------------
Steven Ludtke, Ph.D.
Professor, Dept of Biochemistry and Mol. Biol.         (www.bcm.edu/biochem)
Co-Director National Center For Macromolecular Imaging        (ncmi.bcm.edu)
Co-Director CIBR Center                          (www.bcm.edu/research/cibr)
Baylor College of Medicine                             





--
--
----------------------------------------------------------------------------------------------
You received this message because you are subscribed to the Google
Groups "EMAN2" group.
To post to this group, send email to em...@googlegroups.com
To unsubscribe from this group, send email to eman2+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/eman2
 
---
You received this message because you are subscribed to the Google Groups "EMAN2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eman2+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Minglei Zhao

unread,
Feb 5, 2014, 8:46:39 PM2/5/14
to em...@googlegroups.com
Hi Steve,

"e2proc2d.py image.mrc image.png --fixintscaling sane" from the most recent build is working for me. Thank you for your help.

Cheers,
Minglei 

Md Munan Shaik

unread,
Dec 7, 2017, 8:35:05 AM12/7/17
to EMAN2
Hi Steve, 
This is a old thread,  don't know you are still following this or not. I am trying to batch convert tiff movie stack to mrcs 

e2proc2d.py test0001.tif test0001.mrcs  fixintscaling sane

but I am getting message "Input file 'fixintscaling' does not exist" after the conversion of the first file.

Could you please point me that what I am missing here. I tried with a single file and seems it worked good.

thanks, 
Munan

Steve Ludtke

unread,
Dec 7, 2017, 8:55:03 AM12/7/17
to em...@googlegroups.com
You are missing the "--" before each option...

For more options, visit https://groups.google.com/d/optout.

--------------------------------------------------------------------------------------
Steven Ludtke, Ph.D.
Charles C. Bell Jr., Professor of Structural Biology
Dept. of Biochemistry and Molecular Biology                      (www.bcm.edu/biochem)
Co-Director CIBR Center                                    (www.bcm.edu/research/cibr)

Co-Director National Center For Macromolecular Imaging                  (ncmi.bcm.edu)

Jae Yang

unread,
Sep 4, 2018, 1:15:07 PM9/4/18
to EMAN2

Hi Steve and All,

e2proc2d.py works well for me to convert dm3 to tif or mrc. However, it failed to generate readable tif from mrc. It gave the error message "32-bit TIFF file with no data type defined". I used "e2proc2d.py input.mrc output.tif --fixintscaling sane" command. The mrc is 32 bit. 

I switched to mrc2tif (IMOD) and it worked. However, I would prefer using e2proc2d.py as it is easier for batch processing. 

Any idea why e2proc2d.py did not work here?

Many Thanks,

Jae

Steve Ludtke

unread,
Sep 4, 2018, 2:02:56 PM9/4/18
to em...@googlegroups.com, Tunay Durmaz
That's odd, it should default to floating point format, and shouldn't raise an error. You can try using:

  --outmode OUTMODE     All EMAN2 programs write images with 4-byte floating
                        point values when possible by default. This allows
                        specifying an alternate format when supported (float,
                        int8, int16, int32, uint8, uint16, uint32). Values are
                        rescaled to fill MIN-MAX range.

and specifying a type. Not sure if TIFF uses int32 or uint32 (or if there is any reason to keep 32 bits).


--------------------------------------------------------------------------------------
Steven Ludtke, Ph.D. <slu...@bcm.edu>                      Baylor College of Medicine 
Charles C. Bell Jr., Professor of Structural Biology
Dept. of Biochemistry and Molecular Biology                      (www.bcm.edu/biochem)
Academic Director, CryoEM Core                                        (cryoem.bcm.edu)

Co-Director CIBR Center                                    (www.bcm.edu/research/cibr)
Co-Director National Center For Macromolecular Imaging                  (ncmi.bcm.edu)

Jae Yang

unread,
Sep 4, 2018, 2:17:14 PM9/4/18
to em...@googlegroups.com, Tunay Durmaz
It worked!

Thanks!!!

G P

unread,
Mar 1, 2020, 10:05:03 AM3/1/20
to EMAN2
Dear Dr. Stevev,
Can I use this other way? I mean I want to convert tif movies to mrc or mrcs movies. I tried but somehow it changes pixel size  (from 0.424 to 1.00). Is there a specific option I need to use to keep the pixel size consistent.
Thank you
Gaya

Steve Ludtke

unread,
Mar 1, 2020, 11:23:03 AM3/1/20
to em...@googlegroups.com
So, while it may not answer every question (at least without some reading):
e2proc2d.py --help
is a good place to start.

1) e2proc2d.py should not produce invalid images (if it does, please send an example). However, you should be aware that both TIFF and PNG support 16 bit greyscale images, and TIFF also supports floating point images. You may find a variety of consumer software won't support these more unusual modes even if they are generally able to read TIFF and PNG. If your intent is to produce images you can use with powerpoint, photoshop, etc. You should make sure that you are writing in 8 bit integer mode.  The default behavior is to try and preserve as much information (or potential information) as possible, so it will use as many bits as it can. With the 

--outmode uint8

option, it will write 8 bit integer images, as long as the format supports them (most do), and that should improve readability in consumer software.

If you wish to convert TIFF stacks to MRC stacks:

e2proc2d.py file.tiff file.mrcs

- The "s" in "mrcs" is critical! 
- You may optionally specify --outmode (or you will get floating point .mrcs files)
- if you wish to force the A/pix value add --apix <value>

2) EMAN2 will try and preserve all header values which are compatible between formats, including A/pix. However, as far as I am aware, nobody is storing A/pix information in TIFF files. While TIFF does support the possibility of additional header tags, these have to be registered with Adobe to be valid, and as far as I know, noboby in the CryoEM community has done this.  If you are aware of someone putting A/pix in a TIFF header, please send the details and we will implement it.  Anyway, you can override the A/pix value when writing files in e2proc2d.py with the --apix <value> option.

3) Note that it is possible to combine multiple single images into a single stack file with:

e2proc2d.py <input1> <input2> ... <output>

as long as <output> is a format supporting stack files. In reverse:

e2proc2d.py <input stack> <outbase> --unstacking

should produce a set of individual images from a single stack file.

See this page for details on supported features in each file format:



--------------------------------------------------------------------------------------
Steven Ludtke, Ph.D. <slu...@bcm.edu>                      Baylor College of Medicine 
Charles C. Bell Jr., Professor of Structural Biology
Dept. of Biochemistry and Molecular Biology                      (www.bcm.edu/biochem)
Academic Director, CryoEM Core                                        (cryoem.bcm.edu)
Co-Director CIBR Center                                    (www.bcm.edu/research/cibr)



--
--
----------------------------------------------------------------------------------------------
You received this message because you are subscribed to the Google
Groups "EMAN2" group.
To post to this group, send email to em...@googlegroups.com
To unsubscribe from this group, send email to eman2+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/eman2

---
You received this message because you are subscribed to the Google Groups "EMAN2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eman2+un...@googlegroups.com.

Doo Nam Kim

unread,
Mar 12, 2020, 12:35:17 PM3/12/20
to EMAN2
Steven,

I have a same problem as in

Can I get some advice please?

Thank you,
Doonam
To unsubscribe from this group, send email to em...@googlegroups.com

For more options, visit this group at
http://groups.google.com/group/eman2

---
You received this message because you are subscribed to the Google Groups "EMAN2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to em...@googlegroups.com.

Steve Ludtke

unread,
Mar 12, 2020, 12:53:06 PM3/12/20
to em...@googlegroups.com
Hmm... this looks like an MRC specific bug, and is related to MRC storing stacks of 2-D images as a 3-D volume, unlike other file formats, which store stacks of images in a fundamentally different way from volumes (permitting stacks of volumes). Our solution to this was to follow Relion's lead and store stack files using the .mrcs extension and volumes using the .mrc extension. So, when you use the .mrc output extension it assumes you want to create a volume (stack), and overrides the --unstacking option. You'll note, for example, if you use x.tif as an output that the option performs as requested.

However, this also presents a simple solution. For your output file, simply use the .mrcs extension, and it will create the desired individual image files. You could consider these as MRC stacks with a single image, though in practice the files themselves are identical to .mrc. 

e2proc2d.py input.mrcs output.mrcs --unstacking

and you will get output-001.mrcs, output-002.mrcs, etc.

--------------------------------------------------------------------------------------
Steven Ludtke, Ph.D. <slu...@bcm.edu>                      Baylor College of Medicine 
Charles C. Bell Jr., Professor of Structural Biology
Dept. of Biochemistry and Molecular Biology                      (www.bcm.edu/biochem)
Academic Director, CryoEM Core                                        (cryoem.bcm.edu)
Co-Director CIBR Center                                    (www.bcm.edu/research/cibr)



To unsubscribe from this group, send email to eman2+un...@googlegroups.com

For more options, visit this group at
http://groups.google.com/group/eman2

--- 
You received this message because you are subscribed to the Google Groups "EMAN2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eman2+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eman2/4879a4e2-dea8-4ac2-b8ad-f40d84010735%40googlegroups.com.

Doonam (David)

unread,
Mar 12, 2020, 1:27:30 PM3/12/20
to em...@googlegroups.com
Thank you,
e2proc2d.py input.mrcs output.mrcs --unstacking
works.

You received this message because you are subscribed to a topic in the Google Groups "EMAN2" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/eman2/Aj2EXa-PsRA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to eman2+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eman2/F930BA73-6E8A-40A0-B019-9550E7F4B388%40gmail.com.
Reply all
Reply to author
Forward
0 new messages