Commit 52597db
authored
refactor: optimize KEEP action performance by caching field contenders & fix SyntaxWarning for invalid escape sequences (#295)
* refactor: optimize KEEP action performance by caching field contenders
When multiple KEEP actions are present in a deid recipe, the
`expand_field_expression` function was internally calling
`get_fields_with_lookup(dicom)` for each KEEP action. This function
iterates through all DICOM fields and builds lookup tables, which is
an expensive operation.
This commit modifies the `keep` property to build the field contenders
once on the first KEEP action and pass it explicitly to all subsequent
`expand_field_expression` calls via the `contenders` parameter. This
avoids redundant field enumeration and lookup table construction.
This optimization significantly reduces processing time for recipes
with multiple KEEP actions, especially for DICOM files with many
fields or nested sequences.
* fix: resolve SyntaxWarning for invalid escape sequences
Convert regex patterns to raw strings (r"") in config/utils.py to
eliminate SyntaxWarning about invalid escape sequences.
This follows Python best practices for regular expressions and avoids potential issues with
escape sequences.1 parent 0609cf2 commit 52597db
4 files changed
+13
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
| 133 | + | |
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
222 | | - | |
| 222 | + | |
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
320 | 320 | | |
321 | 321 | | |
322 | 322 | | |
| 323 | + | |
| 324 | + | |
323 | 325 | | |
324 | 326 | | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
325 | 331 | | |
326 | | - | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
327 | 335 | | |
328 | 336 | | |
329 | 337 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
0 commit comments