/ concept-collection / seqlab
Sign in
concept-collection / seqlab
seqlab / src / engine / pulseq / +mr / +aux / +quat / normalize.m
13 lines · 288 BCodeBlameHistory
78d04f1seqlab: write and view pulseq MRI sequences in the browserJeremy Magland 1function q = normalize(q)
2%NORMALIZE normalizes quaternion q (or array of quaternions)
3
4n2=sum(q'.^2)';
5if any(n2>0)
6 if length(n2)>1
7 ninv=n2(n2>0).^-0.5;
8 q(n2>0,:)=q(n2>0,:).*ninv(:,ones(1,4));
9 else
10 ninv=n2^-0.5;
11 q=q*ninv;
12 end
13end
moveopenescclose