LDDMM: how to do regression?#

[1]:
from pathlib import Path

import herbrain.lddmm as lddmm
import herbrain.lddmm.strings as lddmm_strings

import polpo.preprocessing.pd as ppd
from polpo.preprocessing import (
    BranchingPipeline,
    IndexMap,
    IndexSelector,
    Map,
    NestingSwapper,
    PartiallyInitializedStep,
)
from polpo.preprocessing.dict import (
    DictFilter,
    DictMap,
    DictMerger,
    DictToTuplesList,
    Hash,
)
from polpo.preprocessing.load.pregnancy import (
    FigsharePregnancyDataLoader,
    PregnancyPilotSegmentationsLoader,
)
from polpo.preprocessing.mesh.conversion import PvFromData
from polpo.preprocessing.mesh.filter import PvSelectColor
from polpo.preprocessing.mesh.io import PvWriter
from polpo.preprocessing.mesh.registration import PvAlign
from polpo.preprocessing.mesh.smoothing import PvSmoothTaubin
from polpo.preprocessing.mesh.transform import MeshCenterer
from polpo.preprocessing.mri import (
    BRAINSTRUCT2COLOR,
    MeshExtractorFromSegmentedImage,
    MriImageLoader,
)
No CUDA runtime is found, using CUDA_HOME='/usr'
[2]:
T_MIN = 1.0
T_MAX = 25.0

TEMPLATE_SESSION = 3
TARGET_SESSION = 14

STRUCT_NAME = "PostHipp"

OUTPUTS_DIR = Path("results") / "regression"

INITIAL_REGISTRATION_DIR = OUTPUTS_DIR / "initial_registration"

OUTPUTS_DIR.mkdir(exist_ok=False)

# If not None, uses already computed points (assumes consistency)
CTRL_POINTS_FILE = (
    Path("results") / "registration" / "initial_registration" / lddmm_strings.cp_str
)

Load predictor#

Following How to load a csv file? and doing preprocessing:

[3]:
loader = FigsharePregnancyDataLoader(
    data_dir="~/.herbrain/data/pregnancy",
    remote_path="28Baby_Hormones.csv",
    use_cache=True,
)

prep_pipe = (
    ppd.UpdateColumnValues(
        column_name="sessionID", func=lambda entry: int(entry.split("-")[1])
    )
    + ppd.IndexSetter(key="sessionID", drop=True)
    + ppd.ColumnsSelector("gestWeek")
    + ppd.SeriesToDict()
    + DictFilter(lambda value: T_MIN <= value <= T_MAX)
)

predictor = (loader + ppd.CsvReader() + prep_pipe)()

predictor
INFO: Data has already been downloaded... using cached file ('/home/luisfpereira/.herbrain/data/pregnancy/28Baby_Hormones.csv').
[3]:
{3: 1.0,
 4: 1.5,
 5: 2.0,
 6: 3.0,
 7: 9.0,
 8: 12.0,
 9: 14.0,
 10: 15.0,
 11: 17.0,
 12: 19.0,
 13: 22.0,
 14: 24.0}

Load meshes#

Following data loading of LDDMM: how to register a mesh against a template?.

[5]:
files_pipe = PregnancyPilotSegmentationsLoader(
    predictor.keys(),
    as_dict=True,
)


mri2mesh = MriImageLoader() + MeshExtractorFromSegmentedImage() + PvFromData()

if STRUCT_NAME == -1:
    struct_selector = lambda x: x

else:
    struct_selector = PvSelectColor(
        color=BRAINSTRUCT2COLOR[STRUCT_NAME],
        extract_surface=True,
    )

pipe = files_pipe + DictMap(mri2mesh + struct_selector)
[6]:
meshes = pipe()

meshes.keys()
INFO: Data has already been downloaded... using cached file ('/home/luisfpereira/.herbrain/data/pregnancy/Segmentations').
[6]:
dict_keys([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])

