Skip to content

Commit

Permalink
added CLI params for orthanc push
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandip117 committed Dec 13, 2024
1 parent b5a22d6 commit bd9eeec
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 10 deletions.
2 changes: 1 addition & 1 deletion base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def pacs_pull(self):
pass

@abstractmethod
def anonymize(self, dicom_dir: str, params: str, pv_id: int):
def anonymize(self, dicom_dir: str, params: str, send_params: dict, pv_id: int):
pass

@abstractmethod
Expand Down
10 changes: 5 additions & 5 deletions chrisClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def pacs_pull(self):
def pacs_push(self):
pass

def anonymize(self, dicom_dir: str, tag_struct: str, pv_id: int):
def anonymize(self, dicom_dir: str, tag_struct: str, send_params: dict, pv_id: int):

pl_id = self.__get_plugin_id({"name": "pl-dsdircopy", "version": "1.0.2"})
pl_sub_id = self.__get_plugin_id({"name": "pl-pfdicom_tagsub", "version": "3.3.4"})
Expand All @@ -59,10 +59,10 @@ def anonymize(self, dicom_dir: str, tag_struct: str, pv_id: int):
dir_send_data = {
"previous_id": tag_sub_id,
'inputFileFilter': "**/*dcm",
"orthancUrl": params["push"]["url"],
"username":params["push"]["username"],
"password": params["push"]["password"],
"pushToRemote": params["push"]["aec"]
"orthancUrl": send_params["url"],
"username": send_params["username"],
"password": send_params["password"],
"pushToRemote": send_params["aec"]
}
pl_inst_id = self.__create_feed(pl_dcm_id, dir_send_data)

Expand Down
46 changes: 42 additions & 4 deletions reg_chxr.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
logger.remove()
logger.add(sys.stderr, format=logger_format)

__version__ = '1.0.5'
__version__ = '1.0.6'

DISPLAY_TITLE = r"""
_ _
Expand Down Expand Up @@ -72,6 +72,37 @@
type=str,
help='directive to use to anonymize DICOMs'
)
parser.add_argument(
'--orthancUrl', '-o',
dest='orthancUrl',
type=str,
help='Orthanc server url',
default='http://0.0.0.0:8042'
)

parser.add_argument(
'--orthancUsername', '-u',
dest='username',
type=str,
help='Orthanc server username',
default='orthanc'
)

parser.add_argument(
'--orthancPassword', '-p',
dest='password',
type=str,
help='Orthanc server password',
default='orthanc'
)

parser.add_argument(
'--pushToRemote', '-r',
dest='pushToRemote',
type=str,
help='Remote modality',
default=''
)
parser.add_argument('-V', '--version', action='version',
version=f'%(prog)s {__version__}')

Expand Down Expand Up @@ -125,6 +156,7 @@ def main(options: Namespace, inputdir: Path, outputdir: Path):
# for each individual series, check if total file count matches total file registered
for series in data:
pacs_search_params = sanitize_for_cube(series)
file_count = int(series["NumberOfSeriesRelatedInstances"])
registered_file_count = cube_cl.get_pacs_registered(pacs_search_params)

# poll CUBE at regular interval for the status of file registration
Expand All @@ -135,17 +167,23 @@ def main(options: Namespace, inputdir: Path, outputdir: Path):
poll_count += 1
time.sleep(wait_poll)
registered_file_count = cube_cl.get_pacs_registered(pacs_search_params)
LOG(f"Registered file count is {registered_file_count}")
LOG(f"{registered_file_count} series found in CUBE.")

# check if polling timed out before registration is finished
if registered_file_count == 0:
raise Exception(f"PACS file registration unsuccessful. Please try again.")
LOG(f"{registered_file_count} files were successfully registered to CUBE.")
LOG(f"{file_count} files successfully registered to CUBE.")
send_params = {
"url": options.orthancUrl,
"username": options.username,
"password": options.password,
"aec": options.pushToRemote
}
dicom_dir = cube_cl.get_pacs_files(pacs_search_params)

# create connection object
cube_con = ChrisClient(options.CUBEurl, options.CUBEuser, options.CUBEpassword)
cube_con.anonymize(dicom_dir, options.tagStruct, options.pluginInstanceID)
cube_con.anonymize(dicom_dir, options.tagStruct,send_params, options.pluginInstanceID)


def sanitize_for_cube(series: dict) -> dict:
Expand Down

0 comments on commit bd9eeec

Please sign in to comment.