Skip to content

Commit

Permalink
missing Images key
Browse files Browse the repository at this point in the history
  • Loading branch information
vsoch committed Oct 31, 2017
1 parent eb57c5b commit 900a57f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
7 changes: 2 additions & 5 deletions sendit/apps/main/tasks/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ def import_dicomdir(dicom_dir, run_get_identifiers=True):
series_id = dcm.get('SeriesNumber')
if series_id not in all_series:
all_series.append(series_id)

if study_date not in study_dates:
study_dates[study_date] = 0
study_dates[study_date] += 1
Expand All @@ -141,7 +140,6 @@ def import_dicomdir(dicom_dir, run_get_identifiers=True):
message = "%s is flagged in %s: %s, skipping" %(dicom_uid,
flag_group,
reason)

batch = add_batch_warning(message,batch,quiet=True)
message = "BurnedInAnnotation found for batch %s" %batch.uid
if message not in messages:
Expand All @@ -155,13 +153,12 @@ def import_dicomdir(dicom_dir, run_get_identifiers=True):

# Series Number and count of slices (images)
if series_id is not None and series_id not in series:
series[series_id] = {'SeriesNumber': series_id }

series[series_id] = {'SeriesNumber': series_id,
'Images':1 }
# Series Description
description = dcm.get('SeriesDescription')
if dcm.get('SeriesDescription') is not None:
series[series_id]['SeriesDescription'] = description

else:
series[series_id]['Images'] +=1

Expand Down
10 changes: 1 addition & 9 deletions sendit/apps/main/tasks/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

from django.conf import settings
import os
import time
from copy import deepcopy

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sendit.settings')
Expand Down Expand Up @@ -108,7 +109,6 @@ def replace_identifiers(bid, run_upload_storage=False):
'''

batch.qa['ProcessStartTime'] = time.time()

batch = Batch.objects.get(id=bid)
batch_ids = BatchIdentifiers.objects.get(batch=batch)

Expand All @@ -125,12 +125,10 @@ def replace_identifiers(bid, run_upload_storage=False):
cleaned = clean_identifiers(ids=updated,
default="KEEP",
deid=deid)

# Save progress
batch_ids.cleaned = cleaned
batch_ids.updated = updated
batch_ids.save()

# Get updated files
dicom_files = batch.get_image_paths()
output_folder = batch.get_path()
Expand All @@ -142,7 +140,6 @@ def replace_identifiers(bid, run_upload_storage=False):
strip_sequences=True,
remove_private=True) # force = True
# save = True,

# Get shared information
aggregate = ["BodyPartExamined", "Modality", "StudyDescription"]
shared_ids = get_shared_identifiers(dicom_files=updated_files,
Expand All @@ -158,24 +155,19 @@ def replace_identifiers(bid, run_upload_storage=False):

# S6M0<MRN-SUID>_<JITTERED-REPORT-DATE>_<ACCESSIONNUMBER-SUID>
# Rename the dicom based on suid

if item_id in updated:
item_suid = updated[item_id]['item_id']
dcm = dcm.rename(item_suid) # added to [prefix][dcm.name]
dcm.save()

# If we don't have the id, don't risk uploading
else:
message = "%s for Image Id %s file read error: skipping." %(item_id, dcm.id)
batch = add_batch_error(message,batch)
dcm.delete()


except:
message = "%s for Image Id %s not found in lookup: skipping." %(item_id, dcm.id)
batch = add_batch_error(message,batch)
dcm.delete()

batch.qa['ProcessFinishTime'] = time.time()

# We don't get here if the call above failed
Expand Down

0 comments on commit 900a57f

Please sign in to comment.