OSCR

Dynamic image-informed selection of biomechanical tumor growth models.

Code ↔ Paper

1 match between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

The 1 match
  1. [1] § Methods › Scalable Bayesian filtering and model plausibility ↔ BayesianInference/Rat-3_hyper.py, lines 178–205 · score 0.55 · Newton CG, globalized, gradient, misfit, MAP, Bayesian

Paper

Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

Python · 579 lines · 19 KB · no license · 1 match

  1. # ----------------------------------------------------------------------
  2. # Mech-RD Tumor Model___Inferring 3 Params (E, D, G)
  3. ########## Hyper-elasticity ###########
  4. ############## Rat-3 ###################
  5. # ----------------------------------------------------------------------
  6. import time
  7. import math
  8. import numpy as np
  9. import dolfin as dl
  10. from fenics import *
  11. import ufl
  12. import sys
  13. import os
  14. import argparse
  15. sep = "\n"+"#"*80+"\n"
  16. # hippylib setup
  17. sys.path.append('../hippylib/hippylib')
  18. from hippylib import BiLaplacianPrior
  19. from hippylib import *
  20. sys.path.append('..')
  21. from mech_hyper import MechCoupledTumorVarf
  22. from td_mechHyp import VectorTD, TimeDependentPDEVariationalProblem, MisfitTD
  23. from utils import interp, vector2Function
  24. # Start execution timer
  25. start_time = time.time()
  26. # Set log level
  27. dl.set_log_level(40)
  28. parameters["form_compiler"]["quadrature_degree"] = 4
  29. def computeGammaDelta(corr_len, std, alpha=2, ndim=2):
  30. nu = alpha - 0.5 * float(ndim)
  31. assert alpha > 0., "Alpha must be larger than ndim/2"
  32. kappa = math.sqrt(8. * nu) / corr_len
  33. gamma = math.sqrt(math.gamma(nu) / math.gamma(alpha)) / (math.pow(4.0 * math.pi, 0.25 * float(ndim)) * math.pow(kappa, nu) * std)
  34. delta = kappa * kappa * gamma
  35. return gamma, delta
  36. # ------------------------------
  37. # Problem Configuration Section
  38. # ------------------------------
  39. parser = argparse.ArgumentParser()
  40. parser.add_argument('--sigma', default=0.035, type=float)
  41. parser.add_argument('--rhoGM', default=800, type=float)
  42. parser.add_argument('--nsamples', default=500, type=int)
  43. args = parser.parse_args()
  44. # Load Mesh
  45. name = "W05_0"
  46. data_dir = "../mri_data/W05_data/2D/"
  47. mesh = dl.Mesh(data_dir + name + ".xml")
  48. dx = dl.Measure("dx", domain=mesh)
  49. # Function Space
  50. Vh2 = dl.FunctionSpace(mesh, 'Lagrange', 2)
  51. Vh1 = dl.FunctionSpace(mesh, 'Lagrange', 1)
  52. Vh_param = dl.FunctionSpace(mesh, dl.MixedElement([Vh1.ufl_element(), Vh1.ufl_element(), Vh1.ufl_element()]))
  53. Vh = [Vh2, Vh_param, Vh2]
  54. ndofs = [Vh[STATE].dim(), Vh[PARAMETER].dim(), Vh[ADJOINT].dim()]
  55. print(f"STATE={ndofs[0]}, PARAMETER={ndofs[1]}, ADJOINT={ndofs[2]}")
  56. # Load Data
  57. h5 = dl.HDF5File(mesh.mpi_comm(), data_dir + "W05.h5", "r")
  58. time_to_group = {
  59. 2: "/W05/W05_0",
  60. 4: "/W05/W05_1",
  61. 5: "/W05/W05_2",
  62. 6: "/W05/W05_3",
  63. 9: "/W05/W05_4",
  64. }
  65. data = {}
  66. tlist = [2,4,5,6,9]
  67. for t in tlist:
  68. u = dl.Function(Vh[STATE])
  69. h5.read(u, time_to_group[t])
  70. data[str(t)] = u
  71. h5.close()
  72. obs_out = dl.XDMFFile("TumorData.xdmf")
  73. obs_out.parameters["flush_output"] = True
  74. obs_out.parameters["functions_share_mesh"] = True
  75. for t in tlist:
  76. f = dl.Function(Vh[STATE])
  77. f.assign(data[str(t)])
  78. f.rename("tumor", "tumor") # IMPORTANT for consistent naming
  79. obs_out.write(f, float(t))
  80. obs_out.close()
  81. #correlation length and sigmas [E, D, G]
  82. lc1, sigma1 = 5.5, 0.1
  83. lc2, sigma2 = 6.5, 0.3
  84. lc3, sigma3 = 3.5, 0.08
  85. gamma1, delta1 = computeGammaDelta(lc1, sigma1)
  86. gamma2, delta2 = computeGammaDelta(lc2, sigma2)
  87. gamma3, delta3 = computeGammaDelta(lc3, sigma3)
  88. gamma = [gamma1, gamma2, gamma3]
  89. delta = [delta1, delta2, delta3]
  90. theta_x = 0.55
  91. theta_y = 0.55
  92. anis_diff = dl.Constant([[theta_x, 0.], [0., theta_y]])
  93. prior = VectorBiLaplacianPrior(Vh[PARAMETER], gamma, delta,Theta=anis_diff,robin_bc=True)
  94. mean = dl.Function(Vh[PARAMETER])
  95. # Create constant expressions for each field
  96. mean_val1 = dl.Constant(-0.1562)
  97. mean_val2 = dl.Constant(-0.3492)
  98. mean_val3 = dl.Constant(-1.8965)
  99. # Extract subspaces from the mixed space
  100. V0 = Vh[PARAMETER].sub(0).collapse()
  101. V1 = Vh[PARAMETER].sub(1).collapse()
  102. V2 = Vh[PARAMETER].sub(2).collapse()
  103. # Interpolate constants into the subspaces
  104. mean_0 = dl.interpolate(mean_val1, V0)
  105. mean_1 = dl.interpolate(mean_val2, V1)
  106. mean_2 = dl.interpolate(mean_val3, V2)
  107. # Assign the subfield values into the mixed function
  108. assigner = dl.FunctionAssigner(Vh[PARAMETER], [V0, V1,V2])
  109. assigner.assign(mean, [mean_0, mean_1, mean_2])
  110. # Set it as the prior mean
  111. prior.mean.axpy(1.0, mean.vector())
  112. #------------------------ Initial Condition -------------------------
  113. u0 = interp(data_dir + "tumor_t0.mat", "cells_t", Vh[STATE])
  114. #----------------------- PDE Model Setup ------------------------
  115. dt = 1.0
  116. obs_times = [2, 4, 5, 6]
  117. sim_times = [2, 4, 5, 6, 9]
  118. H_D_val = 1.5
  119. log_H_val = math.log(H_D_val)
  120. pde_varf = MechCoupledTumorVarf(Vh, dt, dx=dl.dx, log_H_fixed=dl.Constant(log_H_val))
  121. pde = TimeDependentPDEVariationalProblem(
  122. Vh,
  123. pde_varf,
  124. [],
  125. [],
  126. u0,
  127. t_init=sim_times[0],
  128. t_final=sim_times[-1],
  129. is_fwd_linear=False,
  130. times=sim_times
  131. )
  132. #--------------------- Misfit setup ------------------------
  133. misfits = []
  134. for t in obs_times:
  135. #t_val = float(t)
  136. misfit_t = ContinuousStateObservation(Vh[STATE], dl.dx, [])
  137. obs_vec = data.get(str(int(t)))
  138. if obs_vec is not None:
  139. misfit_t.d.axpy(1.0, obs_vec.vector())
  140. else:
  141. raise RuntimeError(f"Missing observation at time {t}")
  142. misfit_t.noise_variance = args.sigma**2
  143. misfits.append(misfit_t)
  144. misfit = MisfitTD(misfits, obs_times)
  145. #-------------------- Solve for the MAP estimate -------------------------
  146. print( sep, "Find the MAP point", sep)
  147. model = Model(pde, prior, misfit)
  148. m0 = prior.mean.copy()
  149. params = ReducedSpaceNewtonCG_ParameterList()
  150. params["rel_tolerance"] = 1e-6
  151. params["abs_tolerance"] = 1e-10
  152. params["max_iter"] = 200
  153. params["globalization"] = "LS"
  154. params["print_level"] = 0
  155. params["GN_iter"] = 10
  156. params["cg_coarse_tolerance"] = 1e-6
  157. params["cg_max_iter"] = 200
  158. params["gdm_tolerance"] = 1e-12
  159. solver = ReducedSpaceNewtonCG(model, params)
  160. x = solver.solve([None, m0, None])
  161. t_map = time.time() - start_time
  162. print("\n##################################################################")
  163. print ("Termination reason: ", solver.termination_reasons[solver.reason])
  164. print ("Final gradient norm: ", solver.final_grad_norm)
  165. print ("Final cost: ", solver.final_cost)
  166. print ("Final simulation time (min): ", t_map/60)
  167. convergence = solver.converged
  168. print( "\nConverged in ", solver.it, " iterations.")
  169. print("##################################################################")
  170. # Save MAP
  171. map_func = vector2Function(x[PARAMETER], Vh[PARAMETER], name="MAP")
  172. dlx = dl.XDMFFile("MAP.xdmf")
  173. dlx.parameters["flush_output"] = True
  174. dlx.parameters["functions_share_mesh"] = True
  175. dlx.write(map_func, 0.0)
  176. dlx.close()
  177. # Save Prediction
  178. pde.solveFwd(x[STATE], x)
  179. pde.exportState(x[STATE], "state_trajectory.xdmf")
  180. print(sep, "Compute low-rank Gaussian Approximation of the posterior", sep)
  181. model.setPointForHessianEvaluations(x, gauss_newton_approx=True)
  182. Hmisfit = ReducedHessian(model, misfit_only=True)
  183. k = 50 # number of dominant modes
  184. p = 20 # oversampling
  185. print(f"Double Pass Algorithm: computing {k} modes with oversampling {p}")
  186. Omega = MultiVector(x[PARAMETER], k + p)
  187. parRandom.normal(1.0, Omega)
  188. d, eU = doublePassG(Hmisfit, prior.R, prior.Rsolver, Omega, k, s=1, check=False)
  189. posterior = GaussianLRPosterior(prior, d, eU)
  190. posterior.mean = x[PARAMETER]
  191. # ----------------------------------------------------------------------
  192. # Compute Model Evidence (Laplace Approximation)
  193. # ----------------------------------------------------------------------
  194. print(sep, "Computing model evidence (Laplace Approximation)", sep)
  195. print("\nRunning detailed evidence diagnostics...")
  196. Nd_check = 0
  197. for t in obs_times:
  198. v = data[str(t)].vector().get_local()
  199. Nd_check += v.size
  200. print("Total Nd from data =", Nd_check)
  201. residuals = []
  202. for t in obs_times:
  203. xi_t = pde.generate_static_state()
  204. x[STATE].retrieve(xi_t, float(t))
  205. pred = vector2Function(xi_t, Vh[STATE])
  206. obs_vec = data[str(t)]
  207. r = pred.vector().get_local() - obs_vec.vector().get_local()
  208. residuals.append(r)
  209. res_all = np.hstack(residuals)
  210. Phi_direct = 0.5 * np.dot(res_all, res_all) / (args.sigma**2)
  211. print(f"Phi_direct (manual residual) = {Phi_direct:.4e}")
  212. # --- Misfit term Φ(m_MAP) ---
  213. Phi_MAP = model.misfit.cost(x)
  214. print("Φ(m_MAP) =", Phi_MAP)
  215. # --- Prior norm term: (m_MAP - m_pr)^T Γ_pr^{-1} (m_MAP - m_pr) ---
  216. m_diff = x[PARAMETER].copy()
  217. m_diff.axpy(-1.0, prior.mean) # m_MAP - m_pr
  218. # Solve R * y = m_diff for y, then prior_norm_sq = m_diff^T y
  219. y_temp = dl.Vector(m_diff) # allocate solution vector
  220. prior.Rsolver.solve(y_temp, m_diff) # solves R y_temp = m_diff
  221. prior_norm_sq = m_diff.inner(y_temp)
  222. print("Prior norm squared =", prior_norm_sq)
  223. # --- Noise variance / normalization term ---
  224. sigma_noise = args.sigma
  225. try:
  226. Nd = sum([m.d.size() for m in misfits]) # if misfit stores .d vector with .size()
  227. except Exception:
  228. Nd = 0
  229. for m in misfits:
  230. try:
  231. Nd += m.d.size()
  232. except Exception:
  233. try:
  234. Nd += len(m.d)
  235. except Exception:
  236. pass
  237. term_noise = -0.5 * Nd * math.log(2.0 * math.pi * sigma_noise**2)
  238. print("Noise term =", term_noise, " (Nd =", Nd, ", sigma_noise =", sigma_noise, ")")
  239. lambda_vals = np.asarray(d).ravel() # shape (k,)
  240. r = lambda_vals.size
  241. if r == 0:
  242. term_eig = 0.0
  243. else:
  244. # numerically stable log(1+lambda) via log1p
  245. term_eig = -0.5 * np.sum(np.log1p(lambda_vals))
  246. print(f"Using r = {r} eigenvalues; Eigenvalue correction = {term_eig:.6f}")
  247. # --- Effective dimension (diagnostic) ---
  248. eff_dim = np.sum(lambda_vals / (1.0 + lambda_vals))
  249. print(f"Effective dimension = {eff_dim:.3f}")
  250. # Detailed evidence breakdown
  251. log_evidence = -Phi_MAP - 0.5 * prior_norm_sq + term_noise + term_eig
  252. print("\nEVIDENCE COMPONENTS:")
  253. print(f" -Phi_MAP = {-Phi_MAP:.4e}")
  254. print(f" -0.5*prior_norm_sq = {-0.5*prior_norm_sq:.4e}")
  255. print(f" term_noise = {term_noise:.4e}")
  256. print(f" term_eig (correction) = {term_eig:.4e}")
  257. print("\n######################## Model Evidence ########################")
  258. print(f"log_evidence = {log_evidence:.12e}")
  259. try:
  260. evidence_val = math.exp(log_evidence)
  261. print(f"Evidence = {evidence_val:.6e}")
  262. except OverflowError:
  263. print("Evidence too small to exponentiate safely (underflow). Keep log_evidence instead.")
  264. print("################################################################")
  265. # ------------------------
  266. # ------------------------
  267. def compute_dice_score(f1, f2, threshold=0.25):
  268. """
  269. Computes DICE between two FEniCS Functions by DOF thresholding.
  270. """
  271. f1_vals = f1.vector().get_local()
  272. f2_vals = f2.vector().get_local()
  273. f1_mask = (f1_vals > threshold).astype(np.int8)
  274. f2_mask = (f2_vals > threshold).astype(np.int8)
  275. intersection = np.sum(f1_mask * f2_mask)
  276. total = np.sum(f1_mask) + np.sum(f2_mask)
  277. return (2.0 * intersection) / (total + 1e-12)
  278. # ----------------------------------------------------------------------
  279. # Posterior NTA Evaluation: 50 samples per time point
  280. # ----------------------------------------------------------------------
  281. print(sep, "Evaluating NTA across posterior samples", sep)
  282. num_nta_samples = 50
  283. # Evaluate NTA at ALL internal solver times
  284. eval_times = list(pde.times)
  285. brain_area = dl.assemble(dl.Constant(1.0) * dx)
  286. # Storage
  287. nta_results = {t: [] for t in eval_times}
  288. nta_mri_dict = {}
  289. # Compute MRI NTA only where MRI exists
  290. for t in eval_times:
  291. key = str(int(t))
  292. if key in data:
  293. true = data[key]
  294. true_indicator = dl.Function(Vh[STATE])
  295. true_indicator.vector().set_local(
  296. np.where(true.vector().get_local() > 0.25, 1.0, 0.0)
  297. )
  298. nta_mri_dict[t] = dl.assemble(true_indicator * dx) / brain_area
  299. else:
  300. nta_mri_dict[t] = np.nan
  301. # Initialize noise vector
  302. noise = dl.Vector()
  303. posterior.init_vector(noise, "noise")
  304. # File for all NTA samples
  305. with open("NTA_posterior_samples.txt", "w") as f:
  306. f.write("Time,SampleID,NTA_model,NTA_mri\n")
  307. for i in range(num_nta_samples):
  308. print(f"NTA posterior sample {i+1}/{num_nta_samples}")
  309. parRandom.normal(1.0, noise)
  310. # Draw posterior sample
  311. pr_s = model.generate_vector(PARAMETER)
  312. post_s = model.generate_vector(PARAMETER)
  313. posterior.sample(noise, pr_s, post_s, add_mean=True)
  314. # Solve PDE forward for this sample
  315. u = pde.generate_state()
  316. x_sample = [u, post_s, None]
  317. pde.solveFwd(x_sample[STATE], x_sample)
  318. for t in eval_times:
  319. xi_t = pde.generate_static_state()
  320. x_sample[STATE].retrieve(xi_t, float(t))
  321. pred = vector2Function(xi_t, Vh[STATE])
  322. # Compute NTA_model
  323. nta_indicator = dl.Function(Vh[STATE])
  324. nta_indicator.vector().set_local(np.where(pred.vector().get_local() > 0.25, 1.0, 0.0))
  325. nta_model = dl.assemble(nta_indicator * dx) / brain_area
  326. nta_results[t].append(nta_model)
  327. f.write(f"{t},{i},{nta_model:.6f},{nta_mri_dict[t]:.6f}\n")
  328. # --- Compute summary statistics ---
  329. mean_nta = [np.mean(nta_results[t]) for t in eval_times]
  330. std_nta = [np.std(nta_results[t]) for t in eval_times]
  331. nta_mri_values = [nta_mri_dict[t] for t in eval_times]
  332. # Save summary results
  333. with open("NTA_summary.txt", "w") as f:
  334. f.write("Time,NTA_model,NTA_mri\n")
  335. for t, mean_val, nta_mri_val in zip(eval_times, mean_nta, nta_mri_values):
  336. f.write(f"{t},{mean_val:.6f},{nta_mri_val:.6f}\n")
  337. # ----------------------------------------------------------------------
  338. # Posterior DICE Evaluation: Mean ± Std across posterior samples
  339. # ----------------------------------------------------------------------
  340. print(sep, "Evaluating posterior DICE", sep)
  341. num_dice_samples = 50
  342. eval_times = [t for t in sim_times if str(t) in data]
  343. dice_results = {t: [] for t in eval_times}
  344. noise = dl.Vector()
  345. posterior.init_vector(noise, "noise")
  346. for i in range(num_dice_samples):
  347. print(f"DICE posterior sample {i+1}/{num_dice_samples}")
  348. parRandom.normal(1.0, noise)
  349. pr_s = model.generate_vector(PARAMETER)
  350. post_s = model.generate_vector(PARAMETER)
  351. posterior.sample(noise, pr_s, post_s, add_mean=True)
  352. u = pde.generate_state()
  353. x_sample = [u, post_s, None]
  354. pde.solveFwd(x_sample[STATE], x_sample)
  355. for t in eval_times:
  356. xi_t = pde.generate_static_state()
  357. x_sample[STATE].retrieve(xi_t, float(t))
  358. pred = vector2Function(xi_t, Vh[STATE])
  359. true = data[str(t)]
  360. score = compute_dice_score(pred, true, threshold=0.25)
  361. dice_results[t].append(score)
  362. # Save raw samples
  363. with open("DICE_posterior_samples.txt","w") as f:
  364. f.write("Time,SampleID,DICE\n")
  365. for t in eval_times:
  366. for i,val in enumerate(dice_results[t]):
  367. f.write(f"{t},{i},{val:.6f}\n")
  368. mean_dice = [np.mean(dice_results[t]) for t in eval_times]
  369. std_dice = [np.std(dice_results[t]) for t in eval_times]
  370. # ----------------------------------------------------------------------
  371. # FINAL MAP MECHANICS EXPORT: Displacement and Hyper-elastic Stress
  372. # ----------------------------------------------------------------------
  373. print(sep, "Computing MAP Mechanics (Stress/Displacement) for Trajectory", sep)
  374. # File Setup
  375. mech_xdmf = dl.XDMFFile("MAP_mechanics_results.xdmf")
  376. mech_xdmf.parameters["flush_output"] = True
  377. mech_xdmf.parameters["functions_share_mesh"] = True
  378. # Function Space for Magnitudes and visualization
  379. V_mag = Vh1
  380. # Extract the MAP parameter for Stiffness (log_E)
  381. # map_func is already created from x[PARAMETER] earlier in the script
  382. log_E_map, _, _ = map_func.split(deepcopy=True)
  383. # Iterate through all simulation times (start from t=2)
  384. for t in sim_times:
  385. xi_t = pde.generate_static_state()
  386. x[STATE].retrieve(xi_t, float(t))
  387. pred_tumor = vector2Function(xi_t, Vh[STATE])
  388. if float(t) == float(sim_times[0]):
  389. # Force EVERYTHING to be absolute zero at the start
  390. disp_mag = dl.interpolate(dl.Constant(0.0), V_mag)
  391. piola_mag = dl.interpolate(dl.Constant(0.0), V_mag)
  392. print(f"Time t = {t:.2f}: Using forced absolute zeros.")
  393. else:
  394. # solve mechanics for all time after the initial MRI time point
  395. u_mech = pde_varf.solve_mechanics(pred_tumor, log_E_map, pde_varf.log_H_fixed)
  396. # Calculate magnitudes
  397. disp_mag = project(sqrt(dot(u_mech, u_mech)), V_mag)
  398. P2_tensor = pde_varf.first_piola_from_energy(u_mech, log_E_map)
  399. piola_mag = project(sqrt(inner(P2_tensor, P2_tensor)), V_mag)
  400. # Rename for Paraview consistency (Important!)
  401. disp_mag.rename("Displacement_Magnitude", "disp_mag")
  402. piola_mag.rename("First_Piola_Kirchhoff_Magnitude", "piola_mag")
  403. # Export
  404. mech_xdmf.write(disp_mag, float(t))
  405. mech_xdmf.write(piola_mag, float(t))
  406. mech_xdmf.close()
  407. print("MAP Mechanics saved to 'MAP_mechanics_results.xdmf'")
  408. # --------------------------------------------------------
  409. # MAP DICE + NTA + Volume block
  410. # --------------------------------------------------------
  411. print(sep, "Computing MAP DICE / NTA / Volume", sep)
  412. eval_times = [t for t in sim_times if str(t) in data]
  413. dice_file = open("DICE_scores.txt", "w")
  414. dice_file.write("Time,DICE\n")
  415. nta_file = open("nta.txt", "w")
  416. nta_file.write("Time,NTA_model,NTA_mri\n")
  417. vol_file = open("TumorVolumes.txt", "w")
  418. vol_file.write("Time,Volume\n")
  419. brain_area = dl.assemble(dl.Constant(1.0) * dx)
  420. # --- Paraview writers ---
  421. map_pred_xdmf = dl.XDMFFile("MAP_predictions.xdmf")
  422. map_pred_xdmf.parameters["flush_output"] = True
  423. map_pred_xdmf.parameters["functions_share_mesh"] = True
  424. map_mask_xdmf = dl.XDMFFile("MAP_indicator_masks.xdmf")
  425. map_mask_xdmf.parameters["flush_output"] = True
  426. map_mask_xdmf.parameters["functions_share_mesh"] = True
  427. for t in eval_times:
  428. # retrieve state at time t
  429. xi_t = pde.generate_static_state()
  430. x[STATE].retrieve(xi_t, float(t))
  431. pred = vector2Function(xi_t, Vh[STATE], name=f"MAP_pred_t{t}")
  432. true = data[str(t)]
  433. # --- Save tumor field for paraview ---
  434. map_pred_xdmf.write(pred, float(t))
  435. # --- New DICE ---
  436. dice_score = compute_dice_score(pred, true, threshold=0.25)
  437. # --- New NTA / Volume ---
  438. pred_indicator = dl.Function(Vh[STATE], name=f"MAP_indicator_t{t}")
  439. pred_indicator.vector().set_local(
  440. np.where(pred.vector().get_local() > 0.25, 1.0, 0.0)
  441. )
  442. # save mask for paraview
  443. map_mask_xdmf.write(pred_indicator, float(t))
  444. nta_model = dl.assemble(pred_indicator * dx) / brain_area
  445. true_indicator = dl.Function(Vh[STATE])
  446. true_indicator.vector().set_local(
  447. np.where(true.vector().get_local() > 0.25, 1.0, 0.0)
  448. )
  449. nta_mri = dl.assemble(true_indicator * dx) / brain_area
  450. # volume (non-normalized)
  451. vol = dl.assemble(pred_indicator * dx)
  452. # --- Save text values ---
  453. dice_file.write(f"{t},{dice_score:.6f}\n")
  454. nta_file.write(f"{t},{nta_model:.6f},{nta_mri:.6f}\n")
  455. vol_file.write(f"{t},{vol:.6f}\n")
  456. dice_file.close()
  457. nta_file.close()
  458. vol_file.close()
  459. map_pred_xdmf.close()
  460. map_mask_xdmf.close()
  461. print("MAP DICE / NTA / Volume stored in TXT + XDMF files.")
  462. print("Inference complete. Results stored as XDMF and PVD files.")

