Manuscript Offprint
arXiv:2609.30955Flow-TAG: Flow-based conditional latent transport for accurate spline approximation and data compression
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
ABSTRACT
Robust curve fitting is essential in computer-aided design for transforming noisy, discrete data into accurate geometric models that ensure numerical stability across engineering workflows. B-spline models have become the industry standard for this task, offering a flexible and reliable framework characterized by local control and smooth shape representation. This paper presents flow-TAG—a data-driven framework based on a generative flow model with a 1D U-Net backbone capable of mapping the geometry of a curve to the optimal parametrization for cubic B-splines. By leveraging learned geometric patterns, flow-TAG exhibits superior parameterization performance, robustness to noise in the input data, and strong generalization capability to previously unseen 2D and 3D curves drawn from distinct data distributions. Flow-TAG yields fitted curves that achieve the lower root-mean-square error (55% lower on average) and Hausdorff distance (52% lower on average) relative to state-of-the-art data-driven methods. In addition, we investigate the practical applicability of our generative framework in the compression of ECG signals for wearable devices. The proposed compression setup provides a compression ratio of 13 with the signal distortion of , which is acceptable in the field.
Keywords Curve fitting · B-spline approximation optimization · flow matching · generative models · latent transport · ECG compression
1 Introduction
Robust curve fitting is crucial in Computer-Aided Design (CAD) as it underpins the creation of geometric models essential for design and manufacturing [1]. Curves are typically derived from discrete data which can suffer from noise and irregular sampling. Effective curve fitting is necessary to accurately represent shapes, ensuring smoothness and numerical stability. However, it can be noted that poor fitting can introduce errors and undermine design intent. This reliability is vital for applications in surface modeling [2], tool path generation ([3, 4]), and finite element analysis [5], making robust curve fitting methods essential for efficient engineering workflows.
Spline-based models have become a standard tool for curve approximation in CAD due to their flexibility, numerical stability, and strong theoretical foundation [2]. Among them, B-splines are particularly prominent because they provide a compact representation with desirable properties such as local support, smoothness control, and affine invariance [6]. A B-spline curve is defined by a set of control points, a polynomial degree, and a non-decreasing knot vector, which together determine the shape of the curve. The parametrization of the curve—i.e., the assignment of parameter values to data points—plays a crucial role in the quality of approximation, as it influences how the basis functions are evaluated and how geometric features are distributed along the curve. Common parametrization strategies include uniform, chord-length, and centripetal methods, each offering different trade-offs between simplicity and fidelity to the underlying geometry [7]. The combination of flexible parametrization and the inherent locality of B-spline basis functions makes spline-based approaches particularly well-suited for approximating complex shapes encountered in real-world design tasks.
Flow-TAG: Flow-based conditional latent transport for accurate spline approximation and data compression
In recent years, data-driven approaches have been increasingly explored to improve curve parametrization for B-spline fitting, addressing limitations of classical heuristic methods such as uniform or chord-length parametrization ([8, 9]). Machine learning techniques, particularly neural networks, enable the estimation of parameter values directly from data by learning underlying geometric patterns and noise characteristics [10]. These methods aim to produce parametrizations that lead to improved approximation accuracy and robustness, especially for complex or highly irregular curves. A dedicated Section 3.1 later in the manuscript provides a detailed discussion of the principal contributions on neural parametrization for B-spline fitting; therefore, we do not elaborate further on this topic at this point.
Within the scope of the stated problem, the aim of this study is to develop a data-driven framework capable of mapping the geometry of a curve to the optimal positions of spline knots by leveraging learned geometric patterns. In such a model, the knot vector serves as a latent representation of the curve being approximated.
We demonstrate how, using a generative flow-based model with a 1D U-Net backbone, it is possible to learn the geometry of 2D and 3D curves and map it into a knot vector. Ultimately, we introduce flow-TAG: flow-based Task-Aware Generative framework for conditional latent transport for accurate spline approximation. The framework combines several original design solutions, including: 1) redefining the B-spline functional via a 1D U-Net deep learning model; 2) training with the self-tuning multi-task geometry-informed loss function, which combines both the flow matching term and the curve fidelity term (task loss). As a result, flow-TAG exhibits superior parameterization performance (the resulting knot vectors produce the highest-quality spline approximation among all evaluated baseline methods), robustness to noise in the input data, and strong generalization capability to previously unseen curves drawn from distinct data distributions.
In addition to evaluating the intrinsic accuracy of the approximations of abstract curves, we also investigate the practical applicability of flow-TAG to real medical data that can be represented by splines. Specifically, we employ flow-TAG as the backbone to perform compression of ECG recordings [11]. The results of our tests clearly demonstrate the potential of using flow-TAG in the compression of ECG signals for wearable devices.
The body of the paper consists of the following parts: Section 2 includes the rigorous problem statement; Section 3 outlines the baselines of the data-driven neural B-spline curve fitting and curve compression methods; Section 4 provides the theoretical underpinning of the proposed framework, description of the dataset used in the study, and essential notes on the experiments; Section 5 contains the experimental outcomes and their discussion; lastly, in Section 6, we analyze the impact of the study, discuss the limitations of flow-TAG, and potential future research interests in this regard. The paper is accompanied by Appendices that provide additional methodological and implementation details for interested readers.
where are ordered parameter values and are the corresponding observations of a d-dimensional signal. The goal is to construct a smooth function that accurately represents the underlying curve while maintaining a compact and flexible representation.
A widely used representation for such tasks is the B-spline curve [2]. Given a non-decreasing knot vector
and a spline degree p, the B-spline basis functions are defined recursively using the Cox–de Boor formula [12]:
A B-spline curve of degree p is then expressed as
where are the control points, and the number of basis functions is determined by the knot vector length via .
Flow-TAG: Flow-based conditional latent transport for accurate spline approximation and data compression
B-splines were originally constructed as convolutions of certain probability distributions and later used for statistical data smoothing [2]. This is remarkable because B-spline basis functions exhibit a structural resemblance to point spread functions (PSF) in optics and kernels in kernel density estimation (KDE). Just as a PSF describes the spatial distribution of a point source's energy due to system blur, or a KDE kernel distributes the probabilistic "weight" of a discrete data point, the B-spline basis function serves as a localized weighting operator that distributes the influence of a control point across a specific interval. Mathematically, this relationship is rooted in the fact that a B-spline of order (p is degree) can be derived from the -fold convolution of a rectangular pulse (the boxcar function), a process that mirrors the repeated filtering operations used to model optical blur or to derive higher-order smoothing kernels ([12, 13]). Consequently, B-spline interpolation can be interpreted as a generalized filtering process where the continuous signal is reconstructed by "smearing" discrete coefficients through a basis that satisfies the partition of unity, ensuring both local support and global smoothness, making B-spline curves, Eq. 5, a powerful tool to model complex shapes.
The curve modeling can be carried out as an approximation or an interpolation process. In the presented study, both frameworks were utilized. In the spline interpolation problem, the constructed curve is required to pass exactly through the given data points:
Substituting the B-spline representation yields a linear system
or in matrix form
where is the basis matrix, contains the unknown control points, contains the observed samples. If the number of basis functions equals the number of samples, , the system (8) can be solved directly. Interpolating splines provide exact reconstruction of the observed data but may become sensitive to noise or irregular sampling.
In many practical applications the number of control points is intentionally chosen to be smaller than the number of samples, . In this case, the spline does not interpolate the data exactly but approximates it by minimizing a fitting error. A common formulation is the least-squares problem:
in matrix form:
the solution is given by
Approximation B-splines provide a compact representation of the curve and naturally smooth noisy observations.
The knot vector K determines the support and shape of the B-spline basis functions and therefore strongly influences the quality of the curve representation. For a fixed spline degree p and number of control points, the choice of knot locations defines the approximation space
However, the knots are in general not given, which poses the problem of finding an optimal knot placement scheme for a given curve. Uniform knot placement is often used due to its simplicity, but it may fail to capture local variations of the curve, particularly in regions with high curvature or rapid changes. Conversely, adaptive placement of knots allows more flexible modeling by allocating more basis functions in complex regions and fewer in smooth segments.
Formally, the optimal knot placement problem can be formulated as
subject to the monotonicity constraint on the knot vector
Flow-TAG: Flow-based conditional latent transport for accurate spline approximation and data compression
Moreover, in the present study, we imposed natural boundary conditions at the extremities of the knot vector, which effectively means the second derivatives at the ends are set to zero.
The problem given by Eq. (13) is nonlinear and combinatorial because the basis functions themselves depend on the knot locations. Consequently, determining an optimal knot configuration is a challenging task and often relies on heuristic strategies, iterative refinement, or data-driven approaches. A brief survey of approaches for adaptive knot placement for B-spline curve approximation can be found in Section 3.1.
Efficient spline modeling therefore requires addressing two coupled tasks: estimating the spline coefficients for a given knot configuration and determining an appropriate placement of knots that yields an accurate yet compact representation of the underlying curve.
3 Related work
In this section, we provide an overview of several notable previously published works related to the optimization of spline curve approximation using machine learning, as well as studies on curve compression algorithms.
3.1 Learning-based methods for spline curve approximation
Addressing optimal parameter and knot estimation in B-spline curve fitting, Laube et al. [14] proposed a data-driven framework called PARNET, utilizing deep neural networks instead of traditional heuristics. PARNET features two architectures: a Point Parametrization Network (PPN) for assigning parametric values, and a Knot Selection Network (KSN) for predicting knot vector distribution. This approach allows simultaneous prediction of parameters and knots based on point set geometry, incorporating a least-squares control point solution into the network's loss function for reduced approximation error. Results show PARNET achieves tighter fits with fewer control points and lower computational overhead during inference. However, challenges include scalability and generalization, as training on synthetic data limits robustness against real-world noise distributions.
Unlike PARNET, which used fixed-size global inputs, Scholz et al. [15] employ a Residual Neural Network (ResNet) to process a small, fixed window of points necessary for unique polynomial approximations. This approach allows the model to generalize to arbitrary-length point sequences and minimize approximation error, effectively capturing non-linear relationships and outperforming traditional methods. However, it faces challenges like vulnerability to high-frequency noise and requires retraining for different polynomial degrees, relying on pre-ordered inputs. Increasing the number of layers and knots may be required for approximating complex curves in practical applications.
Wen et al. [16] in their paper introduced a DNN-Solver for B-spline approximation. In their framework, a Deep Neural Network (DNN) was used as a means of mapping knot positioning from a random allocation to a suboptimal space given the curve data points. The input can be any initial fixed knots, and the output provides the desirable knots. This constitutes a relatively straightforward, predominantly optimization-based rather than learning-based approach. However, its generalizability property necessitates a computationally expensive iterative optimization procedure, which precludes the application of DNN-Solver to real-time curve-fitting scenarios.
With the emergence and widespread adoption of transformer-based deep neural network architectures in recent years, which have achieved state-of-the-art performance across a broad range of tasks, their application to the B-spline curve approximation problem became a natural development. An example of such an approach is presented in the work of Saillot et al. [17]. Trained with supervised learning on randomly generated B-spline curves, their method is designed to directly output the knot vector. Another generative transformer-based approach called SplineGen was introduced in the paper of Zou et al. [18]. It addresses challenges both in parameterization and knot placement in B-spline approximations. Its key features include independence from input data point size, permutation invariance, aligned knots and parameters, and robustness, leading to highly accurate curve fittings. The limitations of SplineGen include failing in scenarios involving point disorder and lack of explicit mechanisms for constraining approximation errors or ensuring a minimal number of knots.
3.2 Curve compression techniques
There are diverse techniques that can be used to achieve compression of curves. Among such examples we can find spline curve fitting techniques. For example, previous work [19] proposed an heuristic algorithm for compressing the 3D shape of medical guidewires based on the natural cubic spline approximation with an optimized knot placement procedure given a geometry prior. This approach demonstrated robustness in the efficient representation of complex, high-resolution medical shape measurements. Nevertheless, due to its reliance on an optimization-based procedure,
Flow-TAG: Flow-based conditional latent transport for accurate spline approximation and data compression
the majority of the compression time is devoted to determining an optimal knot placement, which scales poorly with problem size and consequently induces a trade-off between real-time performance and achievable compression ratio.
Another example of curve fitting compression has been used for accurate B-spline fitting and compression of ECG [20]. The referred method employs stochastic ant colony optimization to find optimal knot locations along the ECG segments. Analogously to the previously discussed approach, this method depends on a computationally intensive optimization procedure, which constrains its suitability for real-time applications. Furthermore, the method may exhibit limited robustness in the presence of noisy recordings [20].
Transform-based compression techniques filter insignificant components out by enforcing sparsity in the transform domain. Analogously to image compression, Bilgin et al. [21] demonstrated how JPEG2000 codec can be applied to effectively compress and denoise ECG recordings. However, the method introduces significant distortion to the signal after decompression. Another strong baseline based on the combination of the coalition of empirical mode decomposition and Tunable-Q Wavelet Transform (TQWT) was developed by Sharma et al. [22]. The method benefits from packing the maximum energy with fewer wavelet coefficients, which have a significant contribution to the original signal, and dynamic thresholding and dead-zone quantization to discard the insignificant wavelet coefficients. Subsequently, a run-length encoding lossless compression scheme was employed to encode the retained wavelet coefficients. The strengths in impressive compression rate with moderate distortions attributed to this algorithm come with the following limitations: EMD-based approaches suffer from high computational complexity and the mode mixing problem ([23, 24]), while TQWT requires careful manual parameter tuning that reduces generalizability ([25, 26]). More broadly, these pipelines are typically evaluated on a single, limited database, lack end-to-end optimization, and may discard clinically significant signal features through aggressive thresholding.
Yildirim et al. [27] have presented a pioneering work that uses Convolutional AutoEncoders (CAE) for ECG compression. The encoder in their model consists of 14 layers, and the compression is achieved via dimensionality reduction at the bottleneck as compared to the original signal space. Their method achieves better average compression ratio relative to the traditional methods; however, the ratio is statically predefined and tightly coupled to the model architecture. Regardless of the impressive compression ratio, the method of Yildirim et al. [27] reconstructs the signal with noticeable distortions higher than those of traditional methods and varies from signal to signal. The recent development of the concept of CAE for ECG compression was presented in the study of Bekiryazici et al. [28], where they reported a multichannel CAE-based model. The proposed approach encodes the ECG signal into a four-channel low-dimensional space with increasing levels of sparsity constraints imposed on each channel. Different quantization levels are then applied to each channel with subsequent entropy encoding. Their method demonstrated the capability to efficiently compress ECG signals while maintaining reconstruction accuracy.
4 Methods
This section exposes the methodology underlying the numerical experiments, including the architecture and configuration of the neural networks, the characteristics and preparation of the datasets, and all additional implementation details required to ensure a comprehensive understanding of the study and to facilitate full reproducibility of the reported results.
4.1 Deep neural network to substitute the spline approximation
Given the problem (9) and the smoothness penalty
imposed by the natural boundary conditions applied to the endpoints and , the spline approximation can be regarded as a smoothing low-dimensional representation ( is a smoothing parameter). The penalty given by Eq. (15) actually reflects the minimum property of cubic splines with natural boundary conditions, which have intuitive physical interpretation: the spline model mimics the behavior of a thin, flexible elastic beam, minimizing bending energy [2]. Therefore, the objective of such a smoothing spline functional becomes:
which is also known as a variational formulation of spline fitting [29].
We define the functional f from Eq. (16) by a neural network parametrized by . Such a network learns a mapping
Flow-TAG: Flow-based conditional latent transport for accurate spline approximation and data compression
Curve autoencoder

(a)
Task model
Knot gen. model

(b)
(c)
Figure 1: Diagrams of the 1D U-Net-based neural networks used in the study: (a) autoencoder D for curve denoising and multiscale feature extraction; (b) task model mimicking B-spline approximation; (c) flow-based soft knot-mask generative model .
where
Therefore, a network trained to minimize loss, which includes the objective given by Eq. (16), is encouraged to produce curves that both match the observed samples and have small curvature matching the curvature of the observed samples. In other words, the network is learning a function that approximates the solution of a smoothing spline problem, and therefore can be interpreted as a learned nonlinear and differentiable generalization of spline smoothing with curvature regularization. Having established the mathematical rationale for moving from the B-spline approximation to a more general neural network model , we will now define the principal architecture of such a network.
A natural architectural choice for this problem is a one-dimensional U-Net-based autoencoder, since several aspects of its structure align well with the theory of spline approximation and smoothing. U-Nets are particularly suitable for inpainting and denoising tasks because they are explicitly designed for context-aware reconstruction of signals or images ([30, 31]), which makes them a good fit for reconstructing curves from sparse samples (as formulated by Eq. (17)). A central component of U-Net is the system of skip connections between encoder and decoder layers (see Figure 1 (a)), which enables the decoder to merge local high-resolution details (fine structure) with global contextual information (shape constraints). This is especially beneficial for curve reconstruction: the network can preserve the exact values of observed samples while filling in unobserved regions using global context. In this way, skip connections help maintain local geometric constraints, analogous to how spline bases provide local support around knots. In addition, U-Net handles noisy input data effectively, allowing the mapping function to adapt to the data distribution and remain robust to noise. For these reasons, U-Net serves as the primary architecture in this work; its integration into the flow-based generative framework is described in the next subsection.
4.2 Task-aware flow-based generative modeling
This section outlines the essential aspects of the proposed flow-based Task-Aware Generative (flow-TAG) framework for conditional latent transport (knot vector). We first describe the origin of this framework and its applications. Next, we present the adaptation for curve approximation and discuss the multi-task geometry-aware loss.
4.2.1 Conventional Flow Matching and its coupling with a downstream task
As a distribution-matching approach, Flow Matching (FM) learns a time-dependent vector field within a neural ODE
Flow-TAG: Flow-based conditional latent transport for accurate spline approximation and data compression
Conventional Flow Matching
Flow-TAG Framework

(a)

(b)
Figure 2: Workflows of the (a) conventional flow matching set-up and (b) proposed flow-based framework for generating latent for a task .
that deterministically maps samples from the standard Gaussian distribution (noise) to the target distribution (see Figure 2 (a)) ([32, 33]). The training objective of a FM model is to minimize the regression loss between the learned velocity field and the ground-truth velocity , which specifies the true trajectory of each point as it evolves from to :
where is typically expressed through the linear coupling assumption between and . Thus, at a time step , the path is defined as
where and . As the formulation Eq. (22) defines a straight line, each pair has a constant ground-truth velocity along the path .
Let us consider a setting in which the ground-truth distribution is not directly accessible and only an empirical or approximated estimate can be obtained. At the same time, we posit the hypothesis that the true distribution either coincides with the estimated one or is contained within the family of distributions represented by :
or overlaps with it:
Given that the samples from both distributions are latent representations for some function (in our case, it is the spline approximant , Section 4.1, and the target distribution would be then the space of possible knot positions), can be estimated indirectly via the predictions of the model . Therefore, the flow prediction (Eq.20) becomes a latent representation of the task . Once both the flow and the task networks are differentiable, learning the transformation dynamics becomes an end-to-end optimization problem driven by the downstream loss :
Figure 2 (b) shows a diagram of this generative framework. The time-dependent weighting in Eq. (20) effectively functions as an implicit regularizer: at early times , the flow emphasizes coarse, broadly data- and task-independent structure, whereas at later times it encodes task-specific refinements. The B-spline approximant fixes the terminal state of the flow within a meaningful objective space, thereby acting as a prior.
Flow-TAG: Flow-based conditional latent transport for accurate spline approximation and data compression
4.2.2 Multi-task loss with uncertainty-based weighting
The training objective of flow-TAG was to minimize the following loss function:
which consists of three separate loss terms and optimizable weights . The idea of optimizing the coefficients of the terms that make up the loss function was proposed in the work of Kendall et al. [34]. This approach makes it possible to balance the model training process on complex composite tasks such as ours by learning the relative weight of each task adaptively. As increases, the weight of the corresponding objective decreases, and vice versa. Weights are discouraged from increasing too much by the last logarithmic term in Eq. (26) in order to avoid the risk of ignoring a certain objective. Therefore, becomes effectively “self-tuning”. We now analyze each individual objective appearing in Eq. (26).
As mentioned in Section 4.2.1, Eq. (21), the first term of the total loss is responsible for the overall consistency of the generated latent representations with the estimated ground truth distribution (flow , Figure 2 (b)). To evaluate this term, it is both necessary and sufficient to possess an approximate characterization of the latent distribution. Let this pseudo-ground truth be represented by the function . In our work, we instantiate using the knot-placement algorithm introduced by Yeh et al. [35]. The authors proposed a heuristic procedure, which can be concisely summarized as follows:
-
Calculate the derivatives of the input data.
-
Calculate a feature curve for the input data.
-
Determine the knot vector using the feature curve.
However, the algorithm of Yeh et al. [35] only works in the absence of noise in the data. In the opposite case, its performance becomes unstable. This limitation, however, does not pose an issue in our setting, because the function is employed exclusively during the training phase of flow-TAG, during which a denoising U-Net model is concurrently utilized (see Figure 1 (a)).
Fine-tuning of the learned latent distribution is carried out by means of the task loss function - Geometry-informed reconstruction loss . The first term minimizes the average reconstruction error
whereas the second term penalizes the error of the second spatial derivative of the reconstructed curve to match that of the original curve y
In this formulation of the task loss, we enforce equivalence between the learning objective and objective (16). This alignment justifies the assertion that the soft masks produced by flow-TAG reside in a latent space that is optimal for B-spline approximation, which follows as well from the ablation study given in B.
4.2.3 Differentiable sigmoid gate
The generative flow model outputs a velocity field that transports the noise-distributed latent variables to the corresponding optimal latent distribution. However, the ground truth subsampling masks belong to binary space, Eq. (18), which poses the fundamental limitation on backpropagation through step-like functions while training the model. To circumvent the non-differential nature of discrete sampling, the latent output from undergoes the following sigmoid transformation:
where is the sigmoid function, is the percentile threshold for soft-selection of the top entities in , is the heuristically defined time-dependent non-linear steepness function, is the time step.
The output of Eq. (29) represents a soft, differentiable mask for the task: elements of above the chosen percentile receive values close to 1, while elements below are smoothly suppressed toward 0 (see the red output soft mask in Figure 1 (c)). The steepness function enhances the sigmoid transformation as the time step approaches 1 (hard thresholding), whereas times below 0.8 normally result in soft thresholding. The gated output is then passed to . At the inference, the top-M selection is applied directly to the generated latent . The differentiable given in Eq. (29) is analogous to the Differentiable Top-K Operator from the paper of [36].
Flow-TAG: Flow-based conditional latent transport for accurate spline approximation and data compression
Algorithm 1 Conditional latent transport for accurate spline approximation with flow-TAG
Require: Original curve , denoising autoencoder , flow model , ODE time grid , -time step, number of knots ,
1: // get conditioning features
2: Sample
3: Get soft mask logits: // solve conditional flow ODE
4: // keep largest elements, set others to 0
5: // get knot indices
6: Fit cubic B-spline:
7: Reconstruct curve:
8: return Reconstructed curves , selected knots
4.2.4 Flow-TAG overview
The overall framework comprises three 1D U-Net-based networks that share an identical architecture, as illustrated in Figure 1. The input signal (a 2D or 3D curve) is fed to the denoising autoencoder , which extracts the multiscale noise-robust features (4 levels of depth + bottleneck). These features are then passed to guide the flow model , which generates knot placement logits. The task model is used only at the training stage of the flow model. A detailed description of the model architectures and training process is provided in A. The inference workflow of flow-TAG is summarized in Algorithm 1.
4.3 Datasets
In this work, three datasets were used. The training, validation, and test sets used in this article were carried out on the public SplineGen dataset by Zou et al. [18]. In addition, the assessment of flow-TAG's performance in clinically relevant settings was conducted on the public electrocardiogram (ECG) MIT-BIH Arrhythmia dataset ([11]), which is a popular benchmark in the ECG data compression community.
SpineGen dataset This set consists of more than 1M non-self-intersecting B-spline-generated 2D and 3D curves. All curves were scaled and rotated to keep the pair of control points with the largest distance in the diagonal of the space ([0, 1] , d is the dimension). The curves are flipped to avoid memorizing a positional bias. As knots and control points are provided within this dataset, all curves were resampled to be of the same length of 100 points. For our experiments, the dataset is split into train, validation, and test subsets. Examples of 2D and 3D curves from the SplineGen dataset are displayed in Figure 3.
MIT-BIH Arrhythmia Database The database has been curated by the Massachusetts Institute of Technology and Beth Israel Hospital ([11]). This dataset serves as a foundational benchmark for the development and validation of automated arrhythmia detection systems and compression algorithms for wearable devices. The database comprises 48 half-hour excerpts of two-channel (leads) ambulatory ECG recordings, obtained from 47 subjects studied between 1975 and 1979. The recordings have been digitized at a sampling rate of 360 Hz per channel with 11-bit resolution over a 10 mV range.
The acquired ECG signal comprises multiple noise and artifact components, including baseline drift, power-line interference, and high-frequency noise, all of which degrade signal quality and consequently impair the effectiveness of compression algorithms. To mitigate their impact, the ECG signals underwent the following preprocessing steps prior to being input into flow-TAG. As important clinical information in ECG signals generally lies in the frequency range of 1 – 150 Hz, each ECG record was first passed through a 4th-order Butterworth filter with a bandwidth of 1 – 150 Hz. Next, a band-stop notch filter with a center frequency of 50 Hz was applied to eliminate the noise originating from the power line. After the filtering, recordings were segmented into patches of 100 points followed by the mean-centered min–max normalization. Figure 4 shows 3 examples of filtered and normalized ECG signal frames. After preprocessing, ECG signal can be regarded as 2D curves and, therefore, processed by flow-TAG and approximated by the spline-fitting model.
4.4 Metrics
Given the input curves y with N points and their B-spline approximation made with the flow-generated knots, we evaluated the performance of flow-TAG with the following most commonly used metrics: Root Mean-Squared
Flow-TAG: Flow-based conditional latent transport for accurate spline approximation and data compression

Figure 3: Exemplary 2D and 3D curves from the SplineGen dataset.

Figure 4: Exemplary 2-lead beats extracted from MIT-BIH Arrhythmia Database.
Error (RMSE) (Eq. (30)) and Hausdorff distance (Eq. (31)).
RMSE estimates the overall quality of the fit, and Hausdorff distance measures the dissimilarity between two curves by determining the maximum distance from any point in one curve to the nearest point in the other, and vice versa.
Next, in Section 5.3, when analyzing the quality of ECG signal approximation for compression, we evaluated the Compression Ratio (CR) and the metrics that are more specific to the medical community of ECG signal processing [37]. These metrics include Normalized Percent Root Difference (PRDN) and Quality Score (QS). Their definitions are:
Flow-TAG: Flow-based conditional latent transport for accurate spline approximation and data compression

Figure 5: Training evolution of the weights of the flow-TAG training objective.
PRDN is a quantitative metric that characterizes the deviation of a compressed signal from its original counterpart in percentage terms and is employed to assess the magnitude of reconstruction error introduced by the compression process. PRDN below a defined threshold is crucial for assessing whether a signal is suitable for clinical interpretation. Values between 0% and 2% reflect excellent compression. Prior work has shown that PRDN values under 9% preserve all clinically relevant features with adequate signal quality [37, 28]. In contrast, PRDN values above 9% indicate that the reconstructed signal may lose critical information and thus be unsuitable for diagnostic use. QS evaluates the performance of ECG signal compression algorithms by jointly quantifying the achieved compression ratio and the magnitude of post-compression signal distortion. This metric emphasizes that methods attaining a high degree of data reduction while maintaining a low reconstruction error are regarded as exhibiting superior compression performance.
5 Results and discussions
In this section, we present and analyze the results of numerical experiments: flow-TAG training dynamics, the quality of curve approximation with generated knots, and the performance of flow-TAG as compression algorithm for ECG.
5.1 Training details
We now examine the evolution of the weighting coefficients associated with the terms of the total loss function in Eq. (26), as illustrated in Figure 5. At the initial stage of training, all three weights decrease at approximately the same rate. After roughly 10,000 iterations, however, the update of slows down and, following a short adaptation phase, it stabilizes at a value of approximately 0.48. In contrast, and continue to decrease up to about 40,000 iterations, reaching values of 0.02 and 0.03, respectively.
Concurrently, the coefficients multiplying the and terms increase as an inverse quadratic function of , such that their contribution to the overall loss becomes dominant relative to the FM term. Consequently, the model progressively reduces its reliance on the pseudo-ground truth and instead focuses on learning more informative latent representations that are better tailored to the target task.
5.2 Curve reconstruction
We now turn to assessing the suitability of the knot placements produced by our method for B-spline curve interpolation. To this end, we refer to Table 6, which reports the results of 2D B-spline interpolation obtained by flow-TAG, alongside several baseline algorithms for comparison.
Our method achieves the lowest RMSE and Haus. dist. on the test dataset for 9–15 knots. The closest competitor, DNN-Solver, being an optimizing iterative solver, produces better results the longer the optimization runs, and eventually outperforms flow-TAG for 5–8 knots. However, such optimization takes incomparably more time than generating knots.
Flow-TAG: Flow-based conditional latent transport for accurate spline approximation and data compression
Fidelity Metrics for 2D Curves

Figure 6: 2D curve reconstruction results on the SplineGen dataset; RMSE (left) and Hausdorff distance (right) plotted across different numbers of knots.

Figure 7: Examples of B-spline 2D curve approximations with knots outputted by flow-TAG (upper row) and uncertainty map for the corresponding curves estimated across 10 generations (lower row).
with flow-TAG. We report the results for SplineGen with the important caveat that the corresponding performance metrics are taken directly from the original publications. We did not independently reproduce these experiments, as the implementation of SplineGen was not publicly available in open-access form. In terms of Haus. dist., our method yields to SplineGen at 11 knots. This is an intriguing result, considering that RMSE usually correlates with Haus. dist., while the RMSE of SplineGen turns out to be an order of magnitude higher than that of our method.
Figure 7 shows three examples from the 2D curve test set together with B-spline interpolations based on the knots generated by flow-TAG. One can observe that the model tends to place knots in regions with higher curvature. However, unlike typical heuristic algorithms, it does not always position a knot exactly at the point of maximum curvature. Nevertheless, the interpolation quality does not suffer. The lower row of plots in Figure 7 displays the uncertainty maps for each curve. The values were calculated as the standard deviation of the soft masks averaged across 10 independent generations. The integrated uncertainty estimation capability constitutes a key strength of the proposed framework, as it provides quantitative insight into the model's confidence when approximating a target curve. In particular, Figure 7 illustrates that the model exhibits heterogeneous uncertainty regarding the placement of individual knots, with some knots being associated with substantially higher uncertainty than others. Moreover, distinct regions of low uncertainty are clearly discernible; these regions were systematically avoided during the knot placement process.
Flow-TAG: Flow-based conditional latent transport for accurate spline approximation and data compression
Fidelity Metrics for 3D Curves

Figure 8: 3D curve reconstruction results on the SplineGen dataset; RMSE (left) and Hausdorff distance (right) plotted across different numbers of knots.



Figure 9: Examples of B-spline 3D curve approximations with knots outputted by flow-TAG.
On the test 3D SplineGen set (see Figure 8), our method achieves the best interpolation quality both in terms of RMSE and Haus. dist. values for 10–15 knots, as compared to the baselines. For fewer knots, flow-TAG outputs suboptimal placements associated with higher error values. We do not report the results for SplineGen evaluation on 3D curves, since they were not provided in the original works. For visual inspection of the interpolation, we present B-spline interpolation of 3 random 3D curves in Figure 9.
5.3 Curve compression
We now examine the direct integration of flow-TAG within an ECG compression framework. To this end, we have trained the flow-TAG components on the training subset of MIT-BIH Arrhythmia database. Next, we developed a simple lossy compression scheme, whose procedural pipeline can be concisely summarized as follows:
-
ECG encoding by flow-TAG → signal values at knot and knot locations.
-
Encoding the binary knot placement mask bitstream.
-
Non-linear quantization of the values at the knots (Lloyd's algorithm) followed by the entropy encoding (Huffman codes) → bitstream.
Table 1 shows that the proposed setup provides a compression ratio of 13 with acceptable signal distortion below 9% (the referred result was obtained for 30 internal knots retained per patch and 30 nonlinear quantization levels). When comparing the efficiency with several established baseline methods (see Table 1), it becomes evident that the proposed approach achieves a moderate level of compression, outperforming, for instance, the method reported in the paper of [20]. Analysis of the quality scores indicates that the proposed algorithm outperforms the ECG-adapted JPEG2000, CAE from the study of [27], and the recent multichannel CAE of Bekiryazici et al. [28]. These results clearly demonstrate the fundamental viability of flow-TAG for ECG compression. Examples of an ECG signal reconstructed after compression by flow-TAG are shown in Figure 9. The model allocates knots in the regions corresponding to the characteristic waves, yielding a robust latent representation of the ECG signal.
Flow-TAG: Flow-based conditional latent transport for accurate spline approximation and data compression
Table 1: Comparison of the ECG compression performance of the flow-TAG-based algorithm with different baselines.
| Method | PRDN, % | Comp. ratio | QS |
|---|---|---|---|
| Mohebbian et al. [20]* | 2.3 | 7.8 | 3.39 |
| Bekiryazici et al. [22] | 8.21 | 33.11 | 4.03 |
| Bekiryazici et al. [28] | 9.85 | 20.23 | 2.05 |
| JPEG2000 | 16.76 | 19.48 | 1.16 |
| Yildirim et al. [27] | 31.17 | 32.25 | 1.03 |
| Ours | 5.13 | 13 | 2.55 |
- – unnormalized PRD value from the original paper

Figure 10: Examples of B-spline ECG approximations with knots outputted by flow- TAG.
6 Conclusion
This paper proposes flow-TAG framework: a generative flow model based on 1D U-Net for generating the parametrization (knot vectors) for cubic B-spline curve approximation. The framework integrates several novel design components, specifically: 1) a redefinition of the B-spline functional through a 1D U-Net deep learning architecture; and 2) a training strategy based on a self-tuning, multi-task, geometry-informed loss function that jointly incorporates the flow matching component and a curve-fidelity component. The resulting generative framework has demonstrated its effectiveness in approximating 2D and 3D curves (public SplineGen dataset) and its advantage over baselines that optimize spline parameterization. In addition, we investigated the prospects of the utilization of flow-TAG as an ECG signal encoder for a compression algorithm. The outcomes of these tests were encouraging and indicate favorable preliminary results.
As an experimental framework, flow-TAG exhibits certain limitations. A primary constraint arises from its patch-wise operation: curves are partitioned into segments of 100 points, for which the corresponding knots are generated. While this strategy can be practical, it may prove suboptimal in specific scenarios. Conversely, the global strategy—processing the entire curve in a single pass—introduces additional constraints on the generative neural network architecture. In principle, however, flow-TAG can be implemented under both regimes.
Flow-TAG exhibits numerous potential applications in computer-aided design. Among these, we anticipate that particularly promising directions include the generation of latent representations for streaming data and the design of advanced algorithms for ECG signal compression.
A U-Net design and training details
As mentioned in Section 5.1, the models that constitute flow-TAG framework share a common architecture, summarized in Table 2. U-Net depth was set to 4, which is sufficient to cover the receptive field of curves with points. Channel or 3 for and , for 2D or 3D curves, respectively; in , . The architecture of the flow model has certain distinctions, such as multiscale features and time conditioning. The summary of it is given in Table 3.
and were trained using the geometry-informed loss (27)-(28), was trained with the multitask learning objective (26) with uncertainty-based loss weighting. The model ingests 2D/3D curves corrupted with additive Gaussian
Flow-TAG: Flow-based conditional latent transport for accurate spline approximation and data compression
Table 2: 1D U-Net architecture used for the denoising autoencoder and task model .
| Level | Main ops | Ch. in out | Len. |
|---|---|---|---|
| Input | - | ||
| E1 | |||
| E2 | |||
| E3 | |||
| E4 | |||
| Bottleneck | |||
| D1 | UpConv+Skip+DConv | ||
| D2 | UpConv+Skip+DConv | ||
| D3 | UpConv+Skip+DConv | ||
| D4 | UpConv+Skip+DConv | ||
| Output |
; right-padding is used for odd-length skip mismatches.
Table 3: 1D U-Net architecture used for the flow model .
| Level | Main ops | Ch. in out | Len. |
|---|---|---|---|
| Input | — | ||
| TimeEmb | — | ||
| E1 | |||
| E2 | |||
| E3 | |||
| E4 | |||
| Bottleneck | |||
| D1 | UpConv+Cat+DConv | ||
| D2 | UpConv+Cat+DConv | ||
| D3 | UpConv+Cat+DConv | ||
| D4 | UpConv+Cat+DConv | ||
| Output |
Flow-TAG: Flow-based conditional latent transport for accurate spline approximation and data compression
Table 4: Performance of trained with the different objectives.
| Loss component | RMSE, a.u. | Haus. Dist., a.u. |
|---|---|---|
| 0.010632 | 0.041932 | |
| 0.009503 | 0.037222 | |
| 0.010928 | 0.034751 |
Table 5: Performance of trained with the different objectives.
| Loss component | RMSE, a.u. | Haus. Dist., a.u. |
|---|---|---|
| 0.006007 | 0.025700 | |
| 0.011002 | 0.039807 | |
| 0.005056 | 0.022596 |
noise and aims to reconstruct the noiseless originals. The training spans 20 epochs with batch () sampling from the SplineGen training set, using the Adam optimizer [38] with learning rate . Training of flow-TAG framework is summarized in Algorithm 2.
Algorithm 2 Training of the conditional 1D U-Net flow model
Require: Training curves , frozen pretrained denoising autoencoder and task model , noise level 1: for iter = 1 to epochs do 2: Sample training batch: 3: Add input noise: , 4: Get conditioning features: , 5: Get knot count: // single per batch 6: Sample , 7: Get GT knot mask estimation: // algorithm of Yeh et al. [35] 8: Define linear FM path and target velocity: , 9: Predict flow velocity and mask logits: 10: Evaluate the percentile thresholds: 11: Get the soft masks: 12: Apply soft sampling: 13: Reconstruct with pretrained task model: 14: Compute the loss and update parameters: 15: end for 16: return Trained model
B Ablation study on the training objective of and
In the Table 4 and 5 we report the denoising and the flow models' performance after being trained for 10,000 iterations with different combinations of the total training loss, Eq. (26).
References
[1] Helmut Pottmann, Stefan Leopoldseder, Michael Hofer, Tibor Steiner, and Wenping Wang. Industrial geometry: recent advances and applications in CAD. Computer-Aided Design, 37(7):751–766, 2005.
[2] Gerald Farin. Curves and surfaces for CAGD: a practical guide. Elsevier, 2001.
[3] Jean Marie Langeron, Emmanuel Duc, Claire Lartigue, and Pierre Bourdet. A new format for 5-axis tool path computation, using Bspline curves. Computer-Aided Design, 36(12):1219–1229, 2004.
[4] Ali Lasemi, Deyi Xue, and Peihua Gu. Recent development in CNC machining of freeform surfaces: A state-of-the-art review. Computer-Aided Design, 42(7):641–654, 2010.
Flow-TAG: Flow-based conditional latent transport for accurate spline approximation and data compression
[5] Thomas JR Hughes, John A Cottrell, and Yuri Bazilevs. Isogeometric analysis: CAD, finite elements, NURBS, exact geometry and mesh refinement. Computer methods in applied mechanics and engineering, 194(39-41):4135–4195, 2005.
[6] Hartmut Prautzsch, Wolfgang Boehm, and Marco Paluszny. Bézier and B-spline techniques, volume 6. Springer, 2002.
[7] Les Piegl and Wayne Tiller. The NURBS book. Springer Science & Business Media, 2012.
[8] Pascal Laube, Matthias O Franz, and Georg Umlauf. Learnt knot placement in B-spline curve approximation using support vector machines. Computer Aided Geometric Design, 62:104–116, 2018.
[9] Tianyu Song, Tong Shen, Linlin Ge, and Jieqing Feng. A Hybrid Parametrization Method for B-Spline Curve Interpolation via Supervised Learning. volume 43, page e15240. Wiley Online Library, 2024.
[10] Yann LeCun, Yoshua Bengio, and Geoffrey Hinton. Deep learning. nature, 521(7553):436–444, 2015.
[11] George B Moody and Roger G Mark. The impact of the MIT-BIH arrhythmia database. IEEE engineering in medicine and biology magazine, 20(3):45–50, 2001.
[12] Carl De Boor. A practical guide to splines, volume 27. Springer New York, 1978.
[13] Michael Unser. Splines: A perfect fit for signal and image processing. IEEE Signal processing magazine, 16(6):22–38, 2002.
[14] Pascal Laube, Matthias O Franz, and Georg Umlauf. Deep learning parametrization for B-spline curve approximation. pages 691–699. IEEE, 2018.
[15] Felix Scholz and Bert Juettler. Parameterization for polynomial curve approximation via residual deep neural networks. Computer Aided Geometric Design, 85:101977, 2021.
[16] Zepeng Wen, Jiaqi Luo, and Hongmei Kang. The deep neural network solver for B-spline approximation. Computer-Aided Design, 169:103668, 2024.
[17] Mathis Saillot, Dominique Michel, and Ahmed Zidna. B-spline curve approximation with transformer neural networks. Mathematics and Computers in Simulation, 223:275–287, 2024.
[18] Qiang Zou, Lizhen Zhu, Jiayu Wu, and Zhijie Yang. SplineGen: Approximating unorganized points through generative AI. Computer-Aided Design, 178:103809, 2025.
[19] Roman Pavelkin, Luis A Zavala-Mondragon, Ahmet Ekin, and Fons van der Sommen. Spline-Based Shape Compression for Interventional Device Tracking. pages 179–192. Springer, 2025.
[20] Mohammad Reza Mohebbian and Khan A Wahid. ECG compression using optimized B-spline. Multimedia Tools and Applications, 82(14):21071–21083, 2023.
[21] Ali Bilgin, Michael W Marcellin, and Maria I Altbach. Compression of electrocardiogram signals using JPEG 2000. IEEE Transactions on Consumer Electronics, 49(4):833–840, 2003.
[22] Neenu Sharma and Ramesh Kumar Sunkaria. ECG compression based on empirical mode decomposition and tunable-Q wavelet transform with validation using heartbeat classification. Signal, Image and Video Processing, 18(4):3079–3095, 2024.
[23] Kang-Ming Chang. Arrhythmia ECG noise reduction by ensemble empirical mode decomposition. Sensors, 10(6):6063–6080, 2010.
[24] Yang Xu, Mingzhang Luo, Tao Li, and Gangbing Song. ECG signal de-noising and baseline wander correction based on CEEMDAN and wavelet threshold. Sensors, 17(12):2754, 2017.
[25] Paridhi Singhai, Anil Kumar, A Ateek, Irshad Ahmad Ansari, Girish Kumar Singh, and Heung No Lee. ECG signal compression based on optimization of wavelet parameters and threshold levels using evolutionary techniques. Circuits, Systems, and Signal Processing, 42(6):3509–3537, 2023.
[26] Hardev Singh Pal, A Kumar, Amit Vishwakarma, and Heung-No Lee. Electrocardiogram signal compression using adaptive tunable-Q wavelet transform and modified dead-zone quantizer. ISA transactions, 142:335–346, 2023.
[27] Ozal Yildirim, Ru San Tan, and U Rajendra Acharya. An efficient compression of ECG signals using deep convolutional autoencoders. Cognitive Systems Research, 52:198–211, 2018.
[28] Tahir Bekiryazici, Mehmet Damkaci, Gürkan Aydemir, and Hakan Gürkan. A novel multichannel sparse convolutional autoencoder for electrocardiogram signal compression. Journal of Electrocardiology, page 154125, 2025.
[29] Paddy M Prenter. Splines and variational methods. Courier Corporation, 2008.
Flow-TAG: Flow-based conditional latent transport for accurate spline approximation and data compression
[30] Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-net: Convolutional networks for biomedical image segmentation. pages 234–241. Springer, 2015.
[31] Christopher Williams, Fabian Falck, George Deligiannidis, Chris C Holmes, Arnaud Doucet, and Saifuddin Syed. A unified framework for U-Net design and analysis. Advances in Neural Information Processing Systems, 36:27745–27782, 2023.
[32] Chieh-Hsin Lai, Yang Song, Dongjun Kim, Yuki Mitsufuji, and Stefano Ermon. The Principles of Diffusion Models. 2025.
[33] Yaron Lipman, Ricky TQ Chen, Heli Ben-Hamu, Maximilian Nickel, and Matt Le. Flow matching for generative modeling. arXiv preprint arXiv:2210.02747, 2022.
[34] Alex Kendall, Yarin Gal, and Roberto Cipolla. Multi-task learning using uncertainty to weigh losses for scene geometry and semantics. pages 7482–7491, 2018.
[35] Raine Yeh, Youssef SG Nashed, Tom Peterka, and Xavier Tricoche. Fast automatic knot placement method for accurate B-spline curve fitting. Computer-aided design, 128:102905, 2020.
[36] Yanjie Zhu, Zhen Zhang, Yunli Wang, Zhiqiang Wang, Yu Li, Rufan Zhou, Shiyang Wen, Peng Jiang, Chenhao Lin, and Jian Yang. Differentiable Fast Top-K Selection for Large-Scale Recommendation. arXiv preprint arXiv:2510.11472, 2025.
[37] Yaniv Zigel, Arnon Cohen, and Amos Katz. The weighted diagnostic distortion (WDD) measure for ECG signal compression. IEEE transactions on biomedical engineering, 47(11):1422–1430, 2002.
[38] Diederik P Kingma. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.