### Install MRpro Python Package Source: https://docs.mrpro.rocks/user_guide Instructions for installing the MRpro framework using pip, including options for basic installation, additional dependencies for notebooks, and direct installation from the GitHub repository. ```Shell pip install mrpro ``` ```Shell pip install mrpro[notebooks] ``` ```Shell pip install "git+https://github.com/PTB-MR/mrpro" ``` -------------------------------- ### Install mrpro library if not present Source: https://docs.mrpro.rocks/_downloads/cc676d8b9b1ce252393c34d574f85f5e/tv_minimization_reconstruction_pdhg Checks for the presence of the 'mrpro' library and installs it along with its 'notebooks' dependencies if it's not found. This ensures the environment is set up correctly to run the reconstruction examples. ```python import importlib if not importlib.util.find_spec('mrpro'): %pip install mrpro[notebooks] ``` -------------------------------- ### Install MRpro with Notebooks Dependencies Source: https://docs.mrpro.rocks/_downloads/0bd3aa53b488f539fdf23fa4cdddd899/cartesian_reconstruction This snippet checks if the 'mrpro' library is installed and, if not, installs it along with its notebook-specific dependencies. This ensures that the necessary environment is set up for running the examples. ```python import importlib if not importlib.util.find_spec('mrpro'): %pip install mrpro[notebooks] ``` -------------------------------- ### Install mrpro library and dependencies Source: https://docs.mrpro.rocks/_downloads/08ecca3652a95795ea26ce68ca461824/comparison_trajectory_calculators This snippet checks for the presence of the 'mrpro' library. If not found, it proceeds to install 'mrpro' along with its 'notebooks' dependencies using pip, ensuring the environment is prepared for running the provided examples. ```python import importlib if not importlib.util.find_spec('mrpro'): %pip install mrpro[notebooks] ``` -------------------------------- ### mrpro.data.QHeader API Reference Source: https://docs.mrpro.rocks/_autosummary/mrpro.algorithms.prewhiten_kspace API documentation for the `QHeader` class, detailing its constructors from various sources, and properties related to resolution, position, orientation, and device status. ```APIDOC mrpro.data.QHeader: Methods: __init__() from_dicom() from_iheader() from_kheader() Properties: resolution position orientation device is_cpu is_cuda ndim ``` -------------------------------- ### Install mrpro library if not found Source: https://docs.mrpro.rocks/_downloads/0de23edf8dc53925d1e62f7ca38a8b00/direct_reconstruction This snippet checks for the presence of the 'mrpro' library and installs it along with its 'notebooks' dependencies if it's not already installed. This ensures that all necessary components for running the examples are available in the environment. ```python import importlib if not importlib.util.find_spec('mrpro'): %pip install mrpro[notebooks] ``` -------------------------------- ### API Documentation for DensityCompensationOp Source: https://docs.mrpro.rocks/_autosummary/mrpro.operators.models.EPG.initial_state Provides detailed API reference for the `DensityCompensationOp` class, specifically detailing its constructor. ```APIDOC DensityCompensationOp: Methods: __init__() ``` -------------------------------- ### mrpro.data.QHeader Class API Source: https://docs.mrpro.rocks/_autosummary/mrpro.operators.models.EPG.initial_state API documentation for the `QHeader` class, detailing its initialization methods from different sources, and properties for accessing resolution, position, orientation, and device information. ```APIDOC mrpro.data.QHeader: __init__() from_dicom() from_iheader() from_kheader() resolution position orientation device is_cpu is_cuda ndim ``` -------------------------------- ### Install mrpro library if not found Source: https://docs.mrpro.rocks/_downloads/6785dbff279df6db8fed91f8dfedbee5/iterative_sense_reconstruction_with_regularization Checks if the 'mrpro' library is available in the current environment. If not found, it proceeds to install 'mrpro' along with its 'notebooks' dependencies using pip, ensuring the necessary environment for running the examples. ```python import importlib if not importlib.util.find_spec('mrpro'): %pip install mrpro[notebooks] ``` -------------------------------- ### API Reference for mrpro.data.QHeader Source: https://docs.mrpro.rocks/_autosummary/mrpro.utils.slice_profiles.SliceGaussian API documentation for the `QHeader` class, detailing its initialization methods from various sources and properties for accessing resolution, position, orientation, and device information. ```APIDOC mrpro.data.QHeader: Methods: __init__() from_dicom() from_iheader() from_kheader() Properties: resolution position orientation device is_cpu is_cuda ndim ``` -------------------------------- ### mrpro.data.QData API Reference Source: https://docs.mrpro.rocks/_autosummary/mrpro.algorithms.prewhiten_kspace API documentation for the `QData` class, covering its initialization, data access, device handling, shape information, and various data manipulation methods. ```APIDOC mrpro.data.QData: Methods: __init__() from_single_dicom() apply() apply_() clone() concatenate() cpu() cuda() double() half() items() rearrange() single() split() to() __eq__() __new__() Properties: data header device is_cpu is_cuda ndim shape ``` -------------------------------- ### mrpro.data.QData Class Methods and Properties Source: https://docs.mrpro.rocks/_autosummary/mrpro.operators.models.WASABITI Documentation for the `QData` class in `mrpro.data`, covering its initialization, data access properties, device management methods, and various data manipulation functions like apply, clone, and concatenate. ```APIDOC class mrpro.data.QData: __init__() from_single_dicom() data header device is_cpu is_cuda ndim shape apply() apply_() clone() concatenate() cpu() cuda() double() half() items() rearrange() single() split() to() __eq__() __new__() ``` -------------------------------- ### Install mrpro library if not found Source: https://docs.mrpro.rocks/_downloads/a80110c83292567ac7d3d5b6da5eedef/qmri_sg_challenge_2024_t1 Checks if the 'mrpro' library is installed and installs it along with 'notebooks' dependencies if it's not found. This ensures the necessary environment for running the notebook. ```python import importlib if not importlib.util.find_spec('mrpro'): %pip install mrpro[notebooks] ``` -------------------------------- ### API Documentation for mrpro.operators.EinsumOp Source: https://docs.mrpro.rocks/user_guide Documents the `EinsumOp` class within the `mrpro.operators` module, outlining its constructor, properties, and various operator methods. ```APIDOC mrpro.operators.EinsumOp: __init__() H gram __call__() adjoint() forward() operator_norm() __add__() ``` -------------------------------- ### Install mrpro library and dependencies Source: https://docs.mrpro.rocks/_downloads/5c9b574f51852d92d9336bdf4d7a2616/qmri_cardiac_fingerprinting Checks if the 'mrpro' library is installed in the current environment. If not found, it proceeds to install 'mrpro' along with its notebook-specific dependencies using pip. This ensures all necessary packages are available for executing the notebook's code. ```python import importlib if not importlib.util.find_spec('mrpro'): %pip install mrpro[notebooks] ``` -------------------------------- ### Install mrpro library if not found Source: https://docs.mrpro.rocks/_downloads/6ae3823ec28b1274464026f5ea725b96/qmri_t1_mapping_with_grad_acq This snippet checks if the `mrpro` library is installed in the current environment. If it's not found, it proceeds to install `mrpro` along with its notebook-specific dependencies using `pip`. This ensures the necessary packages are available for executing the rest of the notebook. ```python import importlib if not importlib.util.find_spec('mrpro'): %pip install mrpro[notebooks] ``` -------------------------------- ### EinsumOp Class API Reference Source: https://docs.mrpro.rocks/_autosummary/mrpro.operators.functionals API documentation for the `EinsumOp` class, including its initialization, properties, and various operational methods. ```APIDOC mrpro.operators.EinsumOp: __init__() H gram __call__() adjoint() forward() operator_norm() __add__() __and__() __matmul__() __mul__() __or__() __radd__() __rmul__() ``` -------------------------------- ### Python: Examples for Rearranging Dataclass Dimensions Source: https://docs.mrpro.rocks/_autosummary/mrpro.data.CsmData Illustrative Python code examples demonstrating how to use the `rearrange()` method to split and reorder data dimensions. ```Python # Split the phase encode lines into 8 cardiac phases data.rearrange('batch coils k2 (phase k1) k0 -> batch phase coils k2 k1 k0', phase=8) # Split the k-space samples into 64 k1 and 64 k2 lines data.rearrange('... 1 1 (k2 k1 k0) -> ... k2 k1 k0', k2=64, k1=64, k0=128) ``` -------------------------------- ### mrpro.operators.DensityCompensationOp API Reference Source: https://docs.mrpro.rocks/_autosummary/mrpro.algorithms.optimizers.pgd API documentation for the `DensityCompensationOp` class, specifically detailing its constructor (`__init__`). ```APIDOC DensityCompensationOp: __init__() ``` -------------------------------- ### EinsumOp Class API Source: https://docs.mrpro.rocks/_autosummary/mrpro.operators.models.WASABITI API documentation for the `EinsumOp` class, including its initialization, properties, and various operator methods. ```APIDOC EinsumOp: __init__() H gram __call__() adjoint() forward() operator_norm() __add__() __and__() __matmul__() __mul__() __or__() __radd__() __rmul__() ``` -------------------------------- ### Python: Example Usage of mrpro.data.KHeader.rearrange Source: https://docs.mrpro.rocks/_autosummary/mrpro.data.KHeader Illustrates how to use the `rearrange` method of the `mrpro.data.KHeader` class with practical examples, demonstrating splitting phase encode lines and k-space samples. ```Python # Split the phase encode lines into 8 cardiac phases data.rearrange('batch coils k2 (phase k1) k0 -> batch phase coils k2 k1 k0', phase=8) # Split the k-space samples into 64 k1 and 64 k2 lines data.rearrange('... 1 1 (k2 k1 k0) -> ... k2 k1 k0', k2=64, k1=64, k0=128) ``` -------------------------------- ### mrpro.data.QHeader API Reference Source: https://docs.mrpro.rocks/_autosummary/mrpro.data.traj_calculators.KTrajectoryRpe API documentation for the `QHeader` class, which encapsulates quantitative header information. It provides methods for initialization from various sources and properties for accessing resolution, position, orientation, and device status. ```APIDOC QHeader: __init__() from_dicom() from_iheader() from_kheader() resolution position orientation device is_cpu is_cuda ndim ``` -------------------------------- ### Parameters and Examples for Data Splitting Source: https://docs.mrpro.rocks/_autosummary/mrpro.data.AcqInfo Defines parameters such as dimension, size, overlap, and dilation for splitting data, along with illustrative examples demonstrating their effect on the resulting data segments. ```APIDOC Parameters: dim (int): dimension to split along. size (int, default: 1): size of the splits. overlap (int, default: 0): overlap between splits. The stride will be `size - overlap`. Negative overlap will leave spaces between splits. dilation (int, default: 1): dilation of elements in each split. Examples: If the dimension has 6 elements: * split with size 2, overlap 0, dilation 1 -> elements (0,1), (2,3), and (4,5) * split with size 2, overlap 1, dilation 1 -> elements (0,1), (1,2), (2,3), (3,4), (4,5), and (5,6) * split with size 2, overlap 0, dilation 2 -> elements (0,2), and (3,5) * split with size 2, overlap -1, dilation 1 -> elements (0,1), and (3,4) Returns: A tuple of the splits. ``` -------------------------------- ### API Documentation for DensityCompensationOp Class Source: https://docs.mrpro.rocks/_autosummary/mrpro.utils.broadcasted_rearrange API documentation for the `DensityCompensationOp` class, specifically detailing its constructor. ```APIDOC DensityCompensationOp: __init__() ``` -------------------------------- ### mrpro.utils.broadcasted_rearrange Python Examples Source: https://docs.mrpro.rocks/_autosummary/mrpro.utils.broadcasted_rearrange Illustrative Python examples demonstrating the usage of `mrpro.utils.broadcasted_rearrange` with different input tensors and parameters, showcasing basic rearrangement, explicit broadcasting, and view reduction behavior. ```Python import torch from mrpro.utils import broadcasted_rearrange tensor = torch.randn(1, 16, 1, 768, 256) shape_result = broadcasted_rearrange(tensor, "... (phase k1) k0 -> phase ... k1 k0", phase=8, reduce_views=False).shape # Expected output: torch.Size([8, 1, 16, 1, 96, 256]) ``` ```Python import torch from mrpro.utils import broadcasted_rearrange tensor = torch.randn(1, 1, 1, 768, 1) shape_result = broadcasted_rearrange(tensor, "... (phase k1) k0 -> phase ... k1 k0", broadcasted_shape=(1, 16, 1, 768, 256), phase=8, reduce_views=False).shape # Expected output: torch.Size([8, 1, 16, 1, 96, 256]) # Behaves as-if the tensor was of shape (1, 16, 1, 768, 256) ``` ```Python import torch from mrpro.utils import broadcasted_rearrange tensor = torch.randn(1, 1, 1, 768, 1) shape_result = broadcasted_rearrange(tensor, "... (phase k1) k0 -> phase ... k1 k0", broadcasted_shape=(1, 16, 1, 768, 256) phase=8, reduce_views=True).shape # Expected output: torch.Size([8, 1, 1, 1, 96, 1]) # Dimensions that are stride-0 are reduced to singleton dimensions ``` -------------------------------- ### QHeader Class API Reference Source: https://docs.mrpro.rocks/_autosummary/mrpro.algorithms.optimizers.cg API documentation for the `QHeader` class in `mrpro.data`, covering its initialization, methods for creating headers from DICOM, iheader, or kheader, and properties for accessing resolution, position, orientation, and device information. ```APIDOC class QHeader: __init__() from_dicom() from_iheader() from_kheader() resolution: property position: property orientation: property device: property is_cpu: property is_cuda: property ndim: property ``` -------------------------------- ### mrpro Split Function Parameters and Examples Source: https://docs.mrpro.rocks/_autosummary/mrpro.data.KData Documents the parameters for a data splitting function, including dimension, size, overlap, and dilation, along with illustrative examples demonstrating how these parameters influence the resulting splits. ```APIDOC Parameters: dim: int – dimension to split along. size: int (default: 1) – size of the splits. overlap: int (default: 0) – overlap between splits. The stride will be `size - overlap`. Negative overlap will leave spaces between splits. dilation: int (default: 1) – dilation of elements in each split. Examples (If the dimension has 6 elements): split with size 2, overlap 0, dilation 1 → elements (0,1), (2,3), and (4,5) split with size 2, overlap 1, dilation 1 → elements (0,1), (1,2), (2,3), (3,4), (4,5), and (5,6) split with size 2, overlap 0, dilation 2 → elements (0,2), and (3,5) split with size 2, overlap -1, dilation 1 → elements (0,1), and (3,4) Returns: A tuple of the splits. ``` -------------------------------- ### QHeader Class API Reference Source: https://docs.mrpro.rocks/_autosummary/mrpro.operators.ConstraintsOp API documentation for the `QHeader` class in `mrpro.data`, detailing its initialization from various sources, and properties for accessing resolution, position, orientation, and device information. ```APIDOC mrpro.data.QHeader: __init__() from_dicom() from_iheader() from_kheader() resolution position orientation device is_cpu is_cuda ndim ``` -------------------------------- ### Example Output Log from PDHG Algorithm Source: https://docs.mrpro.rocks/_notebooks/tv_minimization_reconstruction_pdhg This is an example output log showing the objective function's value at various iterations during the PDHG algorithm's execution, demonstrating the convergence of the optimization process. ```Text Iteration 0: Objective = 1.721e-06 Iteration 16: Objective = 1.031e-06 Iteration 32: Objective = 8.298e-07 Iteration 48: Objective = 7.132e-07 Iteration 64: Objective = 6.370e-07 Iteration 80: Objective = 5.819e-07 Iteration 96: Objective = 5.397e-07 Iteration 112: Objective = 5.071e-07 Iteration 128: Objective = 4.808e-07 Iteration 144: Objective = 4.592e-07 Iteration 160: Objective = 4.414e-07 Iteration 176: Objective = 4.257e-07 Iteration 192: Objective = 4.118e-07 Iteration 208: Objective = 4.002e-07 Iteration 224: Objective = 3.904e-07 Iteration 240: Objective = 3.807e-07 Iteration 256: Objective = 3.721e-07 ``` -------------------------------- ### Conceptual Example for mrpro.utils.split_idx Logic Source: https://docs.mrpro.rocks/_autosummary/mrpro.utils.split_idx An illustrative example demonstrating the conceptual splitting logic of the `mrpro.utils.split_idx` function, showing how an input index array is divided into blocks based on specified block size, overlap, and cyclic parameters. ```Python # idx = [1,2,3,4,5,6,7,8,9], np_per_block = 5, np_overlap = 3, cycle = True # # idx: 1 2 3 4 5 6 7 8 9 # block 0: 0 0 0 0 0 # block 1: 1 1 1 1 1 # block 2: 2 2 2 2 2 # block 3: 3 3 3 3 3 ``` -------------------------------- ### Usage and Examples for mrpro.data.Dataclass.to Method Source: https://docs.mrpro.rocks/_autosummary/mrpro.data.AcqInfo Explains the core functionality of the `to` method for `mrpro.data.Dataclass`, detailing how it performs dtype and device conversions. It clarifies its relationship with `torch.Tensor.to` and provides specific examples of how different data types are handled during conversion. ```APIDOC Description: Perform dtype and/or device conversion of data. A torch.dtype and torch.device are inferred from the arguments args and kwargs. Please have a look at the documentation of torch.Tensor.to for more details. A new instance of the dataclass will be returned. The conversion will be applied to all Tensor- or Module fields of the dataclass, and to all fields that implement the Dataclass. The dtype-type, i.e. float or complex will always be preserved, but the precision of floating point dtypes might be changed. Examples: If called with `dtype=torch.float32` OR `dtype=torch.complex64`: * A `complex128` tensor will be converted to `complex64` * A `float64` tensor will be converted to `float32` * A `bool` tensor will remain `bool` * An `int64` tensor will remain `int64` ``` -------------------------------- ### QHeader Class API Reference Source: https://docs.mrpro.rocks/_autosummary/mrpro.algorithms.optimizers.pgd API documentation for the `QHeader` class, detailing its constructor, methods for creating instances from DICOM, iheader, or kheader, and properties for resolution, position, orientation, device information, and dimensionality. ```APIDOC QHeader: __init__() from_dicom() from_iheader() from_kheader() resolution position orientation device is_cpu is_cuda ndim ``` -------------------------------- ### QData Class API Documentation Source: https://docs.mrpro.rocks/_autosummary/mrpro.utils.unit_conversion.ms_to_s API documentation for the `mrpro.data.QData` class, covering its initialization, data access properties, device management methods, and various data manipulation functions. ```APIDOC mrpro.data.QData: __init__() from_single_dicom() data header device is_cpu is_cuda ndim shape apply() apply_() clone() concatenate() cpu() cuda() double() half() items() rearrange() single() split() to() __eq__() __new__() ``` -------------------------------- ### API Reference & Example: mrpro.data.DcfData.rearrange Method Source: https://docs.mrpro.rocks/_autosummary/mrpro.data.DcfData Documents the `rearrange` method, which allows flexible rearrangement of tensor dimensions within a `DcfData` object, similar to `einops.rearrange`. Includes a Python example demonstrating its usage for splitting phase encode lines. ```APIDOC rearrange(*pattern: str, **axes_lengths: int) -> Self Rearrange the data according to the specified pattern. Similar to `einops.rearrange`, allowing flexible rearrangement of data dimensions. Parameters: pattern (str): The rearrangement pattern string. axes_lengths (int): Keyword arguments specifying lengths for new axes. ``` ```python # Split the phase encode lines into 8 cardiac phases data.rearrange('batch coils k2 (phase k1) k0 -> batch phase coils k2 k1 k0', phase=8) ``` -------------------------------- ### APIDOC: EinsumOp Class Reference Source: https://docs.mrpro.rocks/_notebooks/qmri_cardiac_fingerprinting API documentation for the `EinsumOp` class, detailing its initialization, adjoint, gramian, forward, and operator norm methods, along with various arithmetic and bitwise dunder methods. ```APIDOC EinsumOp: __init__() H gram __call__() adjoint() forward() operator_norm() __add__() __and__() __matmul__() __mul__() __or__() __radd__() __rmul__() ``` -------------------------------- ### Download Raw Data for mrpro Example from Zenodo Source: https://docs.mrpro.rocks/_notebooks/comparison_trajectory_calculators This Python code snippet facilitates the download of raw MR data from a specified Zenodo record into a temporary directory. It leverages the `zenodo_get` library to fetch the data, which is a prerequisite for running the subsequent image reconstruction examples. ```python # Download raw data from Zenodo import tempfile from pathlib import Path import mrpro import torch import zenodo_get tmp = tempfile.TemporaryDirectory() # RAII, automatically cleaned up data_folder = Path(tmp.name) zenodo_get.download(record='14617082', retry_attempts=5, output_dir=data_folder) ``` -------------------------------- ### QHeader Class API Documentation Source: https://docs.mrpro.rocks/_autosummary/mrpro.utils.unit_conversion.ms_to_s API documentation for the `mrpro.data.QHeader` class, detailing its constructors from various sources, and properties for accessing resolution, position, orientation, and device information. ```APIDOC mrpro.data.QHeader: __init__() from_dicom() from_iheader() from_kheader() resolution position orientation device is_cpu is_cuda ndim ``` -------------------------------- ### Install mrpro Library if Not Found Source: https://docs.mrpro.rocks/_downloads/9cf9875eec8da88abc45b6a8b64afbff/pgd_wavelet_reconstruction This Python snippet checks for the presence of the `mrpro` library. If the library is not found in the current environment, it proceeds to install `mrpro` along with its notebook-specific dependencies using `pip`. This ensures that all necessary modules for the reconstruction process are available before execution. ```python import importlib if not importlib.util.find_spec('mrpro'): %pip install mrpro[notebooks] ``` -------------------------------- ### mrpro.operators.models Module API Reference Source: https://docs.mrpro.rocks/_autosummary/mrpro.operators.EinsumOp Comprehensive API documentation for the `mrpro.operators.models` module, listing key classes and their associated methods. This includes initialization, call, forward pass, and various operator overloading methods. ```APIDOC mrpro.operators.models.MOLLI __mul__() __radd__() __rmul__() mrpro.operators.models.MonoExponentialDecay __init__() __call__() forward() __add__() __matmul__() __mul__() __radd__() __rmul__() mrpro.operators.models.SaturationRecovery __init__() __call__() forward() __add__() __matmul__() __mul__() __radd__() __rmul__() mrpro.operators.models.SpoiledGRE __init__() __call__() forward() __add__() __matmul__() __mul__() __radd__() __rmul__() mrpro.operators.models.TransientSteadyStateWithPreparation __init__() __call__() ``` -------------------------------- ### Visualize M0 and T1 Starting Values Source: https://docs.mrpro.rocks/_notebooks/qmri_sg_challenge_2024_t1 Plots the calculated starting values for `M0` (equilibrium magnetization) and `T1` (longitudinal relaxation time) using `matplotlib`. This visualization provides a crucial visual inspection of the initial parameters derived from the dictionary matching, helping to assess their quality before proceeding with the non-linear optimization. ```Python fig, axes = plt.subplots(1, 2, figsize=(6, 2), squeeze=False) im = axes[0, 0].imshow(m0_start[0, 0]) axes[0, 0].set_title('$M_0$ start values') axes[0, 0].set_axis_off() fig.colorbar(im, ax=axes[0, 0], label='a.u.') im = axes[0, 1].imshow(t1_start[0, 0], vmin=0, vmax=2.5, cmap=Colormap('lipari').to_mpl()) axes[0, 1].set_title('$T_1$ start values') axes[0, 1].set_axis_off() fig.colorbar(im, ax=axes[0, 1], label='s') plt.show() ``` -------------------------------- ### QData Class API Reference Source: https://docs.mrpro.rocks/_autosummary/mrpro.operators.ConstraintsOp API documentation for the `QData` class in `mrpro.data`, covering its initialization, data access properties, device management methods, and various data manipulation functions. ```APIDOC mrpro.data.QData: __init__() from_single_dicom() data header device is_cpu is_cuda ndim shape apply() apply_() clone() concatenate() cpu() cuda() double() half() items() rearrange() single() split() to() __eq__() __new__() ``` -------------------------------- ### Determine Initial Value for Iterative Reconstruction Source: https://docs.mrpro.rocks/_downloads/3f8ef0c72e8d9b31624d32f0f6e83cef/iterative_sense_reconstruction_radial2D This code block calculates the initial value for the iterative reconstruction. It starts with the density-compensated adjoint reconstruction (A^H W y) and then applies a scaling factor to account for normalization differences, ensuring a well-conditioned starting point. ```python (u,) = (acquisition_operator.H @ dcf_operator)(kdata.data) scale = vdot(u, u) / vdot(u, *(acquisition_operator.H @ dcf_operator @ acquisition_operator)(u)) initial_value = u * scale ``` -------------------------------- ### Install mrpro Library if Not Found Source: https://docs.mrpro.rocks/_downloads/3f8ef0c72e8d9b31624d32f0f6e83cef/iterative_sense_reconstruction_radial2D This Python snippet checks for the presence of the 'mrpro' library. If it's not found in the current environment, it proceeds to install 'mrpro' along with its notebook-specific dependencies using the pip package manager, ensuring all required components are available for execution. ```python import importlib if not importlib.util.find_spec('mrpro'): %pip install mrpro[notebooks] ``` -------------------------------- ### API Reference for MOLLI Class Source: https://docs.mrpro.rocks/_autosummary/mrpro.algorithms.prewhiten_kspace Provides the API documentation for the MOLLI class, specifically detailing its constructor. ```APIDOC MOLLI: __init__(): ``` -------------------------------- ### Download Example MRI Data from Zenodo Source: https://docs.mrpro.rocks/_downloads/9cf9875eec8da88abc45b6a8b64afbff/pgd_wavelet_reconstruction This Python code block downloads example MRI k-space data from a specified Zenodo record. It uses `tempfile` to create a temporary directory for storing the downloaded files, ensuring a clean environment. The `zenodo_get` library handles the download process, including retries for robustness. ```python import tempfile from pathlib import Path import zenodo_get tmp = tempfile.TemporaryDirectory() # RAII, automatically cleaned up data_folder = Path(tmp.name) zenodo_get.download(record='14617082', retry_attempts=5, output_dir=data_folder) ``` -------------------------------- ### API Reference for EinsumOp Source: https://docs.mrpro.rocks/_autosummary/mrpro.utils API documentation for the `EinsumOp` class, providing details on its initialization, properties, and methods for Einstein summation and related functional and arithmetic operations. ```APIDOC EinsumOp: __init__() H gram __call__() adjoint() forward() operator_norm() __add__() __and__() __matmul__() __mul__() __or__() __radd__() __rmul__() ``` -------------------------------- ### API Documentation for ZeroOp Class Source: https://docs.mrpro.rocks/_autosummary/mrpro.utils.summarize_object Details the API for the `ZeroOp` class, outlining its constructor, adjoint, forward methods, and properties related to zero operations. ```APIDOC ZeroOp: __init__() H gram __call__() adjoint() forward() operator_norm() ``` -------------------------------- ### Initialize M0 and T1 Start Values from Dictionary Source: https://docs.mrpro.rocks/_downloads/a80110c83292567ac7d3d5b6da5eedef/qmri_sg_challenge_2024_t1 This line initializes the starting values for M0 (equilibrium magnetization) and T1 (longitudinal relaxation time) by looking up the closest values in a pre-computed dictionary based on cosine similarity for each voxel. These values serve as initial guesses for the subsequent optimization process. ```python m0_start, t1_start = dictionary(idata_multi_ti.data.real) ``` -------------------------------- ### APIDOC: EinsumOp Class Methods Source: https://docs.mrpro.rocks/_autosummary/mrpro.data.QData API documentation for the EinsumOp class, detailing its available methods and properties. ```APIDOC EinsumOp: __init__() H gram __call__() adjoint() forward() operator_norm() __add__() __and__() __matmul__() __mul__() __or__() __radd__() __rmul__() ``` -------------------------------- ### Get Identity Rotation Source: https://docs.mrpro.rocks/_autosummary/mrpro.data.Rotation Retrieves the identity rotation, where a single rotation is generated. ```APIDOC Rotation: identity(): Description: A single rotation is generated. Returns: identity: The identity rotation. ``` -------------------------------- ### Get Quaternion Y Component Source: https://docs.mrpro.rocks/_autosummary/mrpro.data.Rotation Retrieves the 'y' component (second vector part) of the quaternion representation of the rotation. ```APIDOC Property: quaternion_y Type: Tensor Description: Get y component of the quaternion. ``` -------------------------------- ### QHeader Class API Reference Source: https://docs.mrpro.rocks/_autosummary/mrpro.utils.split_idx API documentation for the `QHeader` class, detailing its constructors from different sources, and properties for accessing resolution, position, orientation, device information, and dimensionality. ```APIDOC mrpro.data.QHeader: __init__() from_dicom() from_iheader() from_kheader() resolution position orientation device is_cpu is_cuda ndim ``` -------------------------------- ### QHeader Class API Reference Source: https://docs.mrpro.rocks/_autosummary/mrpro.utils.unit_conversion.s_to_ms API documentation for the `QHeader` class in `mrpro.data`, outlining its constructors, properties for resolution, position, and orientation, and device-related attributes. ```APIDOC mrpro.data.QHeader: __init__() from_dicom() from_iheader() from_kheader() resolution position orientation device is_cpu is_cuda ndim ``` -------------------------------- ### Get Device of Rotation Source: https://docs.mrpro.rocks/_autosummary/mrpro.data.Rotation Retrieves the PyTorch device on which the Rotation object's data is located. ```APIDOC Property: device Type: device Description: Get the device of the Rotation. ``` -------------------------------- ### API Reference for EinsumOp Source: https://docs.mrpro.rocks/_autosummary/mrpro.algorithms API documentation for the `EinsumOp` class, detailing its constructor, properties, and methods for Einstein summation operations. ```APIDOC EinsumOp: __init__() H gram __call__() adjoint() forward() operator_norm() __add__() __and__() __matmul__() __mul__() __or__() __radd__() __rmul__() ``` -------------------------------- ### Python Example: L1 Regularized Image Reconstruction with PGD Source: https://docs.mrpro.rocks/_autosummary/mrpro.algorithms.optimizers.pgd This Python example demonstrates the application of the `pgd` function for L1 regularized image reconstruction. It initializes k-space data, defines the forward operator (Fast Fourier Transform), the data fidelity term (L2 norm squared), and the regularization term (L1 norm). It then calculates an appropriate step size and calls the `pgd` optimizer to find the image solution. ```Python kspace_data = torch.randn(3, 10, 10 , dtype=torch.complex64) fft = FastFourierOp() l2 = L2NormSquared(target=kspace_data) f = l2 @ fft reg_parameter = 0.01 g = reg_parameter * L1Norm() operator_norm = 1. stepsize = 0.85 * 1 / operator_norm**2 initial_value = torch.ones(3,10,10) pgd_image_solution = pgd( f=f, g=g, initial_value=initial_value, stepsize=stepsize, max_iterations=200, backtrack_factor=1.0, ) ``` -------------------------------- ### API Reference for EinsumOp Class Source: https://docs.mrpro.rocks/_autosummary/mrpro.algorithms.optimizers.lbfgs Documents the `EinsumOp` class, detailing its initialization, properties like H and gram, and various operator methods for Einstein summation. ```APIDOC EinsumOp: __init__() H gram __call__() adjoint() forward() operator_norm() __add__() __and__() __matmul__() __mul__() __or__() __radd__() __rmul__() ``` -------------------------------- ### Get Quaternion W Component Source: https://docs.mrpro.rocks/_autosummary/mrpro.data.Rotation Retrieves the 'w' component (scalar part) of the quaternion representation of the rotation. ```APIDOC Property: quaternion_w Type: Tensor Description: Get w component of the quaternion. ``` -------------------------------- ### API Reference for mrpro.data.AcqInfo Class Source: https://docs.mrpro.rocks/_autosummary/mrpro.algorithms.prewhiten_kspace Documents the `AcqInfo` class, including its constructor. ```APIDOC AcqInfo: __new__() ``` -------------------------------- ### Get Batch Shape of Rotation Source: https://docs.mrpro.rocks/_autosummary/mrpro.data.Rotation Returns the batch shape of the Rotation object, indicating the dimensions of the rotation data. ```APIDOC Property: shape Type: Size Description: Return the batch shape of the Rotation. ``` -------------------------------- ### QHeader Class API Reference Source: https://docs.mrpro.rocks/_autosummary/mrpro.utils.typing API documentation for the QHeader class, detailing its constructors from different sources, and properties for accessing resolution, position, orientation, device status, and dimensions. ```APIDOC QHeader: - __init__() - from_dicom() - from_iheader() - from_kheader() - resolution - position - orientation - device - is_cpu - is_cuda - ndim ``` -------------------------------- ### Get Quaternion Z Component Source: https://docs.mrpro.rocks/_autosummary/mrpro.data.Rotation Retrieves the 'z' component (third vector part) of the quaternion representation of the rotation. ```APIDOC Property: quaternion_z Type: Tensor Description: Get z component of the quaternion. ``` -------------------------------- ### API Documentation for EinsumOp Source: https://docs.mrpro.rocks/_autosummary/mrpro.phantoms.brainweb API documentation for the `EinsumOp` class, detailing its constructor, properties, and methods for Einstein summation operations. ```APIDOC EinsumOp: __init__(): H: gram: __call__(): adjoint(): forward(): operator_norm(): __add__(): __and__(): __matmul__(): __mul__(): __or__(): __radd__(): __rmul__(): ``` -------------------------------- ### Get Quaternion X Component Source: https://docs.mrpro.rocks/_autosummary/mrpro.data.Rotation Retrieves the 'x' component (first vector part) of the quaternion representation of the rotation. ```APIDOC Property: quaternion_x Type: Tensor Description: Get x component of the quaternion. ``` -------------------------------- ### mrpro.operators.DensityCompensationOp API Source: https://docs.mrpro.rocks/_autosummary/mrpro.algorithms.optimizers.lbfgs API documentation for the `DensityCompensationOp` class, detailing its initialization method. ```APIDOC DensityCompensationOp: __init__() ``` -------------------------------- ### Get Number of Dimensions (ndim) Property Source: https://docs.mrpro.rocks/_autosummary/mrpro.data.KTrajectory Returns the number of dimensions of the dataclass, representing the broadcasted shape of all fields. ```APIDOC property ndim: int Description: Return the number of dimensions of the dataclass. This is the number of dimensions of the broadcasted shape of all fields. ``` -------------------------------- ### API Documentation for mrpro.data.AcqInfo Class Source: https://docs.mrpro.rocks/_autosummary/mrpro.operators.ZeroPadOp Documents the `AcqInfo` class, primarily detailing its `__new__` method for object instantiation. ```APIDOC mrpro.data.AcqInfo: __new__() ``` -------------------------------- ### Get number of dimensions (ndim property) Source: https://docs.mrpro.rocks/_autosummary/mrpro.data.AcqInfo Returns the number of dimensions of the dataclass, which is derived from the broadcasted shape of all its fields. ```APIDOC ndim: int Return the number of dimensions of the dataclass. This is the number of dimensions of the broadcasted shape of all fields. ``` -------------------------------- ### Get Determinant of Rotation Source: https://docs.mrpro.rocks/_autosummary/mrpro.data.Rotation Returns the determinant of the rotation matrix. This value will be 1.0 for proper rotations and -1.0 for improper rotations. ```APIDOC Property: det Type: Tensor Description: Returns the determinant of the rotation matrix. Will be 1. for proper rotations and -1. for improper rotations. ``` -------------------------------- ### API Documentation for EinsumOp Source: https://docs.mrpro.rocks/_autosummary/mrpro.operators.models.SaturationRecovery API reference for the `EinsumOp` class, detailing its constructor, properties, and methods, including operator overloading methods. ```APIDOC EinsumOp: __init__() H gram __call__() adjoint() forward() operator_norm() __add__() __and__() __matmul__() __mul__() __or__() __radd__() __rmul__() ``` -------------------------------- ### QHeader Class API Reference Source: https://docs.mrpro.rocks/_autosummary/mrpro.operators.models.SaturationRecovery API documentation for the `QHeader` class, detailing its constructor, methods for creating headers from various sources, and properties for accessing resolution, position, orientation, and device information. ```APIDOC QHeader: __init__() from_dicom() from_iheader() from_kheader() resolution position orientation device is_cpu is_cuda ndim ``` -------------------------------- ### Get Broadcasted Shape (shape) Property Source: https://docs.mrpro.rocks/_autosummary/mrpro.data.KTrajectory Returns the broadcasted shape of all tensor/data fields within the dataclass. Each field is broadcastable to this shape. ```APIDOC property shape: Size Description: Return the broadcasted shape of all tensor/data fields. Each field of this dataclass is broadcastable to this shape. Returns: The broadcasted shape of all fields. Raises: InconsistentShapeError: If the shapes cannot be broadcasted. ``` -------------------------------- ### Get Iterator for Dataclass Fields (mrpro.data.Dataclass) Source: https://docs.mrpro.rocks/_autosummary/mrpro.data.Dataclass Returns an iterator over the names and values of the fields contained within the Dataclass instance. ```APIDOC items() -> Iterator[tuple[str, Any]] Description: Get an iterator over names and values of fields. ``` -------------------------------- ### mrpro.data Module API Reference Source: https://docs.mrpro.rocks/_autosummary/mrpro.algorithms.optimizers.lbfgs Detailed API documentation for the `mrpro.data` module, including classes `KTrajectory`, `Limits`, `QData`, and `QHeader` and their respective methods and properties. ```APIDOC mrpro.data.KTrajectory: Methods: concatenate() cpu() cuda() double() half() items() rearrange() single() split() to() __eq__() __new__() mrpro.data.Limits: Methods: __init__() from_ismrmrd() to_ismrmrd() __eq__() __new__() Properties: min max center length mrpro.data.QData: Methods: __init__() from_single_dicom() apply() apply_() clone() concatenate() cpu() cuda() double() half() items() rearrange() single() split() to() __eq__() __new__() Properties: data header device is_cpu is_cuda ndim shape mrpro.data.QHeader: Methods: __init__() from_dicom() from_iheader() from_kheader() Properties: resolution position orientation device is_cpu is_cuda ndim ``` -------------------------------- ### Get Number of Dimensions (ndim) - mrpro.data Source: https://docs.mrpro.rocks/_autosummary/mrpro.data.CsmData Retrieves the total number of dimensions for the dataclass, which corresponds to the broadcasted shape of all its fields. ```APIDOC property ndim: int Return the number of dimensions of the dataclass. This is the number of dimensions of the broadcasted shape of all fields. ``` -------------------------------- ### mrpro.data.QData Class API Source: https://docs.mrpro.rocks/_autosummary/mrpro.operators.models.EPG.initial_state API documentation for the `QData` class, outlining its initialization methods, data access properties, and various utility functions for data processing, device management, and array manipulation. ```APIDOC mrpro.data.QData: __init__() from_single_dicom() data header device is_cpu is_cuda ndim shape apply() apply_() clone() concatenate() cpu() cuda() double() half() items() rearrange() single() split() to() __eq__() __new__() ``` -------------------------------- ### QHeader Class API Reference Source: https://docs.mrpro.rocks/_autosummary/mrpro.utils.TensorAttributeMixin API documentation for the `QHeader` class, detailing its constructor, methods for creating instances from DICOM, iheader, or kheader, and properties for accessing resolution, position, orientation, device information, and dimensionality. ```APIDOC QHeader: __init__() from_dicom() from_iheader() from_kheader() resolution position orientation device is_cpu is_cuda ndim ``` -------------------------------- ### Get Iterator for mrpro.data.AcqInfo Fields Source: https://docs.mrpro.rocks/_autosummary/mrpro.data.AcqInfo Documents the `items()` method, which provides an iterator over the names and values of fields within the data class. ```APIDOC items() -> Iterator[tuple[str, Any]] Description: Get an iterator over names and values of fields. ``` -------------------------------- ### mrpro.data.traj_calculators Module Classes Source: https://docs.mrpro.rocks/_autosummary/mrpro.phantoms.brainweb This section outlines the classes within the `mrpro.data.traj_calculators` module, which are responsible for computing k-space trajectories. An example class is `KTrajectoryCalculator`. ```APIDOC mrpro.data.traj_calculators: KTrajectoryCalculator ``` -------------------------------- ### AcqInfo Class API Documentation Source: https://docs.mrpro.rocks/_autosummary/mrpro.algorithms.csm.inati API documentation for the `AcqInfo` class, detailing its constructor. ```APIDOC AcqInfo: __new__() ``` -------------------------------- ### Get Magnitude of mrpro.data.Rotation Source: https://docs.mrpro.rocks/_autosummary/mrpro.data.Rotation Documents the `magnitude` method, which returns the angular magnitude(s) of the rotation(s) in radians, always within the range [0, pi]. ```APIDOC magnitude() -> torch.Tensor Get the magnitude(s) of the rotation(s). Returns: magnitude (torch.Tensor): Angles in radians. The magnitude will always be in the range [0, pi]. ``` -------------------------------- ### API Documentation for DensityCompensationOp Source: https://docs.mrpro.rocks/_autosummary/mrpro.utils.unit_conversion.deg_to_rad API documentation for the `DensityCompensationOp` class, specifically detailing its constructor. ```APIDOC DensityCompensationOp: __init__() ``` -------------------------------- ### QData Class API Reference Source: https://docs.mrpro.rocks/_autosummary/mrpro.algorithms.optimizers.pgd API documentation for the `QData` class, covering its initialization, methods for creating instances from DICOM, properties for data, header, device information, and methods for applying operations, cloning, concatenation, device transfer, data type conversion, item access, rearrangement, and splitting. ```APIDOC QData: __init__() from_single_dicom() data header device is_cpu is_cuda ndim shape apply() apply_() clone() concatenate() cpu() cuda() double() half() items() rearrange() single() split() to() __eq__() __new__() ``` -------------------------------- ### Get Identity Rotation(s) (identity) Source: https://docs.mrpro.rocks/_autosummary/mrpro.data.Rotation This class method generates one or more identity rotation objects. Composition with an identity rotation has no effect on other rotations. ```APIDOC classmethod identity( shape: int | None | tuple[int, ...] = None ) -> Self Description: Get identity rotation(s). Composition with the identity rotation has no effect. Parameters: shape (int | None | tuple[int, ...], default: None): Number of identity rotations to generate. If None, then a single identity rotation is returned. Returns: Self: Object containing the identity rotation(s). ``` -------------------------------- ### Get number of dimensions Source: https://docs.mrpro.rocks/_autosummary/mrpro.data.QHeader Returns the total number of dimensions for the dataclass. This value represents the number of dimensions of the broadcasted shape across all fields. ```APIDOC property ndim: int Returns: The number of dimensions of the dataclass. This is the number of dimensions of the broadcasted shape of all fields. ``` -------------------------------- ### QData Class API Reference Source: https://docs.mrpro.rocks/_autosummary/mrpro.utils.typing API documentation for the QData class, covering its initialization, data access properties, device management methods, and various data manipulation functions. ```APIDOC QData: - __init__() - from_single_dicom() - data - header - device - is_cpu - is_cuda - ndim - shape - apply() - apply_() - clone() - concatenate() - cpu() - cuda() - double() - half() - items() - rearrange() - single() - split() - to() - __eq__() - __new__() ``` -------------------------------- ### API Documentation for EinsumOp Source: https://docs.mrpro.rocks/_autosummary/mrpro.phantoms.brainweb.BrainwebTissue Provides an API reference for the `EinsumOp` class, detailing its constructor, properties, and methods for Einstein summation operations. ```APIDOC EinsumOp: __init__(): H: gram: __call__(): adjoint(): forward(): operator_norm(): __add__(): __and__(): __matmul__(): __mul__(): __or__(): __radd__(): __rmul__(): ``` -------------------------------- ### Get Number of Dimensions for Dataclass Source: https://docs.mrpro.rocks/_autosummary/mrpro.data.KNoise Retrieves the number of dimensions for the dataclass. This value is derived from the broadcasted shape of all fields contained within the dataclass. ```APIDOC property ndim: int Description: Return the number of dimensions of the dataclass. Details: This is the number of dimensions of the broadcasted shape of all fields. ```