Rat-3_hyper.py at commit 7e048e0, no license · at the source

Overview

Authors: Abdullah Al Noman1, Pratyush Kumar Singh1, David A Hormuth II2, Danial Faghihi1
  1. Department of Mechanical and Aerospace Engineering, University at Buffalo, Buffalo, NY USA
  2. Oden Institute for Computational Engineering and Sciences, Livestrong Cancer Institutes, University of Texas at Austin, Austin, TX USA
Journal: Biomechanics and modeling in mechanobiology, volume 25, issue 5, article 97
Dates: received 6 April 2026; accepted 12 August 2026; published online 31 August 2026; in print 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.1007/s10237-026-02121-2 · PMID 42675182 · PMCID PMC13529865 · OpenAlex W7204846453
Open access: hybrid, a free copy (OpenAlex)
Status: code verified
Categories: structural MRI / diffusion (modality), mouse (organism), other condition (population)
Methods: Spectral & time-frequency, Connectivity, fMRI & imaging
Keywords: Biomechanical tumor growth, Finite deformation elasticity, Dynamic model selection, Image-informed modeling
MeSH: Brain Neoplasms*, Magnetic Resonance Imaging*, Models, Biological*, Animals, Bayes Theorem, Biomechanical Phenomena, Cell Proliferation, Elasticity, Mice, Stress, Mechanical (* major topic)
Topic: Mathematical Biology Tumor Growth (Modeling and Simulation, Mathematics), according to OpenAlex
Funding: State University of New York (SUNY) Research Seed Grant (1191358); U.S. National Science Foundation (NSF) through CAREER Award (CMMI-2143662); U.S. National Science Foundation (NSF) (DMS-2436499)
Citations: not cited yet (Europe PMC); 45 references in the paper

Abstract

Glioblastoma progression is strongly influenced by evolving mechanical interactions between the tumor and surrounding brain tissue. However, the extent to which finite-deformation mechanics and constitutive assumptions improve subject-specific prediction as tumor burden evolves remains unclear. We introduce a sequential Bayesian inference and dynamic model selection framework that assimilates longitudinal murine magnetic resonance imaging (MRI) data to calibrate spatially varying tumor diffusivity, proliferation rate, and tissue stiffness in biomechanical tumor growth models. Competing formulations were compared at each imaging time, including reaction–diffusion without mechanics and reaction–diffusion coupled to linear elasticity or hyperelastic mechanics, using posterior model plausibility to adapt model choice for individualized one-scan-ahead prediction as new MRI scans are acquired. Across the studied animals, mechanically coupled models were consistently more plausible than the uncoupled reaction–diffusion model, and the evolution of model plausibility indicated an increasing role of mass effect and stress-mediated feedback of tumor growth during progression. While linear and hyperelastic coupled tumor growth models often produced similar tumor morphology, they yield distinct stress, deformation, and inferred stiffness fields, with the hyperelastic formulation often receiving higher posterior plausibility at later imaging times. These results indicate that, within the present longitudinal murine dataset, mechanical coupling is favored for image-informed glioma growth prediction and that constitutive assumptions should be evaluated sequentially for each subject rather than fixed a priori.

Supplementary Information: The online version contains supplementary material available at https://doi.org/10.1007/s10237-026-02121-2.

Reproduced under the paper's license (CC BY), from the paper cited above.

Repository

Its files are read in the Code ↔ Paper reader above, with 1 match between paragraphs and lines of code.

PCELab/RecursiveGliomaInference

License: none: the authors keep all their rights
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Commit: 7e048e0eab5133a9686a1445ac3fc677d2424a78, 5 July 2026
Languages: Python (4)
Size: 10 files, 4 scripts
Software Heritage: not archived
Found in: “Data availability”
Holds: README
Not found: license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: NumPy (3 files), SciPy (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers
  • 27 September 2026: the link answers
5 files

The paper's code and data availability statement is in the Data section.

Tracing map

Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.

What the map holds:

  • 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 4 scripts, each with its path and the digest of its content;
  • 1 match between paragraphs of the paper and lines of the code (method lexical-v1);
  • neither the text of the paper nor the code itself.

Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.

Data

No dataset and no data link were found in the paper.

Data availability

The data supporting the findings of this study are available from the corresponding author upon reasonable request. The computational code used in this study is available at https://github.com/PCELab/RecursiveGliomaInference.

Reproduced under the paper's license (CC BY), from the paper cited above.

Versions

The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.

Version 2, 28 September 2026

  • Publisher: n/a → Springer Science+Business Media

Version 1, 27 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 4 authors, 4 keywords, 10 MeSH terms, 3 funders, 29 references.

Cite

This paper

Noman, A. A., Singh, P. K., Hormuth, D. A., & Faghihi, D. (2026). Dynamic image-informed selection of biomechanical tumor growth models. Biomechanics and modeling in mechanobiology, 25(5), 97. https://doi.org/10.1007/s10237-026-02121-2

BibTeX

@article{noman2026dynamic,
author = {Noman, Abdullah Al and Singh, Pratyush Kumar and Hormuth, David A and Faghihi, Danial},
title = {{Dynamic image-informed selection of biomechanical tumor growth models}},
journal = {Biomechanics and modeling in mechanobiology},
year = {2026},
month = aug,
volume = {25},
number = {5},
pages = {97},
publisher = {Springer Science+Business Media},
issn = {1617-7959},
doi = {10.1007/s10237-026-02121-2},
url = {https://doi.org/10.1007/s10237-026-02121-2},
pmid = {42675182},
pmcid = {PMC13529865}
}

RIS

TY - JOUR
AU - Noman, Abdullah Al
AU - Singh, Pratyush Kumar
AU - Hormuth, David A
AU - Faghihi, Danial
TI - Dynamic image-informed selection of biomechanical tumor growth models
T2 - Biomechanics and modeling in mechanobiology
J2 - Biomech Model Mechanobiol
PY - 2026
DA - 2026/08/31
VL - 25
IS - 5
SP - 97
SN - 1617-7959
PB - Springer Science+Business Media
DO - 10.1007/s10237-026-02121-2
UR - https://doi.org/10.1007/s10237-026-02121-2
LA - en
ER -

CSL-JSON

{
"id": "10.1007/s10237-026-02121-2",
"type": "article-journal",
"title": "Dynamic image-informed selection of biomechanical tumor growth models",
"container-title": "Biomechanics and modeling in mechanobiology",
"author": [
{
"family": "Noman",
"given": "Abdullah Al"
},
{
"family": "Singh",
"given": "Pratyush Kumar"
},
{
"family": "Hormuth",
"given": "David A"
},
{
"family": "Faghihi",
"given": "Danial"
}
],
"container-title-short": "Biomech Model Mechanobiol",
"volume": "25",
"issue": "5",
"page": "97",
"DOI": "10.1007/s10237-026-02121-2",
"PMID": "42675182",
"PMCID": "PMC13529865",
"ISSN": "1617-7959",
"publisher": "Springer Science+Business Media",
"URL": "https://doi.org/10.1007/s10237-026-02121-2",
"language": "en",
"issued": {
"date-parts": [
[
2026,
8,
31
]
]
}
}

The tracing map gets a citation of its own once an author has validated it and it has a DOI.

Similar papers

The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.

[1] doi:10.1111/joa.70225
Immune proteomic associations with indices of cortical development in 5-year-old children.
Journal: Journal of anatomy
In common: structural MRI / diffusion, 1 reference
[2] doi:10.34133/csbj.0083
The Role of Astrocyte-Neuron Interactions in Shaping Neuronal Maturation during Human Brain Development.
Journal: Computational and structural biotechnology journal
In common: 1 reference

Contribute

The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.

Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.

Request its removal

To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).

Discussion, reproductions, activity

Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.

Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.

Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.