Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix motion bugs and add colorscale keyword in plot_image #536

Merged
merged 7 commits into from
Feb 1, 2025

Conversation

pvillacorta
Copy link
Collaborator

This PR solves some motion-related bugs that appeared in previous PRs.
Additionally, I added a colorscale keyword for the plot_image function (Let me know if I should include this in another PR or take advantage and include it in this one).

@cncastillo
Copy link
Member

I think it's fine, is it ready to merge?

@pvillacorta
Copy link
Collaborator Author

pvillacorta commented Jan 30, 2025

I also took advantage of this PR to add a method definition for the multiplication of an Array of Grads by a rotation Matrix (36ab6c6). This was necessary because rotating an array of gradients (in x, y, and z) with different durations caused all durations to become the same:

julia> G1=Grad(3e-3,1e-3,0)
Grad(3.0 mT, 1.0 ms)

julia> G2=Grad(1.5e-3,2e-3,0)
Grad(1.5 mT, 2.0 ms)

julia> G3=Grad(4.5e-3,0.5e-3,0)
Grad(4.5 mT, 0.5 ms)

julia> g = [G1; G2; G3;;]
3×1 Matrix{Grad}:
 Grad(3.0 mT, 1.0 ms)
 Grad(1.5 mT, 2.0 ms)
 Grad(4.5 mT, 0.5 ms)

julia> R = [0. 0. 1.; 0. -1. 0.; 1. 0. 0.]
3×3 Matrix{Float64}:
 0.0   0.0  1.0
 0.0  -1.0  0.0
 1.0   0.0  0.0

julia> R * g
3×1 Matrix{Grad}:
 Grad(4.5 mT, 2.0 ms)
 Grad(-1.5 mT, 2.0 ms)
 Grad(3.0 mT, 2.0 ms)

I do not know if this is the expected behaviour, but I can assume it is not:

*(x::Sequence, A::Matrix{Float64}) = Sequence(A*x.GR, x.RF, x.ADC, x.DUR, x.DEF) #TODO: change this, Rotation fo waveforms is broken
*(A::Matrix{Float64}, x::Sequence) = Sequence(A*x.GR, x.RF, x.ADC, x.DUR, x.DEF) #TODO: change this, Rotation fo waveforms is broken

Now only the gradient amplitudes rotate, while the durations keep the same (I am not sure if this is correct for all cases):

julia> R * g
3×1 Matrix{Grad}:
 Grad(4.5 mT, 1.0 ms)
 Grad(-1.5 mT, 2.0 ms)
 Grad(3.0 mT, 0.5 ms)

Please let me know if this change is correct, or tell me how you would do it and whether you would include it in this PR as well.
Thank you

@cncastillo
Copy link
Member

I don't think the gradient rotation is correct. Do you really need it to be like that?

@pvillacorta
Copy link
Collaborator Author

I have needed this when creating a gre sequence and wanting to acquire different planes with it. In the initial basic sequence, which acquires the XY plane slice, there is a block with gradients of different durations. When rotating the sequence to acquire, for example, the YZ plane, all the gradients of the block end up having the same duration. I think this is an important use case.

@cncastillo cncastillo merged commit ccb71b6 into master Feb 1, 2025
6 of 12 checks passed
@cncastillo cncastillo deleted the fix-motion-bugs branch February 1, 2025 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants