Unstack tomo into 2D stacks (10 sections each)

116 views
Skip to first unread message

Alex campos

unread,
Mar 10, 2021, 6:19:14 AM3/10/21
to em...@googlegroups.com

Hi everyone,

 

I have been going around a problem lately without success so I am asking for your help.

 

I have several tomograms reconstructed in EMAN2 (eman 2.31).

 

tomo1.hdf

tomo2.hdf

tomo3.hdf

tomo4.hdf

tomo5.hdf

 

with dimensions: 2048 x 2048 x 512

 

I would like to:

 

Unstack each of them in 10 section slices in different .hdf files.

 

For example:

 

Unstack tomo1.hdf (2048 x 2048 x 512) into 50 stacks (z axis, 512/10=51 stacks). And create 50 .hdf 2D files (these would have the dimensions  2048 x 2048 x 1).

 

And I would like to do it on the five tomograms on batch.

 

I have been playing with:

 

e2proc3d.py stack.hdf indiv.hdf –unstacking

e2proc2d.py --threed2twod

 

But I could not manage to get the right results.

 

Thank you in advance.


Best,

 

Alex Campos

MuyuanChen

unread,
Mar 10, 2021, 10:23:36 AM3/10/21
to em...@googlegroups.com
I think threed2twod only turn them in to stack of 2D images, so from 2048x2048x512 volume to a stack of 512 2D images. Then you can run "e2proc2d.py a.hdf b.hdf —first 0 —last 10” through “--first 500 —last 510” for the sections. Probably need to write a bash loop for this. 
If you are doing this with a loop, just “e2proc3d.py —clip 2048,2048,10,1024,1024,z” (loop through z) will work as well.


--
--
----------------------------------------------------------------------------------------------
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/eman2/CAO2cQbtA_820M65YGD%3DYj2MgcUuiJBjh8kxGTF_W7671kX69zA%40mail.gmail.com.

Alex campos

unread,
Mar 11, 2021, 9:07:12 AM3/11/21
to em...@googlegroups.com
Hello MuyuanChen,

I have tried several different ways that you explained but I could not get any result:

First, I could not arrive to unstack the 3D volume. It creates a new file (same size with same data), should be easy but It doesn't work.

$ e2proc3d.py tomo1.hdf indiv.hdf --unstacking
$ indiv-1.hdf info        tomo1.hdf

Then, I went over the loop:

(base) $ for z in 1 ; do e2proc3d.py tomo1.hdf @.hdf --clip=2048,2048,1024,1024,z; done

 

Traceback (most recent call last):

 

  File "/opt/EMAN2/eman2.9_sphire1.4_sparx/bin/e2proc3d.py", line 890, in <module>

    main()

  File "/opt/EMAN2/eman2.9_sphire1.4_sparx/bin/e2proc3d.py", line 159, in main

    (options, args) = parser.parse_args()

  File "/opt/EMAN2/eman2.9_sphire1.4_sparx/lib/python3.7/optparse.py", line 1387, in parse_args

    stop = self._process_args(largs, rargs, values)

  File "/opt/EMAN2/eman2.9_sphire1.4_sparx/lib/python3.7/optparse.py", line 1427, in _process_args

    self._process_long_opt(rargs, values)

  File "/opt/EMAN2/eman2.9_sphire1.4_sparx/lib/python3.7/optparse.py", line 1501, in _process_long_opt

    option.process(opt, value, values, self)

  File "/opt/EMAN2/eman2.9_sphire1.4_sparx/lib/python3.7/optparse.py", line 785, in process

    self.action, self.dest, opt, value, values, parser)

  File "/opt/EMAN2/eman2.9_sphire1.4_sparx/lib/python3.7/optparse.py", line 805, in take_action

    self.callback(self, opt, value, parser, *args, **kwargs)

  File "/opt/EMAN2/eman2.9_sphire1.4_sparx/lib/python3.7/site-packages/EMAN2.py", line 617, in intvararg_callback

    v = [int(i) for i in value.split(',')]

  File "/opt/EMAN2/eman2.9_sphire1.4_sparx/lib/python3.7/site-packages/EMAN2.py", line 617, in <listcomp>

    v = [int(i) for i in value.split(',')]

ValueError: invalid literal for int() with base 10: 'z'


In summary, my knowledge on e2proc*.py and my computer/coding skills are not good enough to fully get what you said.. Could you please be more specific so I can follow more what yoou explained?


Thank you in advance, really.


Best,


Alex







Steve Ludtke

unread,
Mar 11, 2021, 9:11:43 AM3/11/21
to em...@googlegroups.com
Hi Alex,
the syntax in your shell script is incorrect, and the parameters you are passing to the --clip option are wrong.

- in the shell script you need to use $z when you use the variable, not 'z'

- The --clip option (e2proc3d.py --help) takes 6 parameters
x0,y0,z0,nx,ny,nz

so you would want to do something like:

0,0,0,2048,2048,10
0,0,10,2048,2048,10
0,0,20,2048,2048,10
...

-----------------------------------------
Steven Ludtke, slud...@gmail.com 


Steve Ludtke

unread,
Mar 11, 2021, 9:14:06 AM3/11/21
to em...@googlegroups.com
and you don't need the first command at all. You can run the for loop directly on the 2k x 2k x 512 tomogram.
-----------------------------------------
Steven Ludtke, slud...@gmail.com 

Reply all
Reply to author
Forward
0 new messages