Commit 227994d2 authored by Sean Fitzgibbon's avatar Sean Fitzgibbon
Browse files

Added ability not to save intermediate TIMGs

parent ca926c2c
......@@ -23,7 +23,7 @@ general:
# moving image settings
moving:
dtype: f4
export: true
export: false
file: ''
mask:
automask:
......@@ -33,7 +33,7 @@ moving:
function: null
# function: gmm_mask
normalise: true
preview: true
preview: false
resolution_level: 4
snapshot: true
storage: mem
......@@ -41,7 +41,7 @@ moving:
# fixed image settings
fixed:
dtype: f4
export: true
export: false
file: ''
mask:
automask:
......@@ -51,7 +51,7 @@ fixed:
# function: gmm_mask
function: null
normalise: true
preview: true
preview: false
resolution_level: 4
snapshot: true
storage: mem
......@@ -99,6 +99,8 @@ regparams:
visualise: false
xtol_abs: [0.001, 0.001, 0.001, 0.001]
xtol_rel: 0.01
export: false
snapshot: true
rigid:
opt_step: 0.1
......@@ -107,6 +109,8 @@ regparams:
visualise: false
xtol_abs: [0.001, 0.001, 0.001, 0.001]
xtol_rel: 0.01
export: false
snapshot: true
affine:
opt_step: 0.1
......@@ -115,6 +119,8 @@ regparams:
visualise: false
xtol_abs: [0.001, 0.001, 0.001, 0.001, 0.001, 0.001]
xtol_rel: 0.01
export: false
snapshot: true
nonlinear:
maxiter: [20, 20, 20, 20, 10, 10]
......@@ -133,6 +139,8 @@ regparams:
xtol_abs: 0.1
xtol_rel: 0.01 #mm median magnitude
kernel: MK_FULL
export: true
snapshot: true
......
......@@ -132,7 +132,7 @@ from tirl.transformations.nonlinear.displacement import TxDisplacementField
import matplotlib
matplotlib.use("TkAgg")
matplotlib.use("Agg")
print(matplotlib.get_backend())
import matplotlib.pyplot as plt
......@@ -448,14 +448,18 @@ def register(fixed, moving, cnf):
logger.info("Transformation chain has been initialised.")
# Generate output: initial alignment
fixed.save(os.path.join(p.general.outputdir, "fixed.timg"), overwrite=True)
fixed.snapshot(
os.path.join(p.general.outputdir, f"fixed.{SNAPSHOT_EXT}"), overwrite=True
)
moving.save(os.path.join(p.general.outputdir, "moving.timg"), overwrite=True)
moving.snapshot(
os.path.join(p.general.outputdir, f"moving.{SNAPSHOT_EXT}"), overwrite=True
)
if p.fixed.export:
fixed.save(os.path.join(p.general.outputdir, "fixed.timg"), overwrite=True)
if p.fixed.snapshot:
fixed.snapshot(
os.path.join(p.general.outputdir, f"fixed.{SNAPSHOT_EXT}"), overwrite=True
)
if p.moving.export:
moving.save(os.path.join(p.general.outputdir, "moving.timg"), overwrite=True)
if p.moving.snapshot:
moving.snapshot(
os.path.join(p.general.outputdir, f"moving.{SNAPSHOT_EXT}"), overwrite=True
)
# Set the first part of the chain
fixed.domain.chain.extend(chain[:-2])
......@@ -466,13 +470,15 @@ def register(fixed, moving, cnf):
rotation_search2d(fixed, moving, p)
logger.info("Completed rotation search.")
# Generate output
fixed.save(
os.path.join(p.general.outputdir, "fixed1_rotation.timg"), overwrite=True
)
moving.evaluate(fixed.domain).snapshot(
os.path.join(p.general.outputdir, f"moving1_rotation.{SNAPSHOT_EXT}"),
overwrite=True,
)
if q.rotsearch.export:
fixed.save(
os.path.join(p.general.outputdir, "fixed1_rotation.timg"), overwrite=True
)
if q.rotsearch.snapshot:
moving.evaluate(fixed.domain).snapshot(
os.path.join(p.general.outputdir, f"moving1_rotation.{SNAPSHOT_EXT}"),
overwrite=True,
)
else:
logger.info("Rotation search was skipped.")
......@@ -482,13 +488,15 @@ def register(fixed, moving, cnf):
rigid2d(fixed, moving, p)
logger.info("Completed rigid registration.")
# Generate output
fixed.save(
os.path.join(p.general.outputdir, "fixed2_rigid.timg"), overwrite=True
)
moving.evaluate(fixed.domain).snapshot(
os.path.join(p.general.outputdir, f"moving2_rigid.{SNAPSHOT_EXT}"),
overwrite=True,
)
if q.rigid.export:
fixed.save(
os.path.join(p.general.outputdir, "fixed2_rigid.timg"), overwrite=True
)
if q.rigid.snapshot:
moving.evaluate(fixed.domain).snapshot(
os.path.join(p.general.outputdir, f"moving2_rigid.{SNAPSHOT_EXT}"),
overwrite=True,
)
else:
logger.info("Rigid registration was skipped.")
......@@ -499,21 +507,18 @@ def register(fixed, moving, cnf):
affine2d(fixed, moving, p)
logger.info("Completed affine registration.")
# Generate output
fixed.save(
os.path.join(p.general.outputdir, "fixed3_affine.timg"), overwrite=True
)
moving.evaluate(fixed.domain).snapshot(
os.path.join(p.general.outputdir, f"moving3_affine.{SNAPSHOT_EXT}"),
overwrite=True,
)
if q.affine.export:
fixed.save(
os.path.join(p.general.outputdir, "fixed3_affine.timg"), overwrite=True
)
if q.affine.snapshot:
moving.evaluate(fixed.domain).snapshot(
os.path.join(p.general.outputdir, f"moving3_affine.{SNAPSHOT_EXT}"),
overwrite=True,
)
else:
logger.info("Affine registration was skipped.")
# mask_and(moving, fixed)
# moving.mask = None
# fixed.mask = None
# Non-linear registration
tx_nonlinear = chain[-1]
tx_nonlinear.domain.chain = fixed.domain.chain[:]
......@@ -523,13 +528,15 @@ def register(fixed, moving, cnf):
diffreg2d(fixed, moving, p)
logger.info("Completed non-linear registration.")
# Generate output
fixed.save(
os.path.join(p.general.outputdir, "fixed4_nonlinear.timg"), overwrite=True
)
moving.evaluate(fixed.domain).snapshot(
os.path.join(p.general.outputdir, f"moving4_nonlinear.{SNAPSHOT_EXT}"),
overwrite=True,
)
if q.nonlinear.export:
fixed.save(
os.path.join(p.general.outputdir, "fixed4_nonlinear.timg"), overwrite=True
)
if q.nonlinear.snapshot:
moving.evaluate(fixed.domain).snapshot(
os.path.join(p.general.outputdir, f"moving4_nonlinear.{SNAPSHOT_EXT}"),
overwrite=True,
)
else:
logger.info("Non-linear registration was skipped.")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment