Lua filter to exclude DICOM of a certain ImageType value

Hi,

I am using the AdvancedStorage plugin for my Orthanc instance and I am about to add a new path to "Folders" in my config file which contains DICOM of many types and I want to specifically exclude certain DICOM that are most easily distinguishable by the value for the ImageType tag. I have come up with a Lua filter as follows:

function ReceivedInstanceFilter(dicom, origin, info)
   if dicom.ImageType == "DERIVED\\SECONDARY\\C3034" or dicom.ImageType == "DERIVED\\SECONDARY\\C2058" then
      return false
   else
      return true
   end
end

I think the logic checks out, the only thing I am unsure of is whether the value of dicom.ImageType is as I expect in the code above. I don’t know if there is a good way to check what the value is except maybe if it is the same as what is returned by the API? I have used the R package I developed ( GitHub - mattwarkentin/orthanc: Programmatic Interface to the Orthanc DICOM Server REST API for the R Language · GitHub ) to query the DICOM tags for one of these Instances and it returns those values. This also tracks with the REST API documentation ( Orthanc REST API ). So it looks like I can expect a single string.

My hesitation came from reading these DICOM into Python (via pydicom, for example) and the ImageType field is treated as an array of values that split on the "\\". And when opening the DICOM in standard viewers, the same tag uses single slashes only (e.g., DERIVED\SECONDARY\C3034)

Anyway, I guess I am wondering whether there is a better way to find out the contents of dicom/origin/info inside Lua before deploying the script?

Hi @mattwrkntn

lua is keeping the tag value as a string so your test looks correct.

However, you can still add a print('imageType from lua: ' .. dicom.ImageType) statement in your script to validate it “manually” before going into production.

Hope this helps,

Alain.

1 Like