Skip to content

Commit f6579f8

Browse files
committed
refactor: modernize fit2x - own L-BFGS, remove LabVIEW layer and ALGLIB, BSD-3 SPDX
Optimizer: - Replace the bundled FORTRAN-derived L-BFGS (Nocedal/ALGLIB translation, non-OSI citeware license) and the entire thirdparty/alglib tree (compiled wholesale but used only for its array type) with a self-contained, header-only, std-only L-BFGS in include/i_lbfgs.h (BSD-3, ~150 lines: two-loop recursion, Armijo backtracking, central-difference gradients). The bfgs class interface (target function, fixed-parameter masks, eps and iteration control, minimize info codes) is unchanged, so DecayFit23-26 and the 2D Gaussian image localization work without call-site changes. fit2x cleanup: - Remove the LabView-heritage interface: LVI32Array, LVDoubleArray, MParam, CreateMParam and CreateLV*Array are gone. The fits now use DecayFitData, a plain std::vector container (Jordi format sizing preserved) that maps directly to numpy via SWIG. The x/fixed parameter array layouts of DecayFitNN::fit/modelf/targetf are unchanged. - Fix an uninitialized stack read in DecayFit25::correct_input (gamma was read from xm[1] before ever being written), which made fit25 results depend on the process memory layout. Fit results are now reproducible across processes. - Make all fit-internal static state thread_local. - New one-call convenience API: tttrlib.fit23/fit24/fit25/fit26 functions with keyword arguments, sensible defaults and dict results; the Fit23-Fit26 wrapper classes stay unchanged. Licensing: - Consistent BSD-3-Clause: fix the stray MIT SPDX tag in DecayFit.h and add SPDX-License-Identifier: BSD-3-Clause to all project sources (include/, src/, ext/python/). No third-party optimizer code remains. Verified: fit model functions bit-identical; fit quality (2I*) equal or better than the previous optimizer on a multi-start grid; full test suite passes (616); fit23 throughput ~15k fits/s.
1 parent cbbf554 commit f6579f8

158 files changed

Lines changed: 944 additions & 11746 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,6 @@ ELSE()
194194
LINK_LIBRARIES(nlohmann_json::nlohmann_json)
195195
ENDIF()
196196

197-
# LBFGS
198-
FILE(GLOB_RECURSE LBFGS "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/lbfgs/*.cpp")
199-
LIST(APPEND SRC_files ${LBFGS})
200-
201-
# ALGLib
202-
FILE(GLOB_RECURSE ALGLIB "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/alglib/*.cpp")
203-
LIST(APPEND SRC_files ${ALGLIB})
204-
205197
# HighFive HDF5 reader
206198
IF(BUILD_PHOTON_HDF)
207199
IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/HighFive/CMakeLists.txt")

examples/fluorescence_decay/plot_fit23_usage_2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ def model_irf(
5757
# add poisson noise to model and use as data
5858
data = np.random.poisson(model * n_photons)
5959

60-
# create MParam structure that contains all parameters for fitting
61-
m_param = tttrlib.CreateMParam(
60+
# create DecayFitData container that contains all parameters for fitting
61+
m_param = tttrlib.DecayFitData(
6262
irf=irf_np,
6363
background=bg,
6464
data=data.astype(np.int32),

ext/documentation.i

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
12

23
// File: index.xml
34

ext/python/BurstFeatureExtractor.i

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
12
%{
23
#include "BurstFeatureExtractor.h"
34
#include <nlohmann/json.hpp>

ext/python/BurstFilter.i

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
12
%{
23
#include "BurstFilter.h"
34
#include "Channel.h"

ext/python/CLSM.i

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
12
%{
23
#include "CLSMPixel.h"
34
#include "CLSMLine.h"

ext/python/CLSMFrame.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
12
import numpy as np
23

34
@property

ext/python/CLSMISM.i

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
12
// CLSMISM SWIG interface (embedded into the main tttrlib module)
23
%include "misc_types.i"
34

ext/python/CLSMISM.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
12
import warnings
23
import numpy as np
34

ext/python/CLSMImage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
12
import numpy as np
23

34
@property

0 commit comments

Comments
 (0)