I2PC / xmippCore

Core functions for Xmipp and sharing with other packages (like Scipion)
GNU General Public License v3.0
4 stars 2 forks source link

dm4 to mrc flip? #39

Open azazellochg opened 5 years ago

azazellochg commented 5 years ago

From mailing list:

Our users report that the motioncor2 protocol flips the gain reference when converting from .dm4 to .mrc. I see an option in the MC2 protocol to flip the gain reference back. However, I'm wondering why the gain reference is flipped in the first place.

This code seems relevant:

https://github.com/I2PC/scipion/blob/d1a60f69960d1079bbbecde5bf3f5f4017b36927/pyworkflow/em/convert/image_handler.py#L178

However, since *.img files are not involved I would guess the "else" branch of that statement would be followed, meaning that Xmipp performs the conversion.

Any ideas how to troubleshoot this?

Matt

Feel free to transfer the issue to an appropriate repo.

azazellochg commented 3 years ago

Any progress on this? I have just checked and dm4 to mrc conversion by xmipp flips the gain image vertically so mc will produce wrong results.

azazellochg commented 3 years ago

Left is correct result (applied extra vertical flip in mc2 protocol), right is default image

DStrelak commented 3 years ago

Hi @azazellochg , I tried to reproduce this issue using dataset 10261 (files CountRef_movie_19-5_000_May17_10.47.41.dm4 and movie_19-5_000_May17_10.47.41.tif).

When I open both original dm4 and converted mrc file, they (at least optically) have the same orientation, see attachment. That being said, I would say that I got better micrograph from MotionCorr with Flip gain reference set to upside down, i.e. that the gain should be flipped.

If I compare micrographs produced by FlexAlign (left) and MotionCorr (right), you can see that they are flipped, however, xsj shows the frames of the movie (center) it in the same orientation as FlexAlign.

So, to me it seems that either XMIPP is ignoring some header flag (but at least it's doing so consistently) or MotionCorr is internally flipping the tif, but then does not do the same with the gain.

image image

azazellochg commented 3 years ago

Hi @DStrelak ,

I'm using 1 movie and a gain from data/tests/movies/: c3...tif and Super...dm4. These are super-res movie and gain that do not require any rotation during motion correction.

1) I have converted the dm4 gain using either dm2mrc (imod) or e2proc2d.py (EMAN2) to mrc 2) I displayed converted files with relion_display and both converted gain are shown in the same orientation:

image

3) as a sanity check, I opened the files with scipion show and they match relion_display (at least mrc are displayed in the same way, great!) 4) I have also displayed dm4 gain with scipion show - and it is flipped vertically! So either BOTH Imod and Eman2 flip dm4 upon conversion to mrc or Scipion/Xmipp is reading dm4 wrongly

image

5) as a sanity check I ran relion motioncorrection on tif movie with both mrc gains and the results are ok 6) now, I ran mc2 with tif movie and eman/imod gain or no gain at all. With both gain files output is as expected / good. 7) I compared mc2 result with no gain and relion result with no gain - they are identical, meaning that neither of them flips tifs. Or both of them do flip tifs AND both eman/imod flip dm4->mrc - but I find such probability close to 0.