Preprocessing meshes#

Following preprocessing of LDDMM: how to register a mesh against a template?, we center, smooth, and rigid align the meshes against the template.

[7]:
# TODO: consider decimation if above a given number of points

prep_pipe = DictMap(
    MeshCenterer() + PvSmoothTaubin(n_iter=20)
) + PartiallyInitializedStep(
    Step=lambda **kwargs: DictMap(PvAlign(**kwargs)),
    _target=lambda x: x[TEMPLATE_SESSION],
    max_iterations=10,
)
[8]:
meshes = prep_pipe(meshes)

Save meshes in vtk format (as required by deformetrica).

[10]:
meshes_writer = Map(PvWriter(dirname=OUTPUTS_DIR, ext="vtk"))

write_pipe = DictToTuplesList() + BranchingPipeline(
    [
        Map(IndexSelector(0)),
        Map(
            [
                lambda datum: list(datum),
                IndexMap(index=0, step=lambda session: f"mesh_{str(session).zfill(2)}"),
                PvWriter(dirname=OUTPUTS_DIR, ext="vtk"),
            ]
        ),
    ],
    merger=NestingSwapper() + Hash(),
)

mesh_filenames_dict = write_pipe(meshes)

We can now create the dataset:

[11]:
(times, mesh_filenames) = (DictMerger() + NestingSwapper())(
    [predictor, mesh_filenames_dict]
)

And we also normalize time:

[12]:
# TODO: do it in a sklearn style
min_time = min(times)
maxmindiff_time = max(times) - min_time

times = [(time_ - min_time) / maxmindiff_time for time_ in times]
[13]:
# TODO: just to make it run, needs improvement
mesh_filenames = [{"shape": filename} for filename in mesh_filenames]

LDDMM#

Step 1: find control points#

Follows LDDMM: how to register a mesh against a template?.

[14]:
# TODO: need to adapt registration parameters to substructure
registration_kwargs = dict(
    kernel_width=4.0,
    regularisation=1.0,
    max_iter=2000,
    freeze_control_points=False,
    attachment_kernel_width=2.0,
    metric="varifold",
    tol=1e-16,
    filter_cp=True,
    threshold=0.75,
)

if CTRL_POINTS_FILE is not None:
    initial_control_points = CTRL_POINTS_FILE
else:
    lddmm.registration(
        mesh_filenames[TEMPLATE_SESSION],
        mesh_filenames[TARGET_SESSION],
        output_dir=INITIAL_REGISTRATION_DIR,
        **registration_kwargs,
    )
    initial_control_points = INITIAL_REGISTRATION_DIR / lddmm_strings.cp_str

Step 2: perform regression#

[15]:
spline_kwargs = dict(
    initial_step_size=100,
    regularisation=1.0,
    freeze_external_forces=True,
    freeze_control_points=True,
)

kwargs = registration_kwargs.copy()
kwargs.update(spline_kwargs)

target_weights = [1 / len(times)] * len(times)


lddmm.spline_regression(
    source=mesh_filenames[0]["shape"],
    targets=mesh_filenames,
    output_dir=OUTPUTS_DIR,
    times=times,
    subject_id=[""],
    t0=min(times),
    target_weights=target_weights,
    initial_control_points=initial_control_points,
    **kwargs,
)
Logger has been set to: DEBUG
OMP_NUM_THREADS was not found in environment variables. An automatic value will be set.
OMP_NUM_THREADS will be set to 10
>> Initial t0 set by the user to 0.00 ; note that the mean visit age is 0.46
context has already been set
>> No specified state-file. By default, Deformetrica state will by saved in file: results/regression/deformetrica-state.p.
instantiating kernel torch with kernel_width 4.0 and gpu_mode GpuMode.KERNEL. addr: 0x7d265fde2f10
instantiating kernel torch with kernel_width 2.0 and gpu_mode GpuMode.KERNEL. addr: 0x7d265fdc8ad0
>> Reading 110 initial control points from file results/registration/initial_registration/DeterministicAtlas__EstimatedParameters__ControlPoints.txt.
>> Momenta initialized to zero.
dtype=float32
>> Started estimator: ScipyOptimize

>> Scipy optimization method: L-BFGS-B

------------------------------------- Iteration: 1 -------------------------------------

------------------------------------- Iteration: 20 -------------------------------------
>> Log-likelihood = -1.441E+03     [ attachment = -1.198E+03 ; regularity = -2.425E+02 ]
>> Log-likelihood = -1.435E+03     [ attachment = -1.194E+03 ; regularity = -2.409E+02 ]

------------------------------------- Iteration: 40 -------------------------------------
>> Log-likelihood = -1.396E+03     [ attachment = -1.160E+03 ; regularity = -2.363E+02 ]

------------------------------------- Iteration: 60 -------------------------------------
>> Log-likelihood = -1.388E+03     [ attachment = -1.151E+03 ; regularity = -2.376E+02 ]
>> Log-likelihood = -1.388E+03     [ attachment = -1.149E+03 ; regularity = -2.382E+02 ]

------------------------------------- Iteration: 80 -------------------------------------
>> Log-likelihood = -1.383E+03     [ attachment = -1.144E+03 ; regularity = -2.392E+02 ]

------------------------------------- Iteration: 100 -------------------------------------
>> Log-likelihood = -1.381E+03     [ attachment = -1.144E+03 ; regularity = -2.375E+02 ]

------------------------------------- Iteration: 120 -------------------------------------
>> Log-likelihood = -1.379E+03     [ attachment = -1.140E+03 ; regularity = -2.391E+02 ]

------------------------------------- Iteration: 140 -------------------------------------
>> Log-likelihood = -1.378E+03     [ attachment = -1.138E+03 ; regularity = -2.398E+02 ]

------------------------------------- Iteration: 160 -------------------------------------
>> Log-likelihood = -1.376E+03     [ attachment = -1.136E+03 ; regularity = -2.404E+02 ]

------------------------------------- Iteration: 180 -------------------------------------
>> Log-likelihood = -1.375E+03     [ attachment = -1.135E+03 ; regularity = -2.402E+02 ]

------------------------------------- Iteration: 200 -------------------------------------
>> Log-likelihood = -1.375E+03     [ attachment = -1.134E+03 ; regularity = -2.409E+02 ]

------------------------------------- Iteration: 220 -------------------------------------
>> Log-likelihood = -1.374E+03     [ attachment = -1.133E+03 ; regularity = -2.411E+02 ]
>> Log-likelihood = -1.374E+03     [ attachment = -1.133E+03 ; regularity = -2.413E+02 ]

------------------------------------- Iteration: 240 -------------------------------------
>> Log-likelihood = -1.373E+03     [ attachment = -1.132E+03 ; regularity = -2.411E+02 ]

------------------------------------- Iteration: 260 -------------------------------------
>> Log-likelihood = -1.373E+03     [ attachment = -1.130E+03 ; regularity = -2.428E+02 ]
>> Log-likelihood = -1.373E+03     [ attachment = -1.130E+03 ; regularity = -2.426E+02 ]

------------------------------------- Iteration: 280 -------------------------------------
>> Log-likelihood = -1.372E+03     [ attachment = -1.130E+03 ; regularity = -2.424E+02 ]

------------------------------------- Iteration: 300 -------------------------------------
>> Log-likelihood = -1.371E+03     [ attachment = -1.128E+03 ; regularity = -2.437E+02 ]

------------------------------------- Iteration: 320 -------------------------------------
>> Log-likelihood = -1.371E+03     [ attachment = -1.127E+03 ; regularity = -2.434E+02 ]

------------------------------------- Iteration: 340 -------------------------------------
>> Log-likelihood = -1.370E+03     [ attachment = -1.125E+03 ; regularity = -2.445E+02 ]

