Skip to content

Commit

Permalink
Merge pull request #308 from GSTT-CSC/306-refactor-relaxometry-to-use…
Browse files Browse the repository at this point in the history
…-hazentask

306 refactor relaxometry to use hazentask
  • Loading branch information
laurencejackson authored Feb 2, 2023
2 parents ba10d0a + 2fce2be commit 0dc7620
Show file tree
Hide file tree
Showing 11 changed files with 1,423 additions and 1,453 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test_cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,3 @@ jobs:
if: always() # will always run regardless of whether previous step fails - useful to ensure all CLI functions tested
run: |
hazen relaxometry tests/data/relaxometry/T1/site1_20200218/plate5 --calc_t1 --plate_number=5 --report
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ report
# TODO: Remove the following if no longer needed
tests/data/slicepos/results
tests/data/uniformity/results
hazenlib/data

# docs
docs/_build
Expand Down
34 changes: 13 additions & 21 deletions hazenlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,24 +315,6 @@ def get_field_of_view(dcm: pydicom.Dataset):
return fov


def parse_relaxometry_data(task, arguments, dicom_objects,
report): # def parse_relaxometry_data(arguments, dicom_objects, report): #

# Relaxometry arguments
relaxometry_cli_args = {'--calc_t1', '--calc_t2', '--plate_number',
'--show_template_fit', '--show_relax_fits',
'--show_rois', '--verbose'}

# Pass arguments with dictionary, stripping initial double dash ('--')
relaxometry_args = {}

for key in relaxometry_cli_args:
relaxometry_args[key[2:]] = arguments[key]

return task.main(dicom_objects, report_path=report,
**relaxometry_args)


def main():
arguments = docopt(__doc__, version=__version__)
task_module = importlib.import_module(f"hazenlib.tasks.{arguments['<task>']}")
Expand Down Expand Up @@ -387,9 +369,19 @@ def main():
# TODO: Refactor Relaxometry task into HazenTask object Relaxometry not currently converted to HazenTask object -
# this task accessible in the CLI using the old syntax until it can be refactored
elif arguments['<task>'] == 'relaxometry':
task = importlib.import_module(f"hazenlib.{arguments['<task>']}")
dicom_objects = [pydicom.read_file(x, force=True) for x in files if is_dicom_file(x)]
result = parse_relaxometry_data(task, arguments, dicom_objects, report=True)

# Relaxometry arguments
relaxometry_cli_args = {'--calc_t1', '--calc_t2', '--plate_number',
'--show_template_fit', '--show_relax_fits',
'--show_rois', '--verbose'}

# Pass arguments with dictionary, stripping initial double dash ('--')
relaxometry_args = {}
for key in relaxometry_cli_args:
relaxometry_args[key[2:]] = arguments[key]

result = task.run(**relaxometry_args)

else:
result = task.run()

Expand Down
Loading

2 comments on commit 0dc7620

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.