Hi Sebastien,
Unfortunately, I can't send one of the problematic files and would need to create one for you artificially. The problematic sequence contains patient information that I am attempting to scrub from the file. For the time being, my two step process (designating remove and keep operations to separate API calls) is working.
If I have some time, I'll try to create an artificial example of what I'm talking about.
My guess is that Orthanc sweeps through all the DICOM tags, comparing them against the keep/remove/replace list and flags their status accordingly prior to performing the anonymization step. The order in which keep/remove/replace is evaluated is important if, for example, a sequence marked for deletion (remove) is then found to contain a tag marked to keep.
An example of what the sequence 0040-0275 might contain can be found
here and is listed below:
(0040,0275) Request Attributes Sequence | 3 | Sequence |
(0040,1001) Requested Procedure ID | 1C | Short String |
(0008,0050) Accession Number | 3 | Short String |
(0008,0051) Issuer of Accession Number Sequence | 3 | Sequence |
(0020,000D) Study Instance UID | 3 | Unique Identifier |
(0008,1110) Referenced Study Sequence | 3 | Sequence |
(0032,1060) Requested Procedure Description | 3 | Long String |
(0032,1064) Requested Procedure Code Sequence | 3 | Sequence |
(0040,1002) Reason for the Requested Procedure | 3 | Long String |
(0040,100A) Reason for Requested Procedure Code Sequence | 3 | Sequence |
(0040,0009) Scheduled Procedure Step ID | 1C | Short String |
(0040,0007) Scheduled Procedure Step Description | 3 | Long String |
(0040,0008) Scheduled Protocol Code Sequence | 3 | Sequence |
Note that some of the contents may be copies of tags that often occur outside the sequence (ex. AccessionNumber, StudyID, StudyInstanceUID, etc.).
In my case, I want to get rid of the entire sequence regardless of its contents. However, because I'm also wanting to Keep some things elsewhere like AccessionNumber, I believe I'm running into a conflict between my Remove and my Keep requests when executed in a single Anonymize. I think Orthanc is opting to honor the Keep over the Remove. So, it keeps the sequence because it contains a copy of AccessionNumber that I indicated I wanted to keep.
You might argue that there is a distinction between AccessionNumber as it appears in the top level of the DICOM tags and when it appears here in 0040-0275 as a copy. But, I suspect Orthanc does not make that distinction - it does not recognize whether it occurs in a sequence or not and labels the whole sequence to be kept in order to preserve the requested Keep.
When I have a chance, I'll try to make a fake DICOM for you to test.
Thanks for the help,
John.