@@ -262,7 +262,7 @@ def astra_projection_geometry(geometry):
262262 geometry .ndim == 2 ):
263263 det_count = geometry .detector .size
264264 if astra_supports ('par2d_vec_geometry' ):
265- vecs = parallel_2d_geom_to_astra_vecs (geometry )
265+ vecs = parallel_2d_geom_to_astra_vecs (geometry , coords = 'ASTRA' )
266266 proj_geom = astra .create_proj_geom ('parallel_vec' , det_count , vecs )
267267 else :
268268 det_width = geometry .det_partition .cell_sides [0 ]
@@ -288,7 +288,7 @@ def astra_projection_geometry(geometry):
288288 isinstance (geometry .detector , (Flat1dDetector , Flat2dDetector )) and
289289 geometry .ndim == 2 ):
290290 det_count = geometry .detector .size
291- vecs = cone_2d_geom_to_astra_vecs (geometry )
291+ vecs = cone_2d_geom_to_astra_vecs (geometry , coords = 'ASTRA' )
292292 proj_geom = astra .create_proj_geom ('fanflat_vec' , det_count , vecs )
293293
294294 # Cone 2D vec
@@ -304,7 +304,7 @@ def astra_projection_geometry(geometry):
304304 # Swap detector axes (see `parallel_3d_geom_to_astra_vecs`)
305305 det_row_count = geometry .det_partition .shape [0 ]
306306 det_col_count = geometry .det_partition .shape [1 ]
307- vecs = parallel_3d_geom_to_astra_vecs (geometry )
307+ vecs = parallel_3d_geom_to_astra_vecs (geometry , coords = 'ASTRA' )
308308 proj_geom = astra .create_proj_geom (
309309 'parallel3d_vec' , det_row_count , det_col_count , vecs )
310310
@@ -323,7 +323,7 @@ def astra_projection_geometry(geometry):
323323 # Swap detector axes (see `conebeam_3d_geom_to_astra_vecs`)
324324 det_row_count = geometry .det_partition .shape [0 ]
325325 det_col_count = geometry .det_partition .shape [1 ]
326- vecs = cone_3d_geom_to_astra_vecs (geometry )
326+ vecs = cone_3d_geom_to_astra_vecs (geometry , coords = 'ASTRA' )
327327 proj_geom = astra .create_proj_geom (
328328 'cone_vec' , det_row_count , det_col_count , vecs )
329329
@@ -466,7 +466,7 @@ def vecs_astra_to_odl_coords(vecs):
466466 'array with shape {}' .format (vecs .shape ))
467467
468468
469- def parallel_2d_geom_to_astra_vecs (geometry ):
469+ def parallel_2d_geom_to_astra_vecs (geometry , coords = 'ODL' ):
470470 """Create vectors for ASTRA projection geometries from an ODL geometry.
471471
472472 The 2D vectors are used to create an ASTRA projection geometry for
@@ -491,18 +491,29 @@ def parallel_2d_geom_to_astra_vecs(geometry):
491491 Parameters
492492 ----------
493493 geometry : `Geometry`
494- ODL projection geometry from which to create the ASTRA geometry.
494+ ODL projection geometry from which to create the ASTRA vectors.
495+ coords : {'ODL', 'ASTRA'}, optional
496+ Coordinate system in which the resulting vectors should be
497+ represented.
495498
496499 Returns
497500 -------
498501 vectors : `numpy.ndarray`
499502 Array of shape ``(num_angles, 6)`` containing the vectors.
500503
504+ See Also
505+ --------
506+ vecs_odl_to_astra_coords : Conversion to ASTRA coordinates
507+
501508 References
502509 ----------
503510 .. _ASTRA projection geometry documentation:
504511 http://www.astra-toolbox.com/docs/geom2d.html#projection-geometries
505512 """
513+ coords , coords_in = str (coords ).upper (), coords
514+ if coords not in ('ODL' , 'ASTRA' ):
515+ raise ValueError ('`coords` {!r} not understood' .format (coords_in ))
516+
506517 angles = geometry .angles
507518 mid_pt = geometry .det_params .mid_pt
508519 vectors = np .zeros ((angles .size , 6 ))
@@ -519,10 +530,13 @@ def parallel_2d_geom_to_astra_vecs(geometry):
519530 px_size = geometry .det_partition .cell_sides [0 ]
520531 vectors [:, 4 :6 ] = det_axis * px_size
521532
522- return vecs_odl_to_astra_coords (vectors )
533+ if coords == 'ASTRA' :
534+ vectors = vecs_odl_to_astra_coords (vectors )
535+
536+ return vectors
523537
524538
525- def parallel_3d_geom_to_astra_vecs (geometry ):
539+ def parallel_3d_geom_to_astra_vecs (geometry , coords = 'ODL' ):
526540 """Create vectors for ASTRA projection geometries from an ODL geometry.
527541
528542 The 3D vectors are used to create an ASTRA projection geometry for
@@ -548,7 +562,10 @@ def parallel_3d_geom_to_astra_vecs(geometry):
548562 Parameters
549563 ----------
550564 geometry : `Geometry`
551- ODL projection geometry from which to create the ASTRA geometry.
565+ ODL projection geometry from which to create the ASTRA vectors.
566+ coords : {'ODL', 'ASTRA'}, optional
567+ Coordinate system in which the resulting vectors should be
568+ represented.
552569
553570 Returns
554571 -------
@@ -560,6 +577,12 @@ def parallel_3d_geom_to_astra_vecs(geometry):
560577 .. _ASTRA projection geometry documentation:
561578 http://www.astra-toolbox.com/docs/geom3d.html#projection-geometries
562579 """
580+ coords , coords_in = str (coords ).upper (), coords
581+ if coords not in ('ODL' , 'ASTRA' ):
582+ raise ValueError ('`coords` {!r} not understood' .format (coords_in ))
583+
584+ # TODO: use `coords`
585+
563586 angles = geometry .angles
564587 mid_pt = geometry .det_params .mid_pt
565588
@@ -582,13 +605,15 @@ def parallel_3d_geom_to_astra_vecs(geometry):
582605 # Instead we swap `u` and `v`, resulting in the effective ASTRA result
583606 # `(u, theta, v)`. Here we only need to swap axes 0 and 1, which
584607 # keeps at least contiguous blocks in `v`.
608+ #
609+ # TODO: this swapping should not happen in this function!
585610 vectors [:, 9 :12 ] = det_axes [0 ] * px_sizes [0 ]
586611 vectors [:, 6 :9 ] = det_axes [1 ] * px_sizes [1 ]
587612
588613 return vecs_odl_to_astra_coords (vectors )
589614
590615
591- def cone_2d_geom_to_astra_vecs (geometry ):
616+ def cone_2d_geom_to_astra_vecs (geometry , coords = 'ODL' ):
592617 """Create vectors for ASTRA projection geometries from an ODL geometry.
593618
594619 The 2D vectors are used to create an ASTRA projection geometry for
@@ -614,6 +639,9 @@ def cone_2d_geom_to_astra_vecs(geometry):
614639 ----------
615640 geometry : `Geometry`
616641 ODL projection geometry from which to create the ASTRA vectors.
642+ coords : {'ODL', 'ASTRA'}, optional
643+ Coordinate system in which the resulting vectors should be
644+ represented.
617645
618646 Returns
619647 -------
@@ -625,6 +653,10 @@ def cone_2d_geom_to_astra_vecs(geometry):
625653 .. _ASTRA projection geometry documentation:
626654 http://www.astra-toolbox.com/docs/geom2d.html#projection-geometries
627655 """
656+ coords , coords_in = str (coords ).upper (), coords
657+ if coords not in ('ODL' , 'ASTRA' ):
658+ raise ValueError ('`coords` {!r} not understood' .format (coords_in ))
659+
628660 angles = geometry .angles
629661 mid_pt = geometry .det_params .mid_pt
630662 vectors = np .zeros ((angles .size , 6 ))
@@ -641,10 +673,13 @@ def cone_2d_geom_to_astra_vecs(geometry):
641673 px_size = geometry .det_partition .cell_sides [0 ]
642674 vectors [:, 4 :6 ] = det_axis * px_size
643675
644- return vecs_odl_to_astra_coords (vectors )
676+ if coords == 'ASTRA' :
677+ vectors = vecs_odl_to_astra_coords (vectors )
645678
679+ return vectors
646680
647- def cone_3d_geom_to_astra_vecs (geometry ):
681+
682+ def cone_3d_geom_to_astra_vecs (geometry , coords = 'ODL' ):
648683 """Create vectors for ASTRA projection geometries from an ODL geometry.
649684
650685 The 3D vectors are used to create an ASTRA projection geometry for
@@ -671,6 +706,9 @@ def cone_3d_geom_to_astra_vecs(geometry):
671706 ----------
672707 geometry : `Geometry`
673708 ODL projection geometry from which to create the ASTRA vectors.
709+ coords : {'ODL', 'ASTRA'}, optional
710+ Coordinate system in which the resulting vectors should be
711+ represented.
674712
675713 Returns
676714 -------
@@ -682,6 +720,12 @@ def cone_3d_geom_to_astra_vecs(geometry):
682720 .. _ASTRA projection geometry documentation:
683721 http://www.astra-toolbox.com/docs/geom3d.html#projection-geometries
684722 """
723+ coords , coords_in = str (coords ).upper (), coords
724+ if coords not in ('ODL' , 'ASTRA' ):
725+ raise ValueError ('`coords` {!r} not understood' .format (coords_in ))
726+
727+ # TODO: use `coords`
728+
685729 angles = geometry .angles
686730 mid_pt = geometry .det_params .mid_pt
687731 vectors = np .zeros ((angles .size , 12 ))
@@ -703,6 +747,8 @@ def cone_3d_geom_to_astra_vecs(geometry):
703747 # Instead we swap `u` and `v`, resulting in the effective ASTRA result
704748 # `(u, theta, v)`. Here we only need to swap axes 0 and 1, which
705749 # keeps at least contiguous blocks in `v`.
750+ #
751+ # TODO: this swapping should not happen in this function!
706752 vectors [:, 9 :12 ] = det_axes [0 ] * px_sizes [0 ]
707753 vectors [:, 6 :9 ] = det_axes [1 ] * px_sizes [1 ]
708754
0 commit comments