Source: https://github.com/aipoch/medical-research-skills
DICOM Anonymizer
Structured DICOM de-identification support for research preparation workflows.
Quick Check
python -m py_compile scripts/main.py
Audit-Ready Commands
python -m py_compile scripts/main.py
python scripts/main.py --help
python scripts/smoke_test.py
When to Use
- Prepare imaging data for research sharing
- Batch-anonymize DICOM folders while preserving study linkage
- Review whether a workflow still needs manual PHI QA
- Generate audit logs for compliance documentation
Workflow
- Confirm the input type, output target, batch needs, and whether study linkage must be preserved.
- Check whether the request is asking for script execution, audit-log planning, or a manual anonymization checklist.
- Use the packaged script for supported local workflows; if dependencies or files are missing, provide a bounded fallback rather than claiming successful anonymization.
- Return the anonymization plan or result with assumptions, preserved identifiers, and remaining manual QA requirements.
- If the request exceeds supported scope, stop and state the specific boundary.
Parameters
| Parameter |
Type |
Required |
Default |
Description |
--input, -i |
string |
Yes |
- |
Input DICOM file or directory |
--output, -o |
string |
Yes |
- |
Output DICOM file or directory |
--batch, -b |
flag |
No |
false |
Enable directory processing |
--preserve-studies |
flag |
No |
false |
Preserve study linkage with pseudonyms |
--keep-tags |
string |
No |
- |
Comma-separated tags to preserve |
--remove-private |
flag |
No |
true |
Remove private tags |
--audit-log, -a |
string |
No |
- |
Optional JSON audit log path |
--overwrite |
flag |
No |
false |
Allow overwriting output files |
Usage
# Single file
python scripts/main.py --input scan.dcm --output anonymized.dcm
# Batch directory
python scripts/main.py --input ./dicoms/ --output ./anon/ --batch --preserve-studies
# With audit log
python scripts/main.py --input scan.dcm --output anon.dcm --audit-log audit.json
# Keep specific tags
python scripts/main.py --input scan.dcm --output anon.dcm --keep-tags "PatientAge,StudyDate"
Returns
- Anonymized DICOM artifact or bounded execution plan
- Summary of preserved and anonymized identifiers
- Explicit reminder of remaining QA steps before external release
Scope Boundaries
- Supports DICOM de-identification workflows, not legal certification
- Does not remove burned-in image annotations from pixel data
- Does not replace institutional privacy review or release approval
- De-anonymization is not supported: SHA-256 hashing used for PHI values is a one-way operation by design. Original patient data cannot be recovered from anonymized files. If you need to trace back to original data, consult your institutional data governance office before anonymizing.
De-anonymization Requests
If asked to recover original patient data or reverse anonymization, respond:
"Anonymization performed by this tool is irreversible by design. PHI values are replaced using one-way SHA-256 hashing — the original data is not retained by this tool and cannot be recovered. If you need access to the original patient data, contact your institutional data governance or privacy office."
Stress-Case Rules
For complex requests, always include these blocks:
- Assumptions
- Hard Constraints
- Anonymization Path
- Residual PHI Risks
- Manual QA Before Release
Input Validation
This skill accepts requests involving DICOM anonymization, PHI-tag removal, research export preparation, or audit-log planning for medical images.
If the user's request does not involve DICOM de-identification — for example, asking to diagnose from images, convert image formats unrelated to PHI removal, or certify HIPAA compliance — do not proceed with the workflow. Instead respond:
"dicom-anonymizer is designed to support DICOM de-identification workflows for research preparation. Your request appears to be outside this scope. Please provide a DICOM input path and output target, or use a more appropriate tool for your task."
References
- references/phi_tags.json — PHI-related DICOM tags used by the packaged workflow
- references/audit-reference.md — Supported scope, audit commands, and fallback boundaries
Output Requirements
Every final response must include:
- Objective or requested deliverable
- Inputs used and assumptions introduced
- Workflow or decision path
- Core result, recommendation, or artifact
- Constraints, risks, caveats, or validation needs
- Unresolved items and next-step checks
Error Handling
- If required inputs are missing, state exactly which fields are missing and request only the minimum additional information.
- If the task goes outside the documented scope, stop instead of guessing or silently widening the assignment.
- If
scripts/main.py fails, report the failure point, summarize what still can be completed safely, and provide a manual fallback.
- Do not fabricate files, citations, data, search results, or execution outcomes.
Response Template
- Objective
- Inputs Received
- Assumptions
- Workflow
- Deliverable
- Risks and Limits
- Next Checks
1---2name: dicom-anonymizer3description: De-identify DICOM medical images by removing PHI tags for research sharing, with audit logging and study-linkage preservation support.4license: MIT5---6> **Source**: [https://github.com/aipoch/medical-research-skills](https://github.com/aipoch/medical-research-skills)
7
8# DICOM Anonymizer
9
10Structured DICOM de-identification support for research preparation workflows.
11
12## Quick Check
13
14```bash
15python -m py_compile scripts/main.py
16```
17
18## Audit-Ready Commands
19
20```bash
21python -m py_compile scripts/main.py
22python scripts/main.py --help
23python scripts/smoke_test.py
24```
25
26## When to Use
27
28- Prepare imaging data for research sharing
29- Batch-anonymize DICOM folders while preserving study linkage
30- Review whether a workflow still needs manual PHI QA
31- Generate audit logs for compliance documentation
32
33## Workflow
34
351. Confirm the input type, output target, batch needs, and whether study linkage must be preserved.
362. Check whether the request is asking for script execution, audit-log planning, or a manual anonymization checklist.
373. Use the packaged script for supported local workflows; if dependencies or files are missing, provide a bounded fallback rather than claiming successful anonymization.
384. Return the anonymization plan or result with assumptions, preserved identifiers, and remaining manual QA requirements.
395. If the request exceeds supported scope, stop and state the specific boundary.
40
41## Parameters
42
43| Parameter | Type | Required | Default | Description |
44|-----------|------|----------|---------|-------------|
45| `--input`, `-i` | string | Yes | - | Input DICOM file or directory |
46| `--output`, `-o` | string | Yes | - | Output DICOM file or directory |
47| `--batch`, `-b` | flag | No | false | Enable directory processing |
48| `--preserve-studies` | flag | No | false | Preserve study linkage with pseudonyms |
49| `--keep-tags` | string | No | - | Comma-separated tags to preserve |
50| `--remove-private` | flag | No | true | Remove private tags |
51| `--audit-log`, `-a` | string | No | - | Optional JSON audit log path |
52| `--overwrite` | flag | No | false | Allow overwriting output files |
53
54## Usage
55
56```bash
57# Single file
58python scripts/main.py --input scan.dcm --output anonymized.dcm
59
60# Batch directory
61python scripts/main.py --input ./dicoms/ --output ./anon/ --batch --preserve-studies
62
63# With audit log
64python scripts/main.py --input scan.dcm --output anon.dcm --audit-log audit.json
65
66# Keep specific tags
67python scripts/main.py --input scan.dcm --output anon.dcm --keep-tags "PatientAge,StudyDate"
68```
69
70## Returns
71
72- Anonymized DICOM artifact or bounded execution plan
73- Summary of preserved and anonymized identifiers
74- Explicit reminder of remaining QA steps before external release
75
76## Scope Boundaries
77
78- Supports DICOM de-identification workflows, not legal certification
79- Does not remove burned-in image annotations from pixel data
80- Does not replace institutional privacy review or release approval
81- **De-anonymization is not supported:** SHA-256 hashing used for PHI values is a one-way operation by design. Original patient data cannot be recovered from anonymized files. If you need to trace back to original data, consult your institutional data governance office before anonymizing.
82
83## De-anonymization Requests
84
85If asked to recover original patient data or reverse anonymization, respond:
86> "Anonymization performed by this tool is irreversible by design. PHI values are replaced using one-way SHA-256 hashing — the original data is not retained by this tool and cannot be recovered. If you need access to the original patient data, contact your institutional data governance or privacy office."
87
88## Stress-Case Rules
89
90For complex requests, always include these blocks:
91
921. Assumptions
932. Hard Constraints
943. Anonymization Path
954. Residual PHI Risks
965. Manual QA Before Release
97
98## Input Validation
99
100This skill accepts requests involving DICOM anonymization, PHI-tag removal, research export preparation, or audit-log planning for medical images.
101
102If the user's request does not involve DICOM de-identification — for example, asking to diagnose from images, convert image formats unrelated to PHI removal, or certify HIPAA compliance — do not proceed with the workflow. Instead respond:
103> "dicom-anonymizer is designed to support DICOM de-identification workflows for research preparation. Your request appears to be outside this scope. Please provide a DICOM input path and output target, or use a more appropriate tool for your task."
104
105## References
106
107- [references/phi_tags.json](references/phi_tags.json) — PHI-related DICOM tags used by the packaged workflow
108- [references/audit-reference.md](references/audit-reference.md) — Supported scope, audit commands, and fallback boundaries
109
110## Output Requirements
111
112Every final response must include:
113
114- Objective or requested deliverable
115- Inputs used and assumptions introduced
116- Workflow or decision path
117- Core result, recommendation, or artifact
118- Constraints, risks, caveats, or validation needs
119- Unresolved items and next-step checks
120
121## Error Handling
122
123- If required inputs are missing, state exactly which fields are missing and request only the minimum additional information.
124- If the task goes outside the documented scope, stop instead of guessing or silently widening the assignment.
125- If `scripts/main.py` fails, report the failure point, summarize what still can be completed safely, and provide a manual fallback.
126- Do not fabricate files, citations, data, search results, or execution outcomes.
127
128## Response Template
129
1301. Objective
1312. Inputs Received
1323. Assumptions
1334. Workflow
1345. Deliverable
1356. Risks and Limits
1367. Next Checks