Hello, is it possible to split a DICOM serie into separate images a Lua script in orthanc?
For exemple i have one serie of 4 MG images and i want 4 series of 1 MG image.
Thanks.
Hello, is it possible to split a DICOM serie into separate images a Lua script in orthanc?
For exemple i have one serie of 4 MG images and i want 4 series of 1 MG image.
Thanks.
Hi Ludovic,
Yes, you can certainly do it.
That would probably look like this (disclaimer: not tested)
function OnStoredInstance(instanceId, tags, metadata, origin)
– Do not process twice the same file
if origin[‘RequestOrigin’] ~= ‘Lua’ then
– TODO: add a criteria to detect that it is an instance that you wish to move to another series
local modifyRequest = {}
modifyRequest[“Remove”] = {}
modifyRequest[“Replace”] = {}
– keep the Study and Instance ID but not the SeriesInstanceUID → it will generate a new one
modifyRequest[“Replace”][“StudyInstanceUID”] = tags[“StudyInstanceUID”]
modifyRequest[“Replace”][“SOPInstanceUID”] = tags[“SOPInstanceUID”]
modifyRequest[“Force”] = true – because we want to keep the same SOPInstanceUID
– download a modified version of the instance
local modifiedDicom = RestApiPost(‘/instances/’ … instanceId … ‘/modify’, DumpJson(modifyRequest))
– upload it to Orthanc
RestApiPost(‘/instances’, modifiedDicom)
– remove the original
RestApiDelete(‘/instances/’ … instanceId)
end
end
HTH
Alain
Thank you for your help.
What do you mean by “add a criteria to detect that it is an instance that you wish to move to another series”?
Could it be the first characters of the Accession Number?
Can you give me an example?
This criteria is specific to your use case. It can be: