Commit 43fd8ab7 authored by Thomas Vincent's avatar Thomas Vincent

Change shape of q array to keep image shape

parent 89219aa6
......@@ -71,7 +71,8 @@ def qspace_conversion(img_size, center_chan, chan_per_deg,
:param numpy.ndarray eta: 1D array of eta angle for each image
:param numpy.ndarray nu: 1D array of nu angle for each image
:param numpy.ndarray delta: 1D array of delta angle for each image
:return: Array Q vectors of shape: (nb images, image size, 3 (qx, qy, qz))
:return: Array Q vectors of shape:
(nb images, image height, image width, 3 (qx, qy, qz))
:rtype: numpy.ndarray
"""
phi = np.array(phi, copy=False, dtype=np.float64)
......@@ -106,7 +107,7 @@ def qspace_conversion(img_size, center_chan, chan_per_deg,
# shape of the array that will store the qx/qy/qz for all
# rocking angles
q_shape = n_images, img_size[0] * img_size[1], 3
q_shape = n_images, img_size[0], img_size[1], 3
# then the array
q_ar = np.zeros(q_shape, dtype=np.float64)
......@@ -114,9 +115,9 @@ def qspace_conversion(img_size, center_chan, chan_per_deg,
for index in range(n_images):
qx, qy, qz = hxrd.Ang2Q.area(
eta[index], phi[index], nu[index], delta[index])
q_ar[index, :, 0] = qx.reshape(-1)
q_ar[index, :, 1] = qy.reshape(-1)
q_ar[index, :, 2] = qz.reshape(-1)
q_ar[index, :, :, 0] = qx
q_ar[index, :, :, 1] = qy
q_ar[index, :, :, 2] = qz
return q_ar
......@@ -800,6 +801,8 @@ class QSpaceConverter(object):
eta,
nu,
delta)
# Reshape array to flatten image
q_ar.shape = q_ar.shape[0], q_ar.shape[1] * q_ar.shape[2], q_ar.shape[3]
if mask is not None:
# Mark masked pixels (i.e., non zero in the mask) with NaN
......
......@@ -30,5 +30,5 @@ __license__ = "MIT"
__date__ = "01/03/2016"
from .QSpaceConverter import QSpaceConverter
from .QSpaceConverter import QSpaceConverter, qspace_conversion
from .helpers import kmap_2_qspace
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment