ahendriksen / tomosipo

A library for painless 3D tomographic reconstruction

Home Page:https://aahendriksen.gitlab.io/tomosipo/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rotation issue with multiple rotation axis

jon-dong opened this issue · comments

Hi,

It seems like there is a syntax error in the ts.rotate() function when using it with multiple rotation axis. This option seems to be possible (both in the documentation and error messages) but there is a small error when running the following code:

import numpy as np
import tomosipo as ts
multi_axis = np.random.randn(10, 3)
angles = np.random.randn(10, 1)
ts.rotate(pos=(0,0,0), axis=multi_axis, angles=angles)

The error message is the following:

ValueError                                Traceback (most recent call last)
<ipython-input-2-3029707426d4> in <module>
      1 axiss = np.random.randn(10, 3)
      2 angles = np.random.randn(10, 1)
----> 3 ts.rotate(pos=(0,0,0), axis=axiss, angles=angles)

~/.conda/envs/tomosipo2/lib/python3.8/site-packages/tomosipo/geometry/transform.py in rotate(pos, axis, angles, rad, deg, right_handed)
    342     pos, axis = vc._broadcastv(pos, axis)
    343 
--> 344     axis = axis / vc.norm(axis)
    345 
    346     angles_defined = angles is not None

ValueError: operands could not be broadcast together with shapes (10,4) (10,) 

This was in the version 0.3.1 of Tomosipo (numpy 1.21.0 and python 3.8.10)

Hi,

Good catch! Thank you for bringing it to my attention. I have pushed a fix in commit 6c6f854.

Can you check if the develop branch works as expected?

You can install with pip install git+https://github.com/ahendriksen/tomosipo.git@develop.

Yes it works now. Thanks for your fast update, it saved me time on my side!

Great! Please do continue to file issues if you run into anything.

Hi Jonathan,

I found out yesterday that in the course of fixing this bug, I introduced another. I was already kind apprehensive that I was trying to fix this too fast.. The rotation matrix had become transposed which was not found by the unit tests, because everything remained internally consistent. The SVG animations just became slightly out of whack..

In any case, I have released a new version 0.4.1 that fixes this issue.

Hi Allard,

Thanks for this update! On my side I did not notice this transpose since everything was consistent. I'll keep you posted if there is something strange that come out.