From 99c5777e58e6d94ff3199f7f8062523c97dc42a7 Mon Sep 17 00:00:00 2001 From: Jermiah Joseph Date: Sun, 4 Feb 2024 11:50:42 -0500 Subject: [PATCH] feat: add getStudies and getNewSeries CLI tools --- pyproject.toml | 10 ++++--- src/nbiatoolkit/nbia_cli.py | 54 ++++++++++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1835bf2..aaf79cf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,11 +10,13 @@ readme = "README.md" dicomsort = "nbiatoolkit.nbia_cli:DICOMSorter_cli" NBIAToolkit = "nbiatoolkit:version" getCollections = "nbiatoolkit.nbia_cli:getCollections_cli" -getPatients = "nbiatoolkit.nbia_cli:getPatients_cli" getBodyPartCounts = "nbiatoolkit.nbia_cli:getBodyPartCounts_cli" -downloadSingleSeries = "nbiatoolkit.nbia_cli:downloadSingleSeries_cli" -getSeries = "nbiatoolkit.nbia_cli:getSeries_cli" +getPatients = "nbiatoolkit.nbia_cli:getPatients_cli" getNewPatients = "nbiatoolkit.nbia_cli:getNewPatients_cli" +getStudies = "nbiatoolkit.nbia_cli:getStudies_cli" +getSeries = "nbiatoolkit.nbia_cli:getSeries_cli" +getNewSeries = "nbiatoolkit.nbia_cli:getNewSeries_cli" +downloadSingleSeries = "nbiatoolkit.nbia_cli:downloadSingleSeries_cli" [tool.poetry.dependencies] python = ">=3.10 || 3.12" @@ -54,7 +56,7 @@ dist_path = "dist/" upload_to_release = true upload_to_pypi = false remove_dist = false -commit_message = "chore(release): {version}" +commit_message = "chore(sem-ver): {version}" patch_without_tag = true [tool.semantic_release.commit_parser_options] diff --git a/src/nbiatoolkit/nbia_cli.py b/src/nbiatoolkit/nbia_cli.py index 39c35f2..6b80010 100644 --- a/src/nbiatoolkit/nbia_cli.py +++ b/src/nbiatoolkit/nbia_cli.py @@ -28,10 +28,12 @@ def version(): # run each command with -h to see the available options commands = [ "getCollections", + "getBodyPartCounts", "getPatients", "getNewPatients", - "getBodyPartCounts", + "getStudies", "getSeries", + "getNewSeries", "downloadSingleSeries", "dicomsort" ] @@ -278,6 +280,40 @@ def getBodyPartCounts_cli() -> None: func=NBIAClient(args.username, args.password).getBodyPartCounts, Collection=args.collection ) +def getStudies_cli() -> None: + global query + query = f"getStudies" + p = _initialize_parser(description=f"NBIAToolkit: {query}. Get studies from a collection.") + + p.add_argument( + "-c", + "--collection", + action="store", + required=True, + type=str, + ) + + p.add_argument( + "-p", + "--patientID", + action="store", + default="", + type=str, + ) + + p.add_argument( + "-s", "--studyInstanceUID", + action="store", + default="", + type=str, + ) + + args = _add_extra_args(p) + + return getResults_cli(func=NBIAClient(args.username, args.password).getStudies, Collection=args.collection, PatientID=args.patientID, StudyInstanceUID=args.studyInstanceUID) + + + def getSeries_cli() -> None: global query @@ -367,6 +403,22 @@ def getSeries_cli() -> None: Manufacturer=args.manufacturer, ) +def getNewSeries_cli() -> None: + global query + query = f"newSeries" + p = _initialize_parser(description=f"NBIAToolkit: {query}. Get new series from a collection since a given date.") + + p.add_argument( + "-d", "--date", + action="store", + required=True, + type=str, + help="The date to filter by, i.e '2021-01-01' or '2019/12/31", + ) + + args = _add_extra_args(p) + + return getResults_cli(func=NBIAClient(args.username, args.password).getNewSeries, Date=args.date) def downloadSingleSeries_cli() -> None: global query