------------------------------------- Iteration: 360 -------------------------------------
>> Log-likelihood = -1.369E+03     [ attachment = -1.123E+03 ; regularity = -2.461E+02 ]

------------------------------------- Iteration: 380 -------------------------------------
>> Log-likelihood = -1.368E+03     [ attachment = -1.122E+03 ; regularity = -2.461E+02 ]
>> Log-likelihood = -1.368E+03     [ attachment = -1.122E+03 ; regularity = -2.461E+02 ]

------------------------------------- Iteration: 400 -------------------------------------
>> Log-likelihood = -1.367E+03     [ attachment = -1.119E+03 ; regularity = -2.474E+02 ]

------------------------------------- Iteration: 420 -------------------------------------
>> Log-likelihood = -1.366E+03     [ attachment = -1.118E+03 ; regularity = -2.474E+02 ]

------------------------------------- Iteration: 440 -------------------------------------
>> Log-likelihood = -1.365E+03     [ attachment = -1.119E+03 ; regularity = -2.461E+02 ]

------------------------------------- Iteration: 460 -------------------------------------
>> Log-likelihood = -1.364E+03     [ attachment = -1.118E+03 ; regularity = -2.461E+02 ]

------------------------------------- Iteration: 480 -------------------------------------
>> Log-likelihood = -1.364E+03     [ attachment = -1.119E+03 ; regularity = -2.450E+02 ]

------------------------------------- Iteration: 500 -------------------------------------
>> Log-likelihood = -1.363E+03     [ attachment = -1.118E+03 ; regularity = -2.450E+02 ]

------------------------------------- Iteration: 520 -------------------------------------
>> Log-likelihood = -1.363E+03     [ attachment = -1.117E+03 ; regularity = -2.456E+02 ]

------------------------------------- Iteration: 540 -------------------------------------
>> Log-likelihood = -1.362E+03     [ attachment = -1.117E+03 ; regularity = -2.451E+02 ]

------------------------------------- Iteration: 560 -------------------------------------
>> Log-likelihood = -1.362E+03     [ attachment = -1.117E+03 ; regularity = -2.449E+02 ]

------------------------------------- Iteration: 580 -------------------------------------
>> Log-likelihood = -1.362E+03     [ attachment = -1.117E+03 ; regularity = -2.446E+02 ]

------------------------------------- Iteration: 600 -------------------------------------
>> Log-likelihood = -1.362E+03     [ attachment = -1.117E+03 ; regularity = -2.445E+02 ]

------------------------------------- Iteration: 620 -------------------------------------
>> Log-likelihood = -1.361E+03     [ attachment = -1.117E+03 ; regularity = -2.445E+02 ]
>> Log-likelihood = -1.361E+03     [ attachment = -1.117E+03 ; regularity = -2.445E+02 ]

------------------------------------- Iteration: 640 -------------------------------------
>> Log-likelihood = -1.361E+03     [ attachment = -1.116E+03 ; regularity = -2.446E+02 ]

------------------------------------- Iteration: 660 -------------------------------------
>> Log-likelihood = -1.361E+03     [ attachment = -1.117E+03 ; regularity = -2.438E+02 ]

------------------------------------- Iteration: 680 -------------------------------------
>> Log-likelihood = -1.361E+03     [ attachment = -1.117E+03 ; regularity = -2.438E+02 ]

------------------------------------- Iteration: 700 -------------------------------------
>> Log-likelihood = -1.360E+03     [ attachment = -1.117E+03 ; regularity = -2.436E+02 ]

------------------------------------- Iteration: 720 -------------------------------------
>> Log-likelihood = -1.360E+03     [ attachment = -1.117E+03 ; regularity = -2.431E+02 ]

------------------------------------- Iteration: 740 -------------------------------------
>> Log-likelihood = -1.360E+03     [ attachment = -1.117E+03 ; regularity = -2.429E+02 ]

------------------------------------- Iteration: 760 -------------------------------------
>> Log-likelihood = -1.360E+03     [ attachment = -1.118E+03 ; regularity = -2.423E+02 ]

------------------------------------- Iteration: 780 -------------------------------------
>> Log-likelihood = -1.360E+03     [ attachment = -1.118E+03 ; regularity = -2.421E+02 ]

------------------------------------- Iteration: 800 -------------------------------------
>> Log-likelihood = -1.360E+03     [ attachment = -1.119E+03 ; regularity = -2.411E+02 ]

------------------------------------- Iteration: 820 -------------------------------------
>> Log-likelihood = -1.360E+03     [ attachment = -1.119E+03 ; regularity = -2.407E+02 ]

------------------------------------- Iteration: 840 -------------------------------------
>> Log-likelihood = -1.359E+03     [ attachment = -1.119E+03 ; regularity = -2.404E+02 ]

------------------------------------- Iteration: 860 -------------------------------------
>> Log-likelihood = -1.359E+03     [ attachment = -1.120E+03 ; regularity = -2.396E+02 ]

------------------------------------- Iteration: 880 -------------------------------------
>> Log-likelihood = -1.359E+03     [ attachment = -1.120E+03 ; regularity = -2.393E+02 ]

------------------------------------- Iteration: 900 -------------------------------------
>> Log-likelihood = -1.359E+03     [ attachment = -1.120E+03 ; regularity = -2.389E+02 ]

------------------------------------- Iteration: 920 -------------------------------------
>> Log-likelihood = -1.359E+03     [ attachment = -1.120E+03 ; regularity = -2.389E+02 ]

------------------------------------- Iteration: 940 -------------------------------------
>> Log-likelihood = -1.359E+03     [ attachment = -1.120E+03 ; regularity = -2.387E+02 ]

------------------------------------- Iteration: 960 -------------------------------------
>> Log-likelihood = -1.359E+03     [ attachment = -1.121E+03 ; regularity = -2.382E+02 ]

------------------------------------- Iteration: 980 -------------------------------------
>> Log-likelihood = -1.359E+03     [ attachment = -1.121E+03 ; regularity = -2.376E+02 ]

------------------------------------- Iteration: 1000 -------------------------------------
>> Log-likelihood = -1.359E+03     [ attachment = -1.121E+03 ; regularity = -2.378E+02 ]

------------------------------------- Iteration: 1020 -------------------------------------
>> Log-likelihood = -1.359E+03     [ attachment = -1.121E+03 ; regularity = -2.379E+02 ]

------------------------------------- Iteration: 1040 -------------------------------------
>> Log-likelihood = -1.358E+03     [ attachment = -1.121E+03 ; regularity = -2.376E+02 ]

------------------------------------- Iteration: 1060 -------------------------------------
>> Log-likelihood = -1.358E+03     [ attachment = -1.121E+03 ; regularity = -2.371E+02 ]

------------------------------------- Iteration: 1080 -------------------------------------
>> Log-likelihood = -1.358E+03     [ attachment = -1.122E+03 ; regularity = -2.368E+02 ]

------------------------------------- Iteration: 1100 -------------------------------------
>> Log-likelihood = -1.358E+03     [ attachment = -1.122E+03 ; regularity = -2.362E+02 ]

------------------------------------- Iteration: 1120 -------------------------------------
>> Log-likelihood = -1.358E+03     [ attachment = -1.122E+03 ; regularity = -2.359E+02 ]

------------------------------------- Iteration: 1140 -------------------------------------
>> Log-likelihood = -1.358E+03     [ attachment = -1.122E+03 ; regularity = -2.357E+02 ]

------------------------------------- Iteration: 1160 -------------------------------------
>> Log-likelihood = -1.358E+03     [ attachment = -1.122E+03 ; regularity = -2.356E+02 ]
>> Log-likelihood = -1.358E+03     [ attachment = -1.122E+03 ; regularity = -2.356E+02 ]

------------------------------------- Iteration: 1180 -------------------------------------
>> Log-likelihood = -1.358E+03     [ attachment = -1.122E+03 ; regularity = -2.355E+02 ]
>> Log-likelihood = -1.358E+03     [ attachment = -1.122E+03 ; regularity = -2.355E+02 ]

------------------------------------- Iteration: 1200 -------------------------------------
>> Log-likelihood = -1.358E+03     [ attachment = -1.122E+03 ; regularity = -2.355E+02 ]

------------------------------------- Iteration: 1220 -------------------------------------
>> Log-likelihood = -1.358E+03     [ attachment = -1.122E+03 ; regularity = -2.357E+02 ]

------------------------------------- Iteration: 1240 -------------------------------------
>> Log-likelihood = -1.358E+03     [ attachment = -1.122E+03 ; regularity = -2.358E+02 ]
>> Log-likelihood = -1.358E+03     [ attachment = -1.122E+03 ; regularity = -2.359E+02 ]

------------------------------------- Iteration: 1260 -------------------------------------
>> Log-likelihood = -1.357E+03     [ attachment = -1.119E+03 ; regularity = -2.379E+02 ]

------------------------------------- Iteration: 1280 -------------------------------------
>> Log-likelihood = -1.356E+03     [ attachment = -1.116E+03 ; regularity = -2.401E+02 ]

------------------------------------- Iteration: 1300 -------------------------------------
>> Log-likelihood = -1.355E+03     [ attachment = -1.115E+03 ; regularity = -2.406E+02 ]

------------------------------------- Iteration: 1320 -------------------------------------
>> Log-likelihood = -1.354E+03     [ attachment = -1.116E+03 ; regularity = -2.381E+02 ]

------------------------------------- Iteration: 1340 -------------------------------------
>> Log-likelihood = -1.353E+03     [ attachment = -1.115E+03 ; regularity = -2.377E+02 ]

------------------------------------- Iteration: 1360 -------------------------------------
>> Log-likelihood = -1.352E+03     [ attachment = -1.115E+03 ; regularity = -2.365E+02 ]

------------------------------------- Iteration: 1380 -------------------------------------
>> Log-likelihood = -1.351E+03     [ attachment = -1.115E+03 ; regularity = -2.359E+02 ]

------------------------------------- Iteration: 1400 -------------------------------------
>> Log-likelihood = -1.350E+03     [ attachment = -1.114E+03 ; regularity = -2.366E+02 ]

------------------------------------- Iteration: 1420 -------------------------------------
>> Log-likelihood = -1.350E+03     [ attachment = -1.114E+03 ; regularity = -2.356E+02 ]

------------------------------------- Iteration: 1440 -------------------------------------
>> Log-likelihood = -1.349E+03     [ attachment = -1.114E+03 ; regularity = -2.350E+02 ]

------------------------------------- Iteration: 1460 -------------------------------------
>> Log-likelihood = -1.349E+03     [ attachment = -1.114E+03 ; regularity = -2.354E+02 ]

------------------------------------- Iteration: 1480 -------------------------------------
>> Log-likelihood = -1.349E+03     [ attachment = -1.113E+03 ; regularity = -2.355E+02 ]

------------------------------------- Iteration: 1500 -------------------------------------
>> Log-likelihood = -1.349E+03     [ attachment = -1.113E+03 ; regularity = -2.359E+02 ]

------------------------------------- Iteration: 1520 -------------------------------------
>> Log-likelihood = -1.349E+03     [ attachment = -1.113E+03 ; regularity = -2.356E+02 ]

------------------------------------- Iteration: 1540 -------------------------------------
>> Log-likelihood = -1.348E+03     [ attachment = -1.113E+03 ; regularity = -2.356E+02 ]

------------------------------------- Iteration: 1560 -------------------------------------
>> Log-likelihood = -1.348E+03     [ attachment = -1.112E+03 ; regularity = -2.360E+02 ]

------------------------------------- Iteration: 1580 -------------------------------------
>> Log-likelihood = -1.348E+03     [ attachment = -1.112E+03 ; regularity = -2.359E+02 ]

------------------------------------- Iteration: 1600 -------------------------------------
>> Log-likelihood = -1.348E+03     [ attachment = -1.112E+03 ; regularity = -2.360E+02 ]

------------------------------------- Iteration: 1620 -------------------------------------
>> Log-likelihood = -1.348E+03     [ attachment = -1.112E+03 ; regularity = -2.360E+02 ]

------------------------------------- Iteration: 1640 -------------------------------------
>> Log-likelihood = -1.348E+03     [ attachment = -1.112E+03 ; regularity = -2.359E+02 ]

------------------------------------- Iteration: 1660 -------------------------------------
>> Log-likelihood = -1.348E+03     [ attachment = -1.112E+03 ; regularity = -2.360E+02 ]

------------------------------------- Iteration: 1680 -------------------------------------
>> Log-likelihood = -1.348E+03     [ attachment = -1.111E+03 ; regularity = -2.364E+02 ]

------------------------------------- Iteration: 1700 -------------------------------------
>> Log-likelihood = -1.348E+03     [ attachment = -1.111E+03 ; regularity = -2.367E+02 ]

------------------------------------- Iteration: 1720 -------------------------------------
>> Log-likelihood = -1.347E+03     [ attachment = -1.111E+03 ; regularity = -2.368E+02 ]

------------------------------------- Iteration: 1740 -------------------------------------
>> Log-likelihood = -1.347E+03     [ attachment = -1.111E+03 ; regularity = -2.362E+02 ]
>> Log-likelihood = -1.347E+03     [ attachment = -1.111E+03 ; regularity = -2.363E+02 ]

------------------------------------- Iteration: 1760 -------------------------------------
>> Log-likelihood = -1.347E+03     [ attachment = -1.111E+03 ; regularity = -2.365E+02 ]

------------------------------------- Iteration: 1780 -------------------------------------
>> Log-likelihood = -1.347E+03     [ attachment = -1.111E+03 ; regularity = -2.364E+02 ]

------------------------------------- Iteration: 1800 -------------------------------------
>> Log-likelihood = -1.347E+03     [ attachment = -1.110E+03 ; regularity = -2.370E+02 ]

------------------------------------- Iteration: 1820 -------------------------------------
>> Log-likelihood = -1.347E+03     [ attachment = -1.110E+03 ; regularity = -2.372E+02 ]

------------------------------------- Iteration: 1840 -------------------------------------
>> Log-likelihood = -1.347E+03     [ attachment = -1.110E+03 ; regularity = -2.368E+02 ]

------------------------------------- Iteration: 1860 -------------------------------------
>> Log-likelihood = -1.347E+03     [ attachment = -1.110E+03 ; regularity = -2.372E+02 ]

------------------------------------- Iteration: 1880 -------------------------------------
>> Log-likelihood = -1.347E+03     [ attachment = -1.110E+03 ; regularity = -2.372E+02 ]

------------------------------------- Iteration: 1900 -------------------------------------
>> Log-likelihood = -1.347E+03     [ attachment = -1.110E+03 ; regularity = -2.369E+02 ]
>> Gradient at Termination: 2.2635546810751768
>> CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH
>> Estimation took: 21 minutes and 27 seconds
instantiating kernel torch with kernel_width 4.0 and gpu_mode GpuMode.KERNEL. addr: 0x7d2660822b50
Deformetrica.__del__()
[15]:
time.struct_time(tm_year=2025, tm_mon=3, tm_mday=18, tm_hour=2, tm_min=24, tm_sec=41, tm_wday=1, tm_yday=77, tm_isdst=0)

Further reading#