feat: Add DICOM tag consistency analysis with dynamic loading in series viewer

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Ross
2026-04-30 22:01:54 +01:00
co-authored by Copilot
parent 6574c29a70
commit 859042bf96
4 changed files with 205 additions and 0 deletions
@@ -0,0 +1,107 @@
{% load django_htmx %}
<div id="series-tag-consistency-panel" class="d-flex flex-column gap-2">
<div class="d-flex flex-wrap gap-2 align-items-center">
<button type="button"
class="btn btn-outline-info btn-sm"
hx-get="{% url 'atlas:series_tag_consistency' pk=series.pk %}?analyze=1"
hx-target="#series-tag-consistency-panel"
hx-swap="outerHTML">
Analyze tag consistency
</button>
{% if analyze_requested %}
<span class="small text-muted">Scanned {{ image_count }} image{{ image_count|pluralize }}</span>
{% endif %}
</div>
{% if analyze_requested %}
<div class="small d-flex flex-wrap gap-2">
<span class="badge text-bg-success">Same: {{ same_tags|length }}</span>
<span class="badge text-bg-warning">Different: {{ different_tags|length }}</span>
<span class="badge text-bg-secondary">Missing in some: {{ partial_tags|length }}</span>
</div>
<details class="styled-detail" open>
<summary>Different tags (highlighted)</summary>
<div class="table-responsive mt-2">
<table class="table table-sm table-striped align-middle mb-0">
<thead>
<tr>
<th>Tag</th>
<th>Unique values</th>
<th>Sample values</th>
</tr>
</thead>
<tbody>
{% for row in different_tags %}
<tr class="table-warning">
<td>{{ row.tag_name }}</td>
<td>{{ row.unique_count }}</td>
<td>{{ row.sample_values|join:", " }}</td>
</tr>
{% empty %}
<tr>
<td colspan="3" class="text-muted">No tags vary across all images.</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</details>
<details class="styled-detail">
<summary>Same tags</summary>
<div class="table-responsive mt-2">
<table class="table table-sm table-striped align-middle mb-0">
<thead>
<tr>
<th>Tag</th>
<th>Value</th>
</tr>
</thead>
<tbody>
{% for row in same_tags %}
<tr class="table-success">
<td>{{ row.tag_name }}</td>
<td>{{ row.sample_values.0 }}</td>
</tr>
{% empty %}
<tr>
<td colspan="2" class="text-muted">No uniform tags found across all images.</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</details>
<details class="styled-detail">
<summary>Missing in some images</summary>
<div class="table-responsive mt-2">
<table class="table table-sm table-striped align-middle mb-0">
<thead>
<tr>
<th>Tag</th>
<th>Present in</th>
<th>Unique values</th>
</tr>
</thead>
<tbody>
{% for row in partial_tags %}
<tr class="table-secondary">
<td>{{ row.tag_name }}</td>
<td>{{ row.present_count }}/{{ image_count }}</td>
<td>{{ row.unique_count }}</td>
</tr>
{% empty %}
<tr>
<td colspan="3" class="text-muted">All scanned tags were present in every image.</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</details>
{% else %}
<p class="small text-muted mb-0">Run analysis to quickly highlight tags that are the same or different across the series.</p>
{% endif %}
</div>
+5
View File
@@ -195,6 +195,11 @@
hx-swap="outerHTML">
<span class="text-muted small">Loading split controls…</span>
</div>
<div hx-get="{% url 'atlas:series_tag_consistency' pk=series.pk %}"
hx-trigger="load"
hx-swap="outerHTML">
<span class="text-muted small">Loading tag analysis controls...</span>
</div>
</div>
</div>