Utility Functions#
coordinates#
- get_static_2d_centered_coordinates(map_size, object_dimensions=None, return_2d=True)[source]#
Calculates relative coordinates for a dense map with coordinate origin in the center of the map. If the dimension in map_size is even, the origin is shifted 1/2 with respect to grid indices, if they are uneven, the origin coincides with a grid point. Reshapes the output to a shape, used in cmrsim simulations. The singleton-axis is reserved for repetitions contrasts.
- Parameters:
- Return type:
Tensor
- Returns:
(X, Y, 1, 1, 3)
- compute_orientation_matrix(slice_normal, slice_position, readout_direction=None)[source]#
Computes the 4x4 transformation matrix \(A\) that transform a positional vector \(r_{s}\) defined in slice-coordinates into the gobal coordinate system \(r_{g}\). To apply the transformation, compute the matrix-vector product:
\[(x_{g}, y_{g}, x_{g}, 1) = A \cdot (x_{s}, y_{s}, x_{s}, 1)\]To apply the inverse transformation, transpose the rotation-part of the matrix:
A_inv = A.copy() A_inv[:3, :3] = A[:3, :3].T
- Parameters:
slice_normal (
array
) –slice_position (
Quantity
) –readout_direction (
array
) –
- Returns:
transformation matrix - A (4, 4)
snr#
- calculate_snr(single_coil_images, dynamic_noise_scan, coil_sensitivities=None)[source]#
- Calculates the SNR for a multicoil-acquisition according to doi:10.1002/mrm.21868.
To guarantee correct scaling this assumes, non-zero-filled reconstruction.
Previously implemented by Robbert van Gorkum in the MRXCAT project.
- Parameters:
- Returns:
snr_map (X, Y, Z) of type float32
- compute_noise_std(noiseless_single_coil_images, target_snr, coil_sensitivities=None, mask=None, **kwargs)[source]#
- Computes the standard deviation of the complex gaussian noise for a set of target snr given
multiple single coil images, which are combined on reconstruction.
- Parameters:
noiseless_single_coil_images (
Union
[ndarray
,Tensor
]) – (n_coils, X, Y, [Z]) of type complex64coil_sensitivities (
Union
[ndarray
,Tensor
,None
]) – (n_coils, X, Y, [Z]) of type complex64, Optional: defaults to ones(1, X, Y, [Z]) Is used for iterative refinement.mask (
Union
[ndarray
,Tensor
,None
]) – (X, Y, [Z]) Optional: binary mask to specify ROI for SNR computation. Defaults to entire image.kwargs –
iteratively_refine: (bool) default=True. If True and coil_sensitivities are given, uses iterative method to refine std estimation.
- Return type:
- Returns:
estimated_stds (np.array) of type np.float32 with shape like np.array(target_snr)