def _reorient_3d(image):
    """
    Reorganize the data for a 3d nifti
    """
    # Create empty array where x,y,z correspond to LR (sagittal), PA (coronal), IS (axial) directions and the size
    # of the array in each direction is the same with the corresponding direction of the input image.
    new_image = numpy.zeros([image.dimensions[image.sagittal_orientation.normal_component],
                             image.dimensions[image.coronal_orientation.normal_component],
                             image.dimensions[image.axial_orientation.normal_component]],
                            dtype=image.nifti_data.dtype)

    # Fill the new image with the values of the input image but with matching the orientation with x,y,z
    if image.coronal_orientation.y_inverted:
        for i in range(new_image.shape[2]):
            new_image[:, :, i] = numpy.fliplr(numpy.squeeze(image.get_slice(SliceType.AXIAL,
                                                                            new_image.shape[2] - 1 - i).original_data))
    else:
        for i in range(new_image.shape[2]):
            new_image[:, :, i] = numpy.fliplr(numpy.squeeze(image.get_slice(SliceType.AXIAL,
                                                                            i).original_data))

    return new_image
def _reorient_3d ( image ) : new_image = numpy . zeros ( [ image . dimensions [ image . sagittal_orientation . normal_component ] , image . dimensions [ image . coronal_orientation . normal_component ] , image . dimensions [ image . axial_orientation . normal_component ] ] , dtype = image . nifti_data . dtype ) if image . coronal_orientation . y_inverted : for i in range ( new_image . shape [ 2 ] ) : new_image [ : , : , i ] = numpy . fliplr ( numpy . squeeze ( image . get_slice ( SliceType . AXIAL , new_image . shape [ 2 ] - 1 - i ) . original_data ) ) else : for i in range ( new_image . shape [ 2 ] ) : new_image [ : , : , i ] = numpy . fliplr ( numpy . squeeze ( image . get_slice ( SliceType . AXIAL , i ) . original_data ) ) return new_image
Reorganize the data for a 3d nifti