Skip to content

Commit

Permalink
feat: add getStudies and getNewSeries CLI tools
Browse files Browse the repository at this point in the history
  • Loading branch information
jjjermiah committed Feb 4, 2024
1 parent ccd44bb commit 99c5777
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 5 deletions.
10 changes: 6 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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]
Expand Down
54 changes: 53 additions & 1 deletion src/nbiatoolkit/nbia_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
Expand Down Expand Up @@ -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.")

Check warning on line 286 in src/nbiatoolkit/nbia_cli.py

View check run for this annotation

Codecov / codecov/patch

src/nbiatoolkit/nbia_cli.py#L285-L286

Added lines #L285 - L286 were not covered by tests

p.add_argument(

Check warning on line 288 in src/nbiatoolkit/nbia_cli.py

View check run for this annotation

Codecov / codecov/patch

src/nbiatoolkit/nbia_cli.py#L288

Added line #L288 was not covered by tests
"-c",
"--collection",
action="store",
required=True,
type=str,
)

p.add_argument(

Check warning on line 296 in src/nbiatoolkit/nbia_cli.py

View check run for this annotation

Codecov / codecov/patch

src/nbiatoolkit/nbia_cli.py#L296

Added line #L296 was not covered by tests
"-p",
"--patientID",
action="store",
default="",
type=str,
)

p.add_argument(

Check warning on line 304 in src/nbiatoolkit/nbia_cli.py

View check run for this annotation

Codecov / codecov/patch

src/nbiatoolkit/nbia_cli.py#L304

Added line #L304 was not covered by tests
"-s", "--studyInstanceUID",
action="store",
default="",
type=str,
)

args = _add_extra_args(p)

Check warning on line 311 in src/nbiatoolkit/nbia_cli.py

View check run for this annotation

Codecov / codecov/patch

src/nbiatoolkit/nbia_cli.py#L311

Added line #L311 was not covered by tests

return getResults_cli(func=NBIAClient(args.username, args.password).getStudies, Collection=args.collection, PatientID=args.patientID, StudyInstanceUID=args.studyInstanceUID)

Check warning on line 313 in src/nbiatoolkit/nbia_cli.py

View check run for this annotation

Codecov / codecov/patch

src/nbiatoolkit/nbia_cli.py#L313

Added line #L313 was not covered by tests




def getSeries_cli() -> None:
global query
Expand Down Expand Up @@ -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.")

Check warning on line 409 in src/nbiatoolkit/nbia_cli.py

View check run for this annotation

Codecov / codecov/patch

src/nbiatoolkit/nbia_cli.py#L408-L409

Added lines #L408 - L409 were not covered by tests

p.add_argument(

Check warning on line 411 in src/nbiatoolkit/nbia_cli.py

View check run for this annotation

Codecov / codecov/patch

src/nbiatoolkit/nbia_cli.py#L411

Added line #L411 was not covered by tests
"-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)

Check warning on line 419 in src/nbiatoolkit/nbia_cli.py

View check run for this annotation

Codecov / codecov/patch

src/nbiatoolkit/nbia_cli.py#L419

Added line #L419 was not covered by tests

return getResults_cli(func=NBIAClient(args.username, args.password).getNewSeries, Date=args.date)

Check warning on line 421 in src/nbiatoolkit/nbia_cli.py

View check run for this annotation

Codecov / codecov/patch

src/nbiatoolkit/nbia_cli.py#L421

Added line #L421 was not covered by tests

def downloadSingleSeries_cli() -> None:
global query
Expand Down

0 comments on commit 99c5777

Please sign in to comment.