Import CTP rules#
If your site already redacts burned-in text with the RSNA Clinical Trial
Processor (CTP), you have a DicomPixelAnonymizer.script. That script holds
the pixel regions you trust for each machine. Isocenter can convert the script
into rules. You then copy the rules into a configuration’s machines: list.
Convert the script#
python -m isocenter.utils.ctp_parser /path/to/DicomPixelAnonymizer.script ctp_rules.yaml
It prints Successfully converted N rules to ctp_rules.yaml. For a script
block such as
GE LOGIQ ultrasound banner
{ Manufacturer.containsIgnoreCase("GE") * ManufacturerModelName.containsIgnoreCase("LOGIQ E9") }
(0,0,640,40)
the output is
rules:
- manufacturer: GE
model_name: LOGIQ E9
comment: 'Imported from CTP. Condition: Manufacturer.containsIgnoreCase("GE") *
ManufacturerModelName.containsIgnoreCase("LOGIQ E9")'
redaction_zones:
- - 0
- 40
- 0
- 640
What the converter reads:
One rule per block that meets two conditions. The block’s condition names a
Manufactureror aManufacturerModelNamewithcontainsIgnoreCase. At least one(x,y,w,h)region follows the condition. The converter skips any other block, so the count it prints can be lower than the number of blocks in the script. The converter does not read other conditions in a block (Rows.equals(...),CommentsOnRadiationDose...). They survive only in thecomment.Coordinates are converted. CTP writes
(x, y, width, height). Isocenter zones are[row_start, row_end, col_start, col_end]in pixels. So(x,y,w,h)becomes[y, y+h, x, x+w].No serial number. CTP matches a manufacturer and model. The imported rule carries no selector. A block with a manufacturer but no model gets
model_name: Unknown. Add aserial_number. Or replace the labels with amatch:that names the manufacturer and model exactly as the files spell them. CTP’scontainsIgnoreCaseis not exact.
Use the rules in a configuration#
The output is a rule list, not a configuration. load_config() refuses it
with ValueError: ...: unknown key 'rules' at the top level. Copy each rule
you want into the machines: list of your configuration. Then add the
serial_number of the machine that the rule is for:
machines:
- serial_number: "US12345"
manufacturer: GE
model_name: LOGIQ E9
comment: 'Imported from CTP.'
redaction_zones:
- - 0
- 40
- 0
- 640
Quote the serial number. Give one entry per machine. Two scanners of the same model are two entries with the same zones. Before you rely on the zones, check them against your own images. See Pixel Redaction (Machines) and Burned-in text (OCR).
The built-in CTP knowledge base#
create_config() already knows the rules from CTP’s published script. For
each machine in your data, it does these steps:
It looks for an exact serial number in its own knowledge base.
Then it looks for a CTP rule whose manufacturer and model are both contained in the machine’s, ignoring case.
It writes the zones it finds into the new configuration, with a comment that names the source.
You need the converter only for a script that your site wrote or changed.