Commit fd28830f authored by Sean Fitzgibbon's avatar Sean Fitzgibbon
Browse files

Added initial support for batch

parent 5f10c7f7
#!/usr/bin/env python
#
# Copyright 2021 Sean Fitzgibbon, University of Oxford
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import pandas as pd
from slider.slide_reg import register_slide_to_slide
def run_batch(csv):
# TODO: test what type of csv it is; SLIDE, CHART, APPLYXFM
df = pd.read_csv(csv)
if all(item in list(df) for item in ['moving', 'moving_res', 'fixed', 'fixed_res']):
print('Batch slider_app.py SLIDE')
# csv is SLIDE
for idx, row in df.iterrows():
register_slide_to_slide(**row)
\ No newline at end of file
......@@ -881,7 +881,7 @@ def pad(timg, **kwargs):
def register_slide_to_slide(moving, moving_res, fixed, fixed_res, out, config):
def register_slide_to_slide(moving, moving_res, fixed, fixed_res, out, config=None):
"""
Register 2D-slide to 2D-slide using TIRL.
......
......@@ -19,6 +19,7 @@ import sys
from slider.slide_reg import register_slide_to_slide, apply_slide_xfm
from slider.chart_reg import register_chart_to_slide
from slider.batch import run_batch
def add_slide_cli(subparsers):
"""
......@@ -106,6 +107,21 @@ def add_applyxfm_cli(subparsers):
parser.set_defaults(method='applyxfm')
def add_batch_cli(subparsers):
"""
Set up batch subparser instance.
"""
parser = subparsers.add_parser(
'BATCH',
description='Batch processing SlideR jobs',
formatter_class=lambda prog: argparse.HelpFormatter(prog, max_help_position=55, width=100)
)
parser.add_argument("csv", metavar="<csv>",
help="Spreadsheet of job info", type=str)
parser.set_defaults(method='batch')
if __name__ == "__main__":
""" Main program code. """
......@@ -115,6 +131,7 @@ if __name__ == "__main__":
add_slide_cli(subparsers)
add_chart_cli(subparsers)
add_applyxfm_cli(subparsers)
add_batch_cli(subparsers)
# ---
......@@ -131,5 +148,7 @@ if __name__ == "__main__":
register_chart_to_slide(**args)
elif method == 'applyxfm':
apply_slide_xfm(**args)
elif method == 'batch':
run_batch(**args)
else:
raise RuntimeError(f'Unknown method: {method}')
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