Selective Inference Calling
kenbutcher opened this issue · 1 comments
Could we change the inference app call to allow it to skip an image under specific conditions? For instance, we do not want to trigger the inference label when we add a new secondary capture to Xnat.
It would also be useful if we could run batch inference on all images of one type (i.e. non-contrast CT), again preserving the ability to skip derived / secondary images.
A temp workaround for this now is to override the __call__
function as below.
def __call__(self, request, callbacks: Union[Dict, None] = None) -> Union[Dict, Tuple[str, Dict[str, Any]]]:
print(f"___________________________in my call, request {request} _ open dicom to check on metadata")
from lib.datastore.xnat import DCMUtil
dcm_ds = DCMUtil.open_one_dcm(request["image"])
dcm_type= DCMUtil.get_key_value(dcm_ds, 0x00080008)
print(f"___________________________dcm image type is {dcm_type=}")
stop_run = (len(dcm_ds)>2 and dcm_type[2]=="AI")
if stop_run:
print(f"!!!!!!!!!!!!!!!! Condition not meet this image")
return "",{}
result_file_name, result_json = super().__call__(request, callbacks)
return result_file_name, result_json
However, I think I cleaner solution since this would be a common situation is to add that feature in the BasicInferTask
to call a new interface function skip_inference_for_this_image
with a default implementation or return false
then user can override it with his logic @SachidanandAlle what do you think?