Skip to content

Commit

Permalink
feat: add refseries query to nbia client
Browse files Browse the repository at this point in the history
  • Loading branch information
jjjermiah committed Apr 1, 2024
1 parent e85819b commit ebbfc85
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/nbiatoolkit/nbia.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
ReturnType,
conv_response_list,
)

from .dicomtags.tags import (
getReferencedSeriesUIDS,
extract_ROI_info,
getSequenceElement,
)

import pandas as pd
import requests
from requests.exceptions import JSONDecodeError as JSONDecodeError
Expand Down Expand Up @@ -615,6 +622,21 @@ def getDICOMTags(

return conv_response_list(response, returnType)

def getRefSeriesUIDs(
self,
SeriesInstanceUID: str,
) -> List[str]:

tags_df = self.getDICOMTags(
SeriesInstanceUID=SeriesInstanceUID,
return_type=ReturnType.DATAFRAME,
)

if type(tags_df) != pd.DataFrame:
raise ValueError("DICOM Tags not df or not found in the response.")

return getReferencedSeriesUIDS(series_tags_df=tags_df)

def downloadSeries(
self,
SeriesInstanceUID: Union[str, list],
Expand Down
8 changes: 8 additions & 0 deletions tests/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,11 @@ def test_extract_ROI_info(RTSTRUCT_Tags):
), "Expected all keys to be between 1 and 28"

print("All test cases passed!")


def test_getReferencedSeriesUIDS(client, RTSTRUCT_Series):
result = client.getRefSeriesUIDs(RTSTRUCT_Series["SeriesInstanceUID"].values[0])

expected = ["1.3.6.1.4.1.14519.5.2.1.133742245714270925254982946723351496764"]

assert result == expected, f"Expected {expected}, but got {result}"

0 comments on commit ebbfc85

Please sign in to comment.