Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
e4aea40
added the optim code
hzarei4 May 30, 2023
7ecba4b
added the general 7 parameters fitting
hzarei4 May 31, 2023
0c828e5
Updated the helpa and examples
hzarei4 Jun 2, 2023
b8b89a5
Merge pull request #1 from hzarei4/developement
hzarei4 Jun 2, 2023
e09916b
Updated the Project and removed the additional dep
hzarei4 Jun 2, 2023
86a1037
Merge pull request #2 from hzarei4/developement
hzarei4 Jun 2, 2023
31636e8
N-dimensional generalization
Jan 25, 2024
77ebdbc
Merge pull request #3 from hzarei4/developement
hzarei4 Jan 25, 2024
0062797
Removing clutters
Jan 25, 2024
c1acf27
cleaning the main code
hzarei4 Feb 26, 2024
db04c00
Merge pull request #4 from hzarei4/developement
hzarei4 Feb 26, 2024
d8e7145
Merge pull request #4 from hzarei4/main
hzarei4 Feb 26, 2024
8ae0a6f
one allocation
RainerHeintzmann Feb 26, 2024
fd56e1c
added random seed and fixed type stability
hzarei4 Feb 27, 2024
c236014
added the function input support
hzarei4 Mar 28, 2024
63f548c
rewrote some bits towards modularity
RainerHeintzmann Apr 3, 2024
09f49bf
cleanup
RainerHeintzmann Apr 3, 2024
82d886c
Tried taylor_test.jl
RainerHeintzmann Apr 3, 2024
9790667
added a test for a multidimensional taylor expansion
RainerHeintzmann Apr 4, 2024
3fcc290
Fixed the speed and allocations, tip: don't assign `Array` type to `itp`
hzarei4 Apr 5, 2024
e19d0bd
Merge branch 'develop' of https://github.com/RainerHeintzmann/DataToF…
hzarei4 Apr 5, 2024
c2338f9
fixed polynomial memory up to order 2
RainerHeintzmann Apr 5, 2024
739bbc9
merged
RainerHeintzmann Apr 5, 2024
5688b45
Merge branch 'develop' of https://github.com/RainerHeintzmann/DataToF…
RainerHeintzmann Apr 5, 2024
5c533d2
adding functional input as `get_function_general`, cleaning `export`s
hzarei4 Apr 5, 2024
f8c69f0
Merge branch 'develop' of https://github.com/RainerHeintzmann/DataToF…
hzarei4 Apr 5, 2024
e94bbcd
working version of non-linear deformations
RainerHeintzmann Apr 5, 2024
60c39f6
Merge branch 'develop' of https://github.com/RainerHeintzmann/DataToF…
RainerHeintzmann Apr 5, 2024
ef19af5
modded
hzarei4 Jul 10, 2024
87f4325
added Github workflow
hzarei4 Jul 10, 2024
3787978
renaming ci.yml
hzarei4 Jul 10, 2024
2a1b764
fixed bug and without creator
RainerHeintzmann Jul 14, 2024
9c2c7f7
finally got it working fast
RainerHeintzmann Jul 14, 2024
22f6789
a bit of cleanup
RainerHeintzmann Jul 14, 2024
8c7ddc7
removed Unrolled
RainerHeintzmann Jul 15, 2024
38cbb83
added a Pluto example notebook + bugfixes
RainerHeintzmann Jul 15, 2024
e738204
example of polynomial IM
hzarei4 Jul 15, 2024
0f1079f
Merge branch 'develop' of https://github.com/RainerHeintzmann/DataToF…
hzarei4 Jul 15, 2024
bd2c5e9
updated ci.yml
hzarei4 Jul 15, 2024
133ca00
removed undefined export
hzarei4 Jul 15, 2024
76b7d14
modified tutorial to the new commits
hzarei4 Jul 15, 2024
85efbbc
updated tutorial
hzarei4 Jul 15, 2024
b8d6c7d
modded ci.yml
hzarei4 Jul 15, 2024
fc8a3f9
added eevbranch
hzarei4 Jul 15, 2024
a6e3615
better Pluto sliders
RainerHeintzmann Jul 15, 2024
47d9a0b
better Pluto example
RainerHeintzmann Jul 15, 2024
6acc73e
Documenter and DocumenterTools
RainerHeintzmann Jul 16, 2024
bc04932
added the @generated tag to allow arbitrary dimensions
RainerHeintzmann Jul 22, 2024
4e117fb
modified to use EvalMultiPoly.jl
hzarei4 Jul 23, 2024
4c041b9
added CUDA functionality and some examples
hzarei4 Oct 30, 2024
0f7f69c
updated Project.toml
RainerHeintzmann Jun 10, 2025
4885978
updated Project.toml, compatible with new ver of Interpolations.jl.
hzarei4 Aug 28, 2025
8878d94
Merge branch 'develop' of https://github.com/RainerHeintzmann/DataToF…
hzarei4 Aug 28, 2025
fe8ddee
added example
RainerHeintzmann Apr 29, 2026
9d2e868
updated the CI to pass the tests
hzarei4 Apr 29, 2026
0956279
Fix CI workflow
hzarei4 Aug 18, 2026
f608125
Fix documentation CI dependencies
hzarei4 Aug 18, 2026
6915c7f
Require Julia 1.10
hzarei4 Aug 18, 2026
99252c7
Add missing dependency compat bounds
hzarei4 Aug 18, 2026
16f3bbb
Temporarily disable documentation CI
hzarei4 Aug 18, 2026
c097265
Improve transformation performance, AD support, CUDA compatibility, a…
hzarei4 Aug 24, 2026
9ee3e00
Enable documentation deployment
hzarei4 Aug 24, 2026
7a605c8
updated readme
hzarei4 Aug 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
97 changes: 97 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: CI

on:
pull_request:
branches:
- main
- develop
push:
branches:
- main
- develop
tags: '*'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
version:
- '1.10'
os:
- ubuntu-latest
arch:
- x64

steps:
- uses: actions/checkout@v6

- uses: julia-actions/setup-julia@v3
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}

- uses: julia-actions/cache@v2

- name: Add unregistered dependencies
run: |
julia --project=. -e '
using Pkg
Pkg.develop(PackageSpec(
url="https://github.com/rainerheintzmann/EvalMultiPoly.jl"
))
Pkg.instantiate()
'

- uses: julia-actions/julia-buildpkg@v1

- uses: julia-actions/julia-runtest@v1

- uses: julia-actions/julia-processcoverage@v1

- uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
file: lcov.info

docs:
name: Documentation
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- uses: actions/checkout@v6

- uses: julia-actions/setup-julia@v3
with:
version: '1.10'

- uses: julia-actions/cache@v2

- name: Install documentation dependencies
run: |
julia --project=docs -e '
using Pkg
Pkg.develop([
PackageSpec(
url="https://github.com/rainerheintzmann/EvalMultiPoly.jl"
),
PackageSpec(path=pwd())
])
Pkg.instantiate()
'

- name: Build and deploy documentation
uses: julia-actions/julia-docdeploy@releases/v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,19 @@ docs/site/
# committed for packages, but should be committed for applications that require a static
# environment.
Manifest.toml
examples/Manifest.toml
examples/*.tiff
examples/image_registration_2dpolim.jl

*.mp4
*.png
examples/figures/*
examples/*.tif
examples/*.ipynb
*.jpeg
*.gif
*.jpg
*.txt
*.txt
.*tiff
examples/6-4-Rigis.jl
32 changes: 31 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,38 @@
name = "DataToFunctions"
uuid = "64cfdffa-4d02-49ee-ae8b-a805370874f5"
authors = ["RainerHeintzmann <heintzmann@gmail.com>"]
version = "0.1.0"
authors = ["RainerHeintzmann <heintzmann@gmail.com>"]

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
EvalMultiPoly = "c78649ec-f9ed-405e-be6d-0472f43586aa"
FourierTools = "b18b359b-aebc-45ac-a139-9c0ccbb2871e"
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"

[compat]
Adapt = "4.7.0"
Aqua = "0.8"
BenchmarkTools = "1"
CUDA = "6"
ChainRulesCore = "1.26.1"
EvalMultiPoly = "0.1"
ForwardDiff = "1"
FourierTools = "0.4, 0.5"
Interpolations = "0.15.1, 0.16"
StaticArrays = "1.9.6, 1.10"
Test = "1.9.3"
Zygote = "0.6, 0.7"
julia = "1"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[targets]
test = ["Aqua", "Test", "Zygote", "BenchmarkTools", "ForwardDiff", "CUDA"]
90 changes: 89 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,90 @@
# DataToFunctions.jl
Represents (measured) data as a function, which supports scaling and shifting. It is intended to be used as a tool for fitting data, where the fitting function is given by measured data.

[![CI](https://github.com/RainerHeintzmann/DataToFunctions.jl/actions/workflows/ci.yml/badge.svg)](https://github.com/RainerHeintzmann/DataToFunctions.jl/actions/workflows/ci.yml)
[![Development Documentation](https://img.shields.io/badge/docs-dev-blue.svg)](https://rainerheintzmann.github.io/DataToFunctions.jl/dev/)

`DataToFunctions.jl` represents data as continuously evaluated, parameterized functions.

The package is intended for fitting, image registration, and inverse problems
where measured data itself forms part of the model. It provides efficient
interpolation-based coordinate transformations with support for affine,
polynomial, and user-defined transformations.

## Features

- Affine transformations in arbitrary dimensions using homogeneous coordinates;
- A convenient seven-parameter affine model for 2-D data;
- Polynomial coordinate transformations based on
[`EvalMultiPoly.jl`](https://github.com/RainerHeintzmann/EvalMultiPoly.jl);
- User-defined Cartesian and homogeneous-coordinate transformations;
- Allocation-free in-place CPU evaluation for performance-critical workflows;
- Automatic differentiation of affine and polynomial transformation parameters;
- Custom `ChainRulesCore` reverse rules for efficient Zygote gradients;
- Compatibility with gradient-based optimization such as `Optim.jl` with
`LBFGS`;
- Backend-generic execution, including CUDA arrays for supported interpolation
methods.

## Quick example

```julia
using DataToFunctions

data = rand(Float32, 128, 128)

f = get_function_affine(data)

p = (
0.2f0, # x shift
-0.1f0, # y shift
1.0f0, # x scale
1.0f0, # y scale
0.0f0, # xy shear
0.0f0, # yx shear
0.01f0, # rotation [rad]
)

warped = f(p)
```

For repeated forward evaluations, an in-place version is available:

```julia
f! = get_function_affine_inplace(data)

out = similar(data)
f!(out, p)
```

On CPU, the in-place transformation path is designed to run without heap
allocations after compilation when using concrete tuple parameters and a
preallocated output array.

## Automatic differentiation

The affine and polynomial transformation interfaces provide custom reverse-mode
rules for differentiation with respect to transformation parameters.

For example:

```julia
using Zygote

target = f(p)

loss(q) = sum(abs2, f(q) .- target)

gradient = Zygote.gradient(loss, p)[1]
```

These gradients can be used directly in optimization workflows.

## Documentation

- [Development documentation](https://rainerheintzmann.github.io/DataToFunctions.jl/dev/)

The development documentation follows the `develop` branch.

<!-- Stable documentation can be added after the first tagged release at:

- `https://rainerheintzmann.github.io/DataToFunctions.jl/stable/` -->
11 changes: 11 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[deps]
DataToFunctions = "64cfdffa-4d02-49ee-ae8b-a805370874f5"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
DocumenterTools = "35a29f4d-8980-5a13-9543-d66fff28ecb8"
EvalMultiPoly = "c78649ec-f9ed-405e-be6d-0472f43586aa"
GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
SyntheticObjects = "e7028c27-0967-45e9-8fdb-dbc10ccb2b0a"
23 changes: 23 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import Pkg
Pkg.activate(@__DIR__)

cd(@__DIR__) # go into `docs` folder

using Documenter, Literate, DataToFunctions

# convert tutorial/examples to markdown
# Literate.markdown("./src/tutorial.jl", "./src")
# Which markdown files to compile to HTML
# (which is also the sidebar and the table
# of contents for your documentation)

pages = Any[
"Introduction" => "index.md",
"Tutorial" => "tutorial.md",
"API" => "api.md",
]

# compile to HTML:
makedocs(; sitename="DataToFunctions.jl", pages, modules = [DataToFunctions], checkdocs = :exports)

deploydocs(repo = "github.com/RainerHeintzmann/DataToFunctions.jl.git", devbranch = "develop")
42 changes: 42 additions & 0 deletions docs/src/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# API Reference

This page lists the public transformation interface provided by
`DataToFunctions.jl`.

## Affine transformations

```@docs
DataToFunctions.get_function_affine
DataToFunctions.get_function_affine_inplace
```

## Polynomial transformations

```@docs
DataToFunctions.get_function_poly
DataToFunctions.get_function_poly_inplace
```

## User-defined transformations

```@docs
DataToFunctions.get_function_tuple
DataToFunctions.get_function_tuple_inplace
DataToFunctions.get_function_homogen
DataToFunctions.get_function_homogen_inplace
```

## Mode-based interface

```@docs
DataToFunctions.get_interpolated_function
```

## Transformation modes

If `AffineMode` and `PolynomialMode` have docstrings, they can be included here:

```@docs
DataToFunctions.AffineMode
DataToFunctions.PolynomialMode
```
Loading
Loading