You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the following, you find the documentation of all exported functions of the [MRIRealign.jl](https://github.com/MagneticResonanceImaging/MRIRealign.jl) package:
Estimate motion parameters and/or realign the images.
22
+
23
+
# Required argument
24
+
- `img::AbstractArray{T,4}`: Array of images with the dimensions `x, y, z, t`, i.e., 3D images with time in the 4th dimension. The type T can be real or complex valued. If complex-valued, the motion estimation will be performed on the absolute value; otherwise, on img, i.e., allowing for negative values.
25
+
26
+
# Keyword arguments if motion parameters are unknown
27
+
- `center=size(img)[1:3] .÷ 2`: Point around which the images are rotated (relevant only for the estimated motion parameters, not the alignment).
28
+
- `ref_mode: `:consensus` (default), `:mean`, or an integer. `:consensus` estimates motion parameters pairwise for all timeframes and computes a consensus, which is helpful if any single reference might have poor image quality. This comes at the cost of a `t`-fold increase in computation time. `:mean` estimates the motion parameters wrt. to the mean of all images. This is fast, but might have inferior precision if the mean is blurred by substantial motion. Providing an integer aligns the images wrt. to the `ref_mode`th time frame, which is fast, but works only reliably if this time frame has good image quality.
29
+
- `mask=trues(size(img)[1:3])`: bitmask at which the frames are compared.
30
+
- `fwhm=nothing`: 3-Tuple of the full width at half maximum values of an optional Gaussian smoothing kernel along each dimension, in units of voxels. The default setting (`nothing`) is to perform no smoothing.
31
+
- `realign=true`: If true, the argument `img` will be overwritten inline with the aligned images. If `false`, this function estimates the motion parameters, but does not align the images.
32
+
33
+
# Optional arguments if the motion parameters are already known
34
+
- `motion_params::AbstractMatrix`: If the motion parameters are known, e.g., by a previous run of this function, they can be provided to skip the estimation step. The dimensions of this matrix are `6 × T`, capturing in the first dimension the motion parameters, in the order `rx, ry, rz, tx, ty, tz`, with the rotations `r` and the translations `t`. T is the number of time frames.
35
+
- `center=size(img)[1:3] .÷ 2)`: Point around which `motion_params` are applied.
36
+
37
+
With the appropriate settings (see above), the aligned timeframes are written inline into `img`. The function always returns the estimated motion parameters, where all rotations are in radians and translations in voxels.
38
+
"""
17
39
functionrealign!(img::AbstractArray{Tin,4};
18
40
center=size(img)[1:3] .÷2,
19
41
ref_mode=:consensus,
@@ -99,7 +121,7 @@ function realign!(img::AbstractArray{T,4}, motion_params; center=size(img)[1:3]
Ry =@SMatrix [cos(ry) 0sin(ry); 010; -sin(ry) 0cos(ry)]
@@ -188,6 +219,11 @@ function create_rotation_matrix(rx, ry, rz)
188
219
return R
189
220
end
190
221
222
+
"""
223
+
create_affine_matrix(p, center)
224
+
225
+
Calculate the affine matrix from `p = rx, ry, rz, tx, ty, tz`. The rotations `r` are in radians and the translations `t` in voxels. The argument `center` takes a 3-Tuple (or vector of length 3) with the center around which the images are rotated.
0 commit comments