Commit 3dd0c1b0 authored by Sean Fitzgibbon's avatar Sean Fitzgibbon
Browse files

tweaks

parent 09bd88ab
...@@ -132,6 +132,9 @@ from tirl.transformations.linear.scale import TxScale, TxIsoScale ...@@ -132,6 +132,9 @@ from tirl.transformations.linear.scale import TxScale, TxIsoScale
from tirl.transformations.linear.translation import TxTranslation from tirl.transformations.linear.translation import TxTranslation
from tirl.transformations.nonlinear.displacement import TxDisplacementField from tirl.transformations.nonlinear.displacement import TxDisplacementField
import matplotlib.pyplot as plt
import os.path as op
# TIRL IMPORTS # TIRL IMPORTS
# DEFINITIONS # DEFINITIONS
...@@ -180,6 +183,8 @@ def run(cnf=None, **options): ...@@ -180,6 +183,8 @@ def run(cnf=None, **options):
p.moving.export = \ p.moving.export = \
os.path.join(p.general.outputdir, f"moving.{ext}") os.path.join(p.general.outputdir, f"moving.{ext}")
moving = tirl.scripts.mnd.inout.load_image(scope=globals(), **p.moving) moving = tirl.scripts.mnd.inout.load_image(scope=globals(), **p.moving)
if p.fixed.export is True: if p.fixed.export is True:
ext = ts.EXTENSIONS["TImage"] ext = ts.EXTENSIONS["TImage"]
p.fixed.export = os.path.join(p.general.outputdir, f"fixed.{ext}") p.fixed.export = os.path.join(p.general.outputdir, f"fixed.{ext}")
...@@ -208,6 +213,15 @@ def run(cnf=None, **options): ...@@ -208,6 +213,15 @@ def run(cnf=None, **options):
fixed, *p.preprocessing.fixed, scope=globals(), other=moving, cnf=p) fixed, *p.preprocessing.fixed, scope=globals(), other=moving, cnf=p)
fixed.centralise(weighted=True) fixed.centralise(weighted=True)
# if p.moving.snapshot is True:
# print(moving.mask.shape)
# plt.imsave(op.join(p.general.outputdir, 'moving_mask.png'), moving.mask)
#
# if p.fixed.snapshot is True:
# print(fixed.mask.shape)
# plt.imsave(op.join(p.general.outputdir, 'fixed_mask.png'), fixed.mask)
# Run the registration routine # Run the registration routine
try: try:
register(fixed, moving, p) register(fixed, moving, p)
...@@ -681,7 +695,7 @@ def rgb2hsv(x): ...@@ -681,7 +695,7 @@ def rgb2hsv(x):
def match_fixed_resolution(img, **kwargs): def match_fixed_resolution(img, **kwargs):
""" """
Resamples histology image to match the resolution of another 2D image. Resamples histology image to match the resolution of the fixed image.
""" """
p = AttrMap(kwargs.get("cnf")) p = AttrMap(kwargs.get("cnf"))
...@@ -892,13 +906,13 @@ def create_cli(parser): ...@@ -892,13 +906,13 @@ def create_cli(parser):
""" """
parser.add_argument("--moving", metavar="image", parser.add_argument("--moving", metavar="image",
help="Moving slide", default=None, type=str, help="Moving slide", default=None, type=str,
required=False) required=True)
parser.add_argument("--fixed", metavar="image", parser.add_argument("--fixed", metavar="image",
help="Fixed slide", default=None, type=str, help="Fixed slide", default=None, type=str,
required=False) required=True)
parser.add_argument("--out", metavar="dir", parser.add_argument("--out", metavar="dir",
help="Output directory", default=None, type=str, help="Output directory", default=None, type=str,
required=False) required=True)
parser.add_argument("--config", metavar="cnf_file.json", parser.add_argument("--config", metavar="cnf_file.json",
help="configuration file", default='default.json', type=str, help="configuration file", default='default.json', type=str,
required=False) required=False)
...@@ -913,7 +927,7 @@ def main(*args): ...@@ -913,7 +927,7 @@ def main(*args):
""" Main program code. """ """ Main program code. """
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
prog="slide_to_slide", prog="slice-register.py",
description="Registers a histology slide to " description="Registers a histology slide to "
"another histology slide.") "another histology slide.")
parser = create_cli(parser) parser = create_cli(parser)
......
Supports Markdown
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