.
This commit is contained in:
+18
-1
@@ -1,4 +1,6 @@
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
from rad.settings import REMOTE_URL
|
||||
from django.db.models.fields.files import ImageField
|
||||
from django.db.models.fields.related import ForeignKey
|
||||
@@ -9,6 +11,11 @@ import tagulous
|
||||
import tagulous.models
|
||||
|
||||
|
||||
|
||||
import pydicom
|
||||
import dicognito.anonymizer
|
||||
|
||||
|
||||
from django.core.files.storage import FileSystemStorage
|
||||
from django.conf import settings
|
||||
from django.utils.html import format_html
|
||||
@@ -45,7 +52,6 @@ from generic.models import (
|
||||
from easy_thumbnails.files import get_thumbnailer
|
||||
from easy_thumbnails.exceptions import InvalidImageFormatError
|
||||
|
||||
import pydicom
|
||||
import pydicom.errors
|
||||
import datetime
|
||||
from django.utils import timezone
|
||||
@@ -568,6 +574,17 @@ class Series(models.Model):
|
||||
|
||||
return size
|
||||
|
||||
def anonymise_images(self):
|
||||
anonymizer = dicognito.anonymizer.Anonymizer()
|
||||
|
||||
for series_image in self.images.all():
|
||||
file_path = pathlib.Path(settings.MEDIA_ROOT).joinpath(series_image.image.name)
|
||||
|
||||
with pydicom.dcmread(file_path) as dataset:
|
||||
anonymizer.anonymize(dataset)
|
||||
dataset.save_as(file_path+"ANON")
|
||||
|
||||
|
||||
|
||||
class CaseCollection(models.Model):
|
||||
name = models.CharField(max_length=255, unique=True)
|
||||
|
||||
+2
-1
@@ -22,4 +22,5 @@ django-tinymce
|
||||
django-zipview
|
||||
pymemcache
|
||||
django-autocomplete-light
|
||||
django-querysetsequence
|
||||
django-querysetsequence
|
||||
dicognito
|
||||
Reference in New Issue
Block a user