Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Sean Fitzgibbon
SlideR 🍔
Commits
153da78c
Commit
153da78c
authored
Jun 16, 2021
by
Sean Fitzgibbon
Browse files
Added initial support for slide-to-slide reg
parent
70ddaf9c
Changes
6
Hide whitespace changes
Inline
Side-by-side
setup.py
View file @
153da78c
import
setuptools
import
setuptools
from
slider
import
__version__
with
open
(
'requirements.txt'
,
'rt'
)
as
f
:
with
open
(
'requirements.txt'
,
'rt'
)
as
f
:
install_requires
=
[
l
.
strip
()
for
l
in
f
.
readlines
()]
install_requires
=
[
l
.
strip
()
for
l
in
f
.
readlines
()]
setuptools
.
setup
(
setuptools
.
setup
(
name
=
"slider"
,
name
=
"slider"
,
version
=
__version__
,
version
=
'0.0.1'
,
author
=
"Sean Fitzgibbon"
,
author
=
"Sean Fitzgibbon"
,
author_email
=
"sean.fitzgibbon@ndcn.ox.ac.uk"
,
author_email
=
"sean.fitzgibbon@ndcn.ox.ac.uk"
,
description
=
"Slide Registration tool"
,
description
=
"Slide Registration tool"
,
url
=
"https://git.fmrib.ox.ac.uk/seanf/slider"
,
url
=
"https://git.fmrib.ox.ac.uk/seanf/slider"
,
install_requires
=
install_requires
,
install_requires
=
install_requires
,
scripts
=
[
'slider.py'
],
scripts
=
[
'slider
_app
.py'
],
packages
=
setuptools
.
find_packages
(),
packages
=
setuptools
.
find_packages
(),
include_package_data
=
True
,
include_package_data
=
True
,
python_requires
=
'>=3.7'
,
python_requires
=
'>=3.7'
,
...
...
slider.py
deleted
100644 → 0
View file @
70ddaf9c
#!/usr/bin/env python
if
__name__
==
"__main__"
:
pass
\ No newline at end of file
slider/__init__.py
View file @
153da78c
__version__
=
'0.0.1'
\ No newline at end of file
default.json
→
slider/
default.json
View file @
153da78c
File moved
sli
ce-register
.py
→
sli
der/slide_reg
.py
View file @
153da78c
...
@@ -68,8 +68,7 @@
...
@@ -68,8 +68,7 @@
"""
"""
Oxford Post-Mortem MND Biomarkers Histology-MRI Registration Pipeline, Stage 1:
Register 2D-slide to 2D-slide
Registers a histology slide to the corresponding tissue block photograph.
After the input images are centralised, the registration employs sequential
After the input images are centralised, the registration employs sequential
rigid, affine and non-linear alignment. Depending on the chosen direction of
rigid, affine and non-linear alignment. Depending on the chosen direction of
...
@@ -92,8 +91,6 @@ optimised:
...
@@ -92,8 +91,6 @@ optimised:
offset:
offset:
[centralisation]
[centralisation]
The above chain maps the full-resolution 2D histology coordinates to the 2D
space of the tissue block photograph.
"""
"""
...
@@ -868,75 +865,71 @@ def pad(timg, **kwargs):
...
@@ -868,75 +865,71 @@ def pad(timg, **kwargs):
# PROGRAM FLOW CONTROL
# PROGRAM FLOW CONTROL
def
slide_to_slide
(
args
):
def
register_
slide_to_slide
(
moving
,
fixed
,
out
,
config
):
"""
"""
Main program code. Controls program flow, handles command-
li
n
e
arguments
.
Register 2D-slide to 2D-s
li
d
e
using TIRL
.
"""
"""
cnf
=
args
.
config
if
os
.
path
.
isfile
(
cnf
):
if
os
.
path
.
isfile
(
c
o
nf
ig
):
with
open
(
cnf
,
"r"
)
as
fp
:
with
open
(
c
o
nf
ig
,
"r"
)
as
fp
:
cnf
=
dict
(
json
.
load
(
fp
))
c
o
nf
ig
=
dict
(
json
.
load
(
fp
))
else
:
else
:
raise
FileNotFoundError
(
f
"The provided configuration file "
raise
FileNotFoundError
(
f
"The provided configuration file "
f
"does not exist:
{
args
.
config
}
"
)
f
"does not exist:
{
config
}
"
)
# Override histology and block file paths in the configuration file with
# those provided on the command line.
if
args
.
moving
and
os
.
path
.
isfile
(
args
.
moving
):
cnf
[
"moving"
][
"file"
]
=
args
.
moving
if
args
.
fixed
and
os
.
path
.
isfile
(
args
.
fixed
):
cnf
[
"fixed"
][
"file"
]
=
args
.
fixed
if
args
.
out
:
cnf
[
"general"
][
"outputdir"
]
=
args
.
out
cnf
[
"general"
][
"logfile"
]
=
f
'
{
args
.
out
}
/logfile.log'
cnf
[
"general"
][
"paramlogfile"
]
=
f
'
{
args
.
out
}
/paramlog.log'
# Override verbose option in configurations
cnf
[
"general"
][
"verbose"
]
=
args
.
verbose
# Run registration script
config
[
"moving"
][
"file"
]
=
moving
run
(
cnf
)
config
[
"fixed"
][
"file"
]
=
fixed
config
[
"general"
][
"outputdir"
]
=
out
config
[
"general"
][
"logfile"
]
=
f
'
{
out
}
/logfile.log'
config
[
"general"
][
"paramlogfile"
]
=
f
'
{
out
}
/paramlog.log'
# # Override verbose option in configurations
# cnf["general"]["verbose"] = args.verbose
def
create_cli
(
parser
):
# Run registration script
"""
# print(config)
Sets up the CLI argument parser instance.
run
(
config
)
"""
parser
.
add_argument
(
"--moving"
,
metavar
=
"image"
,
# def create_cli(parser):
help
=
"Moving slide"
,
default
=
None
,
type
=
str
,
# """
required
=
True
)
# Sets up the CLI argument parser instance.
parser
.
add_argument
(
"--fixed"
,
metavar
=
"image"
,
help
=
"Fixed slide"
,
default
=
None
,
type
=
str
,
# """
required
=
True
)
# parser.add_argument("--moving", metavar="image",
parser
.
add_argument
(
"--out"
,
metavar
=
"dir"
,
# help="Moving slide", default=None, type=str,
help
=
"Output directory"
,
default
=
None
,
type
=
str
,
# required=True)
required
=
True
)
# parser.add_argument("--fixed", metavar="image",
parser
.
add_argument
(
"--config"
,
metavar
=
"cnf_file.json"
,
# help="Fixed slide", default=None, type=str,
help
=
"configuration file"
,
default
=
'default.json'
,
type
=
str
,
# required=True)
required
=
False
)
# parser.add_argument("--out", metavar="dir",
parser
.
add_argument
(
"-v"
,
"--verbose"
,
default
=
False
,
action
=
"store_true"
,
# help="Output directory", default=None, type=str,
help
=
"Print status messages to the command line"
,
# required=True)
required
=
False
)
# parser.add_argument("--config", metavar="cnf_file.json",
# help="configuration file", default='default.json', type=str,
return
parser
# required=False)
# parser.add_argument("-v", "--verbose", default=False, action="store_true",
# help="Print status messages to the command line",
def
main
(
*
args
):
# required=False)
""" Main program code. """
# return parser
parser
=
argparse
.
ArgumentParser
(
prog
=
"slice-register.py"
,
description
=
"Registers a histology slide to "
# def main(*args):
"another histology slide."
)
# """ Main program code. """
parser
=
create_cli
(
parser
)
# parser = argparse.ArgumentParser(
if
args
:
# prog="slice-register.py",
slide_to_slide
(
parser
.
parse_args
(
args
))
# description="Registers a histology slide to "
else
:
# "another histology slide.")
parser
.
print_help
()
# parser = create_cli(parser)
# if args:
if
__name__
==
"__main__"
:
# register_slide_to_slide(parser.parse_args(args))
main
(
*
sys
.
argv
[
1
:])
# else:
# parser.print_help()
# if __name__ == "__main__":
# main(*sys.argv[1:])
slider_app.py
0 → 100644
View file @
153da78c
#!/usr/bin/env python
import
argparse
import
sys
from
slider.slide_reg
import
register_slide_to_slide
def
add_slide_cli
(
subparsers
):
"""
Set up slide-to-slide subparser instance.
"""
parser
=
subparsers
.
add_parser
(
'SLIDE'
,
description
=
'Register 2D slide to 2D slide'
,
formatter_class
=
lambda
prog
:
argparse
.
HelpFormatter
(
prog
,
max_help_position
=
55
,
width
=
100
)
)
parser
.
add_argument
(
"moving"
,
metavar
=
"<moving>"
,
help
=
"Moving slide"
,
type
=
str
)
parser
.
add_argument
(
"fixed"
,
metavar
=
"<fixed>"
,
help
=
"Fixed slide"
,
type
=
str
)
parser
.
add_argument
(
"--out"
,
metavar
=
"<dir>"
,
help
=
"Output directory"
,
default
=
None
,
type
=
str
,
required
=
False
)
parser
.
add_argument
(
"--config"
,
metavar
=
"<default.json>"
,
help
=
"configuration file"
,
default
=
'default.json'
,
type
=
str
,
required
=
False
)
# parser.add_argument("-v", "--verbose", default=False, action="store_true",
# help="Print status messages to the command line",
# required=False)
parser
.
set_defaults
(
method
=
'slide'
)
def
add_chart_cli
(
subparsers
):
"""
Set up chart-to-slide subparser instance.
"""
parser
=
subparsers
.
add_parser
(
'CHART'
,
description
=
'Register charting to 2D slide'
,
formatter_class
=
lambda
prog
:
argparse
.
HelpFormatter
(
prog
,
max_help_position
=
55
,
width
=
100
)
)
parser
.
set_defaults
(
method
=
'chart'
)
if
__name__
==
"__main__"
:
""" Main program code. """
parser
=
argparse
.
ArgumentParser
()
subparsers
=
parser
.
add_subparsers
()
add_slide_cli
(
subparsers
)
add_chart_cli
(
subparsers
)
# ---
if
len
(
sys
.
argv
)
==
1
:
parser
.
parse_args
([
'-h'
])
else
:
args
=
vars
(
parser
.
parse_args
())
method
=
args
.
pop
(
'method'
)
if
method
==
'slide'
:
register_slide_to_slide
(
**
args
)
elif
method
==
'chart'
:
pass
else
:
raise
RuntimeError
(
f
'Unknown method:
{
method
}
'
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment