scieee AI-readable full text Open interactive document viewer

A clinically viable vendor-independent and device-agnostic solution for accelerated cardiac MRI reconstruction

Martín González, Elena,Moya Saez, Elisa,Menchon Lara, Rosa María,Royuela del Val, Javier,Palencia de Lara, César,Rodríguez Cayetano, Manuel,Simmross Wattenberg, Federico Jesús,Alberola López, Carlos

Abstract

Producción Científica

Full text

Computer Methods and Programs in Biomedicine 207 (2021) 106143 Contents lists available at ScienceDirect Computer Methods and Programs in Biomedicine journal homepage: www.elsevier.com/locate/cmpb A clinically viable vendor-independent and device-agnostic solution for accelerated cardiac MRI reconstruction Elena Martín-González a , Elisa Moya-Sáez a , Rosa-María Menchón-Lara a , Javier Royuela-del-Val c , César Palencia-de-Lara b , Manuel Rodríguez-Cayetano a , Federico Simmross-Wattenberg a , ∗, Carlos Alberola-López a a Laboratorio de Procesado de Imagen (Image Processing Laboratory), Universidad de Valladolid, Valladolid 47011, Spain b Departamento de Matemática Aplicada, Universidad de Valladolid, Valladolid, Spain c Health Time Group, Córdoba, Spain a r t i c l e i n f o Article history: Received 18 December 2020 Accepted 25 April 2021 Keywords: Magnetic resonance imaging GPU OpenCLIPER OpenCL a b s t r a c t Background and objective : Recent research has reported methods that reconstruct cardiac MR images acquired with acceleration factors as high as 15 in Cartesian coordinates. However, the computational cost of these techniques is quite high, taking about 40 min of CPU time in a typical current machine. This delay between acquisition and final result can completely rule out the use of MRI in clinical environments in favor of other techniques, such as CT. In spite of this, reconstruction methods reported elsewhere can be parallelized to a high degree, a fact that makes them suitable for GPU-type computing devices. This paper contributes a vendor-independent, device-agnostic implementation of such a method to reconstruct 2D motion-compensated, compressed-sensing MRI sequences in clinically viable times. Methods: By leveraging our OpenCLIPER framework, the proposed system works in any computing device (CPU, GPU, DSP, FPGA, etc.), as long as an OpenCL implementation is available, and development is significantly simplified versus a pure OpenCL implementation. In OpenCLIPER, the problem is partitioned in independent black boxes which may be connected as needed, while device initialization and maintenance is handled automatically. Parallel implementations of both a groupwise FFD-based registration method, as well as a multicoil extension of the NESTA algorithm have been carried out as processes of OpenCLIPER. Our platform also includes significant development and debugging aids. HIP code and precompiled libraries can be integrated seamlessly as well since OpenCLIPER makes data objects shareable between OpenCL and HIP. This also opens an opportunity to include CUDA source code (via HIP) in prospective developments. Results : The proposed solution can reconstruct a whole 12–14 slice CINE volume acquired in 19–32 coils and 20 phases, with an acceleration factor of ranging 4–8, in a few seconds, with results comparable to another popular platform (BART). If motion compensation is included, reconstruction time is in the order of one minute. Conclusions : We have obtained clinically-viable times in GPUs from different vendors, with delays in some platforms that do not have correspondence with its price in the market. We also contribute a parallel groupwise registration subsystem for motion estimation/compensation and a parallel multicoil NESTA subsystem for l1 −l2 -norm problem solving. ©2021 The Authors. Published by Elsevier B.V. This is an open access article under the CC BY license ( http://creativecommons.org/licenses/by/4.0/ ) ∗Corresponding author. E-mail addresses: emarg[email protected]a.es , [email protected]a.es (E. Martín- González), emoy[email protected]a.es (E. Moya-Sáez), [email protected]a.es (R.-M. Menchón-Lara), [email protected]g (J. Royuela-del-Val), [email protected] (C. Palencia-de-Lara), [email protected]a.es (M. Rodríguez-Cayetano), [email protected]a.es , [email protected] (F. Simmross-Wattenberg), [email protected]el.uva.es (C. Alberola-López). https://doi.org/10.1016/j.cmpb.2021.106143 0169-2607/© 2021 The Authors. Published by Elsevier B.V. This is an open access article under the CC BY license ( http://creativecommons.org/licenses/by/4.0/ ) E. Martín-González, E. Moya-Sáez, R.-M. Menchón-Lara et al. Computer Methods and Programs in Biomedicine 207 (2021) 106143 1. Introduction Magnetic resonance (MR) is a high-quality and highly versatile medical imaging modality. Not only anatomical images with different contrasts can be acquired, but also a number of properlydesigned pulse sequences provide additional information, such as diffusion, perfusion, fMRI and a few others. Dynamic imaging is also possible and MR currently constitutes the golden standard for functional studies of the heart [1] . However, its major drawback is its inherent slowness relative to other alternatives such as CT and US. A complete study in MRI may take 30–45 min, whereas CT takes a few minutes and US is observed in real time. This has the consequence of patient discomfort, which leads to motion artifacts in the images, the need of synchronization for dynamic studies and poses additional difficulties for imaging non-cooperative patients, such as children or the elderly. This being the case, the MR community is doing a considerable effort to increase the velocity of MR acquisition and to diminish the need of additional hardware (such as navigators, ECG or PPG synchronization, etc.). Apart from improvements in the hardware of the scanners —that provide higher and more homogeneous fields, more intense and faster gradients, etc.—, many different software solutions have been described, which include parallel imaging (PI) and compressed sensing (CS). In terms of reconstruction [2] , different algorithms are capable of reconstructing images from undersampled k-space information; leaving aside modern deep learning-based approaches, for which their bottleneck is the training stage, classical algorithms are optimization-based and they may be computationally demanding, depending on their complexity. Hence fast implementations and appropriate computing hardware make a difference so as to obtain solutions in clinically viable times. Here, clinical viable time is interpreted as the time taken to reconstruct an image that is compatible with repeating an acquisition —whenever the reconstruction is considered of insufficient quality— without causing an unacceptable overload in clinical routine 1 . The MR reconstruction workload turns out to be highly parallelizable so proper implementations on natively-parallel devices, such as (but not limited to) GPUs, are currently playing an outstanding role. Many different attempts have been reported to speed up reconstruction algorithms by means of parallel devices. Section 2 provides an overview of the field. As of today, the field of parallel computing has seen a tremendous growth of tailored solutions that work exclusively on a particular vendor GPU, namely, nVidia. Nevertheless, other alternatives exist. One of them is OpenCL [4] ; OpenCL is an open standard for parallel computing, similar in its objectives to the nVidia-exclusive language CUDA, but covers a much wider set of computing devices (including nVidia GPUs) while ensuring that source code and data are unique, thus avoiding the need for code and data replication among prospectively supported devices. However, it is generally regarded as more complicated and less mature than CUDA. As a matter of fact, OpenCL programmers must deal on their own with device selection and initialization, memory management, kernel loading and compilation, host-device interaction, and administration overload. Another example is HIP [5] ; this initiative helps developers in converting CUDA source code into a more portable form, so that it can run on both nVidia and AMD GPUs. However, as of today, the HIP API is not compatible with OpenCL, so data objects defined in OpenCL cannot be used as parameters to HIP kernels and viceversa, even though OpenCL data is undistinguishable from HIP (or CUDA) data in the GPU memory. 1 Issues related to DICOM interoperability are a step further and well-known solutions are available [3] . We concentrate on operations on the reconstruction problem once all the necessary data is available. The framework OpenCLIPER [6] was developed to address all these shortcomings of OpenCL. In this paper, OpenCLIPER has been used to provide a parallel implementation of our previous proposal [7] on 2D cardiac cine imaging. This algorithm combines CS with Groupwise Motion Compensation (MC) to achieve CINE sequences with acceleration factors (AFs) of 8–15x, which show higher quality than other methods with pairwise approaches for motion compensation. Nevertheless, in its non-parallel version, the post-acquisition reconstruction takes a significant computation time (about 40 min in a Core i7-4790 CPU for the full heart coverage), which is far from being clinically viable. In this paper, we show how OpenCLIPER eases dramatically the process of parallelizing a complex algorithm previously programmed in a scripting language. 2 As a byproduct, we have enlarged the OpenCLIPER library with additional parallel functionality, such as a groupwise version of a registration algorithm based on free form deformations (FFD) [8] or a multicoil parallel adaptation of the NESTA optimization algorithm [9] . None of these algorithms, to the best of our knowledge, are currently available on GPUs. A comparison with another popular framework (BART, see Section 2 ) is included. In addition, we show how to seamlessly incorporate HIP code to Open- CLIPER by solving the integration difficulty referred to above; this opens up the possibility of using CUDA code in our framework —as long as this code can be converted to HIP— at programmer will. The rest of this paper is organized as follows: Section 2 reviews the subject of current parallel implementations of undersampled MRI reconstruction algorithms. Section 3 describes the innards of our proposed implementation. Section 4 evaluates our proposal performance in various computing devices and compares it, as previously mentioned, with another popular framework. The discussion can be found in Sections 5 and 6 concludes the paper. A number of appendices of both mathematical and algorithmic details have been included for the sake of self-completeness. 2. Related work The field of MR reconstruction is very active and quite an activity has been focused on algorithm implementation on GPUs. Two recent survey papers [10,11] give a general overview of the field; the former is dedicated to GPU-based medical image reconstruction while the latter is specifically targeted to MR reconstruction. Both survey papers, however, have a similar structure as for their common topic; they review FFT-based methods, either for Cartesian and non-Cartesian data, PI and CS-based applications. The 2018 survey also includes a section on reconstruction based on deep-learning, probably spurred by the enormous activity that has been reported in the last two years. Both papers also quote some recent work on multi-GPU solutions. The reader is kindly invited to consult the references therein. Apart from particular implementations of reconstruction algorithms, the field has been enriched with a number of libraries, some examples of which are AGILE [12] , BART [13] , Gadgetron [14] and Impatient [15] , to explicitly mention four of them. Additional libraries are mentioned in our former publication on Open- CLIPER [6] . These libraries are conceived to ease the process of algorithm prototyping and testing; Gadgetron shows additional client-server characteristics, where the server takes care of the reconstruction process while the client focuses on data handling, i.e., Gadgetron could be considered both as a library and as a network service. The common ground of these references, both in terms of specific algorithms and of reconstruction toolkits, is that they are based on the CUDA language and, consequently, they are vendor 2 OpenCLIPER code available at http://opencliper.lpi.tel.uva.es/ . 2 E. Martín-González, E. Moya-Sáez, R.-M. Menchón-Lara et al. Computer Methods and Programs in Biomedicine 207 (2021) 106143 dependent. nVidia, since its onset in 2007 with the release of its CUDA application programming interface [16] , has become the main supplier in the field of parallel computing with GPUs, both in academia and in industry. Its mainstream condition is accompanied, however, with some unavoidable consequences which can be summarized in two, namely, the need of code duplication should the application be run in GPU and in CPU (or in any other device), and the need of data replication in the platforms in which the application is deployed. Alternatives to this technology are also available, mainly, Direct Compute issued by Microsoft and, as previously stated, OpenCL, an open source project led by the Khronos Group [11] . The latter has the benefits of being both open-source and device agnostic; the second feature makes it comply with the write-once run-anywhere (WORA) paradigm. An additional solution has been proposed, which is a domain specific computational image reconstruction language, referred to as Indigo [17] . It provides a frontend with a number of image reconstruction facilities, as well as a back-end that is responsible to evaluate the operators provided by the front-end on a particular platform. As long as different backends are available, the language will follow the WORA paradigm, although as of today it seems limited to CUDA as for GPU implementation. As we mentioned in the Introduction, in this paper we illustrate how OpenCLIPER can be used to find a solution to a 2D dynamic cardiac image reconstruction algorithm, that makes wholeheart single breath-hold reconstruction possible [18] in clinically feasible times. Our algorithm makes use of an optimizer, for which we have used NESTA [9] as well as FFD [8] for motion compensation. Further algorithmic details of the method are described elsewhere [7,19] . As for the NESTA algorithm, we are only aware of a GPU version, which was recently described in Dinh et al. [20] ; however, in that implementation, a single coil is apparently used. In our implementation, multiple coils are employed and the algorithm is fully parallel in the coils as well. As for the FFDs, some GPU-based implementations were described in Modat et al. [21] , Ruijters et al. [22] , Du et al. [23] , Ellingwood et al. [24] , Punithakumar et al. [25] ; however, these proposals are pairwise and devicespecific. We show in Royuela-del Val et al. [7] that a groupwise registration has added benefits in terms of reconstruction quality; consequently, the implementation we have carried out is groupwise and specifically targeted for cardiac cine MRI. 3. The proposed system 3.1. The algorithm CINE cardiac MR images can be reconstructed from highly undersampled data while keeping a very high level of detail from the fully-sampled images. A state-of-the-art algorithm on this topic was published in Royuela-del Val et al. [7] and later enhanced in Royuela-del Val et al. [19] . Briefly described, the algorithm departs from the multi-coil k-space subsampled information band solves a CS reconstruction problem which gives the resulting image sequence m i , at iteration step i , as m i = arg min m || b −Em || 2 l 2 + λ|| T m || l 1 (1) m i is a vectorized stack of image frames, one frame per cardiac phase. Eis the encoding operator that includes the multiplication by the coil sensitivities S, the intra-frame spatial Fourier transform Fand the application of the undersampling mask A . is the temporal total variation (tTV) operator. T is the groupwise (GW) transformation for motion compensation (MC) that registers all the frames in the sequence to a common reference and λis a regularization parameter. Appendix A describes a matrix formalization of these data structures and operators. As for m 0 , the transformation T is the identity, since there is no data from which motion information can be estimated. Then, the iterative refinement process finds m i with T obtained by the heart motion estimation (ME) on m i −1 . The whole process continues until a predefined number of iterations is met. In this manuscript, the number of ME/MC reconstruction iterations was set to two. The ME/MC is carried out by means of elastic registration [26] . As previously stated, we use FFDs [8] ; Appendix B provides details on the ME/MC process. B-splines serve the purpose of interpolating the deformation field (see Eq. (B.3) ) from a given control point configuration to give rise to a dense field. Specifically, we apply a GW paradigm in which no particular frame is selected as a reference, but the reference is built along the optimization process as the average of the transformed images. As for the metric to be optimized, we have used the sum of the intensity square differences (SSD) with respect to the reference image (see Eq. (B.1) ); this metric is enlarged with smoothness terms so as to force a realistic motion field solution (see Eq. (B.2) ). Eq. (1) is minimized with the well-known NESTA algorithm based on Nesterov’s method [9] . A detailed pseudocode of the MRI reconstruction algorithm can be found in Appendix C . Specifically, Nesterov’s method iteratively minimizes a function fby estimating three sequences x k , y k and z k . The x k sequence corresponds to the sequence we want to estimate ( m i in the Eq. (1) ), and it is obtained from a weighted sum of the other two sequences. Nesterov’s method can be used for the minimization of both smooth and nonsmooth convex functions if using the appropriate smoothing techniques. In [9] , the l1 -norm in Eq. (1) is component-wise approximated by the well-known Huber function f μ(x ) , which depends on a smoothing parameter μ; this parameter is iteratively decreased during the optimization process. The starting guess x 0 is the result of applying the adjoint encoding operator ( E H ) to the subsampled k-space ( x 0 = E H b). 3.2. Parallel implementation Our parallel implementation is coded in OpenCL [4] , and all parallel operations are programmed as OpenCL kernels. In the next two subsections we provide details on the ME/MC stage and the NESTA algorithm. Pseudocode for the latter is included in Appendix C . 3.2.1. Groupwise registration The registration procedure is determined by the values of the parameters θu in Eq. (B.3) . These parameters are obtained by minimizing the metric defined in Eq. (B.2) . In this section we will concentrate on the implementation of the most resource-demanding operation, which turns out to be finding the gradient of Eq. (B.1) . The gradient is, in essence, calculated as follows: ∂ V (x ) ∂θ = ∂ V (x ) ∂m ·∂m ∂ T (x ) ·∂ T (x ) ∂θ (2) where V (x ) is the metric, m represents the image sequence and T (x ) the transformation. Notice that x will be a grid point (with coordinates given as row and column numbers r, 1 ≤r ≤N 1 , and c, 1 ≤c ≤N 2 , respectively). In addition, each parameter θis associated to each of the frames (with index n , 1 ≤n ≤N t ) as well as to each of the control points (with coordinates, say (r u , c u ) ) and each of the directions of variation, namely, horizontal (index l = 1 ) and vertical ( l = 2 ); these indices will be borne in mind for the derivatives. The first factor in equation Eq. (2) can be written: ∂ V (x ) ∂m r,c,n = 2 N t  m (n ) T (n ) (x ) r,c −1 N t N t  n  =1 m (n  ) T (n  ) (x ) r,c  3 E. Martín-González, E. Moya-Sáez, R.-M. Menchón-Lara et al. Computer Methods and Programs in Biomedicine 207 (2021) 106143 Fig. 1. Functional units of the proposed reconstruction system. Gray boxes represent necessary albeit unproductive work, which is taken care of by OpenCLIPER. White boxes represent actual, productive work. Each white box is abstracted as a process , which may be composed of several other processes. U , U H , E , E H are the internal NESTA operators. tTV: temporal Total Variation; GW: Groupwise Registration. with m (n ) (x ) the n th frame in sequence m , evaluated at pixel x , and T (n ) (x ) it the transformed position of pixel x in that phase. m (n ) will be also referred to as the n th frame. This equation is computed in parallel for the N 1 ×N 2 ×N t pixels. The second factor in Eq. (2) is the image gradient with respect to the transformation. The actual operations we perform are the interpolation of the gradient of each frame m (n ) at position T (n ) (x ) . The interpolation is carried out within a region of interest, say χm , so the number of operations launched in parallel is N 1 χm ×N 2 χm ×N t , where the two first factors are the dimensions of region χm . The last factor in Eq. (2) is the gradient of the transformation with respect to the variables θu to be optimized; since these variables enter Eq. (B.3) as factors, their derivative is straightforward and can be precomputed. Hence, the calculation of the gradient of Eq. (2) will be performed parallelizing along the rows and columns affected by the B- splines ( r s and c s ), the frame dimension ( n ), the rows and columns of the control points ( r u and c u ) and the spatial dimension ( l), as can be seen below: ∂ V (x ) ∂θ r s ,c s ,n,r u ,c u ,l = ∂ V (x ) ∂m r s ,c s ,n,l ·∂m ∂ T (x ) r s ,c s ,n,l ·∂ T (x ) ∂θ r s ,c s ,r u ,c u . 3.2.2. NESTA A matrix formalism of data structures and operators (the encoding operator Eand the sparsifying operator U) used in NESTA is presented in Appendix A ; this formalism makes it simple to derive the adjoint operators. However, in practice, high data dimensionality implies that storage of matrices associated with operators is not feasible due to memory requirements. Consequently, operators are implemented by means of functions and the latter have been the focus of our parallelization effort. Specifically, for the encoding operator Ethe following parallelizations were made: 1) Multiplication by the coil sensitivities Sis performed parallelizing along the spatial dimensions (i.e., N 1 ×N 2 operations launched in parallel). 2) The by-frame spatial Fourier transform Fis performed parallelizing along the coils and frames dimensions (i.e., C ×N t parallel operations) using the clFFT [27] library. 3) Application of the undersampling mask A is performed parallelizing along the spatial dimensions (i.e., N 1 ×N 2 parallel operations). Note that in S, the coils and frames dimensions could have also been parallelized; nevertheless, we empirically verified that this did not constitute a performance gain, presumably caused by the limited number of cores in the hardware. As for the adjoint encoding operator E H , the following parallelizations were made: 1) Multiplication by coil conjugate sensitivities S H and, 2) by-frame spatial inverse Fourier transform F H , Both of them were parallelized analogously to their counterparts Sand F, respectively. 3) Summation of the resulting image sequence in each coil is parallelized along the spatial and temporal dimensions (i.e., N 1 ×N 2 ×N t operations launched in parallel). Regarding the sparsifying operator U = T , the temporal total cyclic variation is performed parallelizing along the spatial dimensions (i.e., N 1 ×N 2 operations launched in parallel) and the T  groupwise transformation for MC is performed parallelizing along both the spatial and the frame dimensions (i.e. N 1 χm ×N 2 χm ×N t parallel operations). Similarly, the adjoint sparsifying operator U H is parallelized along the same dimensions as U. Finally, matrix operations needed in NESTA, such as scaling a vector by a constant or addition of two vectors, are performed efficiently by the clBLAST library [28] . Thus, all the algorithm steps (see Appendix C for details) can be straightforwardly computed by combining operators Eand U, their adjoints E H and U H , and a few matrix operations. 3.3. Algorithm implementation on a generic parallel device We have translated the original method into an actual deviceagnostic software solution which (a) finishes in clinically viable times, comparable to other popular reconstruction frameworks, (b) is suitable for execution in parallel devices, and (c) complies with the WORA paradigm (see Section 2 ) so neither code nor data 4 E. Martín-González, E. Moya-Sáez, R.-M. Menchón-Lara et al. Computer Methods and Programs in Biomedicine 207 (2021) 106143 need be duplicated for CPU/GPU or any other device. As stated in Section 1 , we make extensive use of our framework OpenCLIPER to provide this solution. In this section we provide details on this implementation; Fig. 1 shows a diagram of our system functional units that will guide us through the description that follows. 3.3.1. Generalities Together with the core algorithm —enclosed within the dashed rectangle in Fig. 1 and its operations represented by rectangles with white background—, several other tasks must be carried out for the system to be functional by itself. These tasks are not only part of the initialization process but they are also active while the actual processing is taking place. All these administrative tasks (shaded boxes in Fig. 1 ) are dealt with by OpenCLIPER with minimal programmer intervention. While the system is at work, data passes through several transformations (called processes in Open- CLIPER) that need to be connected appropriately. Each process may be seen as a black box with a single input, a single output and an arbitrary set of parameters. This specification allows prospective programmers to interconnect and compose processes arbitrarily, as long as outputs from one are compatible with inputs to the next, since their interfaces must all comply with this specification. An appropriate computing device must be selected (top row in Fig. 1 ). Since OpenCL supports a wide range of them, an additional workload is the need to detect the available platforms and devices (which may be from different vendors), and to choose the most suitable among them. Moreover, once a device has been selected, kernels must be loaded and compiled for the chosen device. Open- CLIPER simplifies these tasks significantly: kernel loading and compiling is done without user intervention when a process demands it, caching them as necessary so time is dedicated to compilation only once per device (and driver version). Platform/device detection and selection may be either specified by the programmer (via hints such as device type, model, supported CL version, etc.) or, alternatively, left to the framework by just a single line of code. In the latter case —or, in the former, whenever the specified hints match several candidate devices—, the a priori fastest device is automatically chosen. All compute-intensive transformations are performed in the computing device, so the system takes full advantage of its parallel capabilities and hence clinically viable execution times may be achieved (see quantification in Section 4 ). The algorithms implemented in OpenCLIPER, which are themselves processes, are made up from several other processes which may be reused at programmer discretion. In this sense, OpenCLIPER provides a pool of frequently used processes as a ready-to-use toolbox; for example, Hadamard matrix multiplication, fast Fourier transform, channel integration, image sum, etc. These tools make the implementation of more involved processes —such as the two described in Section 3.2 —easy. With respect to the four blocks on top of the NESTA Process in Fig. 1 , after the selection of the most appropriate device (either manually or automatically), kernel loading is delayed until a process requires it. At that time, a previously compiled (i.e. cached) version of the kernel is sought. If it does not exist yet, kernel compilation is automatically triggered and the kernel cache is updated (loading of cached kernels is typically two orders of magnitude faster than on-the-fly compilation). Compilation logs (if any) are shown to the user for debugging purposes. 3.3.2. Input and output MRI data loading is done in a single code line with OpenCLIPER by a front-end function (see leftmost side of Fig. 1 ). As of today, k-space lines are input by means of a.clf file (and its accompanying.hdr file); Matlab format file is also allowed. Output formats include the two formats just mentioned as well as other popular image formats (JPEG, PNG, etc). To maximize utilization of the computing device, data objects may be loaded and saved concurrently while the device is busy processing other objects. Since MRI data files are often large, this can save a noticeable amount of processing time per patient. 3.3.3. Data structures A common burden in GPU computing lies in the need to keep track of pointers to data objects and their properties: number of dimensions, sizes and strides along each of them, data types and sizes (complex, float, integer, etc.), and passing them to the computing device. This is typically done by adding arguments to the kernels, but kernel argument space is usually limited by the computing hardware (apart form adding more burden for the user to call their kernels). OpenCLIPER simplifies this burden by encapsulating all data properties within the buffer in the computing device in a way that is transparent to the kernel programmer (i.e. there is no offset between the object pointer and the real data). Thus, users just have to pass a single pointer to the data object to have all its properties readily available for the kernel code. OpenCLIPER provides support for data with an arbitrary number of frames, coils, sensitivity maps, sampling masks and data dimensionality for the special case of MRI data, and arbitrarily complex data for the general case. Our framework also provides methods to traverse data buffers along any given dimension. This functionality is provided by generating index and size tables for each data object, as shown in Fig. 1 . An additional feature of OpenCLIPER is that all sub-objects in a data object (e.g. sensitivity maps for each coil) are mapped contiguously in device memory and properly adjusted to hardware alignment, so kernel programmers can assume a linear layout when processing compound data objects. Data transfers between host and device are driven by the DMA controller to maximize speed. Listing 1 shows a simple OpenCL kernel which sums a set of MR images along the coil dimension. It can be seen how a kernel can access attributes from input and output buffers (such as coil or frame strides, sizes, and so on) just by passing their natural pointer as arguments with no need to worry about header offsets or the like. All attribute access functions are O (1) as long as all ND Listing 1. Accessing attributes of complex data structures. Note how data properties (sizes, strides and number of coils in this particular case) are available from kernel code without passing them explicitly as kernel arguments. 5 E. Martín-González, E. Moya-Sáez, R.-M. Menchón-Lara et al. Computer Methods and Programs in Biomedicine 207 (2021) 106143 arrays in the given object have the same number of dimensions ( O (n ) otherwise). 3.3.4. Additional support for researchers OpenCLIPER has also been designed as a development tool for researchers. Hence, it includes a number of additional utilities, which we now enumerate: 1. 1D, 2D and 3D objects in device memory, either standalone or as a movie, can be graphically presented to the user at any time by a simple call to pointerToObject- > show() method; scaling and video velocity facilities are provided at programmer convenience. OpenCV [29] is currently used to display windows on the desktop. 2. Similarly, any object in device memory can be saved for further inspection in Matlab or any other supported format at any time. 3. When compiling in debug mode, device and host are automatically synchronized in every process so that run-time errors trigger exactly at the responsible kernel, so fault location detection should be immediate. 4. When OpenCL kernels are compiled on the fly (as opposed to loading a previously cached version), errors may show up when the host program is run. If this is the case, kernel compilation errors are automatically shown to the user. 5. In the case of program abortion, the full stack backtrace is shown to the programmer. 6. OpenCLIPER includes facilities to gather profiling data and generate statistical reports as well. 7. A memory map of data objects in device memory may be obtained at any time. 3.3.5. Incorporation of HIP and CUDA functionality As stated in the introduction, HIP [5] is an interesting effort to bridge the gap between GPUs vendors by providing facilities to migrate CUDA code into a reusable form in other platforms. However, handling exchange is still an issue; specifically, data objects defined in one language (HIP/OpenCL) cannot be used as parameters to kernels written in the other language (OpenCL/HIP). We have solved this problem by providing a HIP handle to every OpenCL data object defined through the OpenCLIPER API. This way, developers may invoke calls to HIP libraries on pure OpenCL data objects and, consequently, OpenCLIPER may benefit from libraries written in CUDA for which a HIP implementation is also available. As an example, Listing 2 shows how an OpenCLIPER data object may be passed seamlessly to the rocFFT library [30] and use its result as an OpenCLIPER object again. After initialization (lines 11– 15), a vector of complex numbers is created as an OpenCL memory object (lines 17–20) and its corresponding HIP handle is obtained (line 23). The next code section is pure HIP code in which the obtained handle is used to feed the rocFFT library (lines 25–31) and, finally, the FFT result is saved as a Matlab file (line 34). 4. Evaluation We have executed several reconstructions to test the behaviour of our platform. Reconstructions have been carried out on 7 healthy volunteers courtesy of King’s College London. These data are 2D Cartesian, fully sampled dynamic short axis cine breath-hold ECG-triggered acquisitions in a 1.5 T Philips scanner with a bSSFP sequence. Some relevant parameters of the acquisitions include flip-angle 60 ◦, TR/TE = 3/1.5 ms, spatial resolution 2 ×2 mm 2 , slice thickness 8 mm, 20 cardiac phases, FOV 320 ×320 mm 2 , 12–14 slices and the number of channels is between 19 and 32, depending on the subject. Both sensitivity maps and k-space data from all coils were provided to us. These datasets were retrospectively subsampled with a Gaussian variable-density Listing 2. Passing OpenCLIPER data objects to HIP libraries. random undersampling pattern along the phase encoding direction described in Asif et al. [31] for different values of acceleration factor (AF). Hence, for the experiments carried out we have fully sampled images which have been used as a reference for measuring some quality indices (QIs). First, we have compared our platform with BART [13] to solve Eq. (1) . As for OpenCLIPER we have used NESTA. As for BART, 3 since NESTA is not available in that platform, we have used the ADMM method [32] . As for these comparisons, T in Eq. (1) is the identity due to the fact that BART does not incorporate —to the best of our knowledge— a groupwise ME/MC implementation. Three experiments have been conducted, namely (a) AF = 4 (AF4), (b) AF = 4 plus coil compression (AF4CC) from 19–32 to half of the channels (9–16), and (c) AF = 8 (AF8). The parameter λin Eq. (1) has been chosen to maximize the structural similarity index (SSIM) [33] in the BART reconstruction. Table 1 shows SSIM values for the three experiments. Thus, λ= 0 . 01 has been used for BART and OpenCLIPER reconstructions. For the sake of fairness, since the two optimization algorithms are different, we have chosen the internal NESTA parameters (namely, both μand the stopping criterion, see lines 5 and 12 in Appendix C ) to guarantee that SSIM values are comparable for ADMM and NESTA reconstructions; this is graphically shown in Fig. 2 a, with boxplots of SSIM along all the slices of all the patients. Boxplots have been grouped in pairs, i.e., AF4 for OpenCLIPER and BART, and the same structure goes for 3 Release downloaded on February 25, 2020, from https://github.com/mrirecon/ bart/releases/tag/v0.5.00 6 E. Martín-González, E. Moya-Sáez, R.-M. Menchón-Lara et al. Computer Methods and Programs in Biomedicine 207 (2021) 106143 Fig. 2. Boxplots of SSIM (a), NCC (b), and SER (c) for experiments AF4, AF4CC, and AF8 on both OpenCLIPER which makes use of NESTA, and BART (which uses ADMM). No significant differences have been found. 7 E. Martín-González, E. Moya-Sáez, R.-M. Menchón-Lara et al. Computer Methods and Programs in Biomedicine 207 (2021) 106143 Fig. 3. Example of reconstructions using BART and OpenCLIPER for the experiments AF4, AF8, and AF8 with ME/MC; the latest only for OpenCLIPER. Fully sampled images are shown as reference. End-systole and end-diastole frames are shown in each case, as well as the intensities along time of the vertical profile marked with red line in reference images. Last row shows the error images (mean squared error, MSE, between reference and reconstructed image). (For interpretation of the references to colour in this figure legend, the reader is referred to the web version of this article.) Table 1 Mean SSIM values evaluated on undersampled BART reconstructions for a single slice of all patients and the three experiments (AF4, AF4CC, and AF8). Maximal values (bold highlighted) indicate the optimal regularization weight ( λin Eq. (1) ) for the experiments. Reg. Term AF4 AF4CC AF8 λ= 10 −5 0.8776 0.8923 0.8200 λ= 10 −4 0.8832 0.8979 0.8293 λ= 10 −3 0.9037 0.9201 0.8642 λ= 0 . 01 0.9056 0.9229 0.8719 λ= 0 . 1 0.8955 0.9133 0.8592 λ= 1 0.8951 0.9128 0.8589 AF4CC as well as for AF8, as indicated in the horizontal labelling and in the legends on the figures. For completeness, different QIs have been analyzed. Fig. 2 also includes the corresponding boxplots for the normalized cross correlation (NCC, Fig. 2 b) and the signal to error ratio (SER, Fig. 2 c). Mann Whitney tests, 4 show no significant differences in any of these parameters between the compared frameworks. Additionally, Figs. 3 and 4 show two reconstruction examples for two different patients. In both cases, the fully sampled reconstructed images are shown as reference with the images reconstructed using BART and OpenCLIPER for the experiments AF4 and AF8; for the latter, ME/MC reconstruction is also shown for OpenCLIPER ˙ With these parameter setting, execution times in identical computer load situations have been compared. To deal with variability, each experiment has been run one hundred times for each patient. Four platforms with four different GPUs have been employed. All of them are standard PC-class workstations based on Intel Core 4 Function wilcox.test in RStudio. or AMD Ryzen processors. The exact GPU models are GeForce 2080Ti and Quadro RTX 60 0 0 from nVidia, and Radeon RX 480 and Radeon RX 5700XT from AMD. For reference, some tests have also been carried out using a CPU as the computing device in a 70- thread Intel Xeon server. Notice that BART can only be run on CPU or nVidia GPUs, so no further comparison could be done between AMD and nVidia as for BART performance. Fig. 5 shows boxplots of execution times on the GeForce 2080Ti (a) and RTX60 0 0 (b) for the three experiments, with the same ordering as in Fig. 2 . As for a comparison betweeen nVidia and Radeon, Fig. 6 shows boxplots of the AMD Radeon RX 5700XT (GFX1010) and the nVidia Quadro RTX 60 0 0 in the same conditions as in the previous experiment. In terms of performance, the FFT implementation used by the reconstruction algorithm plays a prominent role. BART uses the nVidia’s well-known proprietary implementation cuFFT, whereas OpenCLIPER uses the AMD’s opensource implementation clFFT. While the former is highly optimized for nVidia GPUs, the latter is conceived to be run on every possible computing device and hence lacks of any specific optimization. This results in clFFT being slower than cuFFT, as shown in Table 2 . OpenCLIPER compensates this with performance enhancements in other areas, such as parallel loading/saving of data and kernel caching (see Section 3.3 ). 5 Fig. 7 shows boxplots of SSIM for AF8 on OpenCLIPER with and without ME/MC; whereas boxplots for NCC and SER are shown in Fig. 8 . Results of the unilateral Mann-Whitney test for SSIM are significant ( p = 0.008) for ME/MC. If a unilateral signed rank test is run per patient, differences favor ME/MC in six out of the seven patients tested. Mann-Whitney tests are also significant for NCC and SER ( p = 0 . 006 and p = 0 . 007 , respectively). The price 5 In our previous work [34] , FFT times reported were overestimated since they incorporated an additional synchronization of the device command queue. 8 E. Martín-González, E. Moya-Sáez, R.-M. Menchón-Lara et al. Computer Methods and Programs in Biomedicine 207 (2021) 106143 Fig. 4. Example of reconstructions using BART and OpenCLIPER for the experiments AF4, AF8, and AF8 with ME/MC; the latest only for OpenCLIPER. Fully sampled images are shown as reference. End-systole and end-diastole frames are shown in each case, as well as the intensities along time of the vertical profile marked with red line in reference images. Last row shows the error images (mean squared error, MSE, between reference and reconstructed image). (For interpretation of the references to colour in this figure legend, the reader is referred to the web version of this article.) Fig. 5. Boxplots for experiments AF4, AF4CC, and AF8 on (a) GeForce 2080Ti and (b) RTX60 0 0. Times reported are per whole slice stack. Fig. 6. Boxplots of computing time for AMD Radeon RX 5700XT (GFX1010) and nVidia Quadro RTX 60 0 0 (RTX60 0 0) for the three experiments. Notice that red-shaded boxes coincide with the red-shaded boxes in Fig. 5 . Times reported are per whole slice stack. (For interpretation of the references to colour in this figure legend, the reader is referred to the web version of this article.) 9