Skip to content

Commit 3f52bf1

Browse files
committed
Add 'sendOriginal' json option for invertcontrast to send back unmodified images
1 parent b4ce5f2 commit 3f52bf1

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

invertcontrast.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"version": "1.1.0",
33
"parameters": {
4-
"options": ""
4+
"options": "",
5+
"sendOriginal": "False"
56
}
67
}

invertcontrast.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,28 @@ def process_image(imgGroup, connection, config, mrdHeader):
411411

412412
imagesOut[iImg].attribute_string = metaXml
413413

414+
# Send a copy of original (unmodified) images back too
415+
if mrdhelper.get_json_config_param(config, 'sendOriginal', default=False, type='bool') == True:
416+
stack = traceback.extract_stack()
417+
if stack[-2].name == 'process_raw':
418+
logging.warning('sendOriginal is true, but input was raw data, so no original images to return!')
419+
else:
420+
logging.info('Sending a copy of original unmodified images due to sendOriginal set to True')
421+
# In reverse order so that they'll be in correct order as we insert them to the front of the list
422+
for image in reversed(imgGroup):
423+
# Create a copy to not modify the original inputs
424+
tmpImg = image
425+
426+
# Change the series_index to have a different series
427+
tmpImg.image_series_index = 99
428+
429+
# Ensure Keep_image_geometry is set to not reverse image orientation
430+
tmpMeta = ismrmrd.Meta.deserialize(tmpImg.attribute_string)
431+
tmpMeta['Keep_image_geometry'] = 1
432+
tmpImg.attribute_string = tmpMeta.serialize()
433+
434+
imagesOut.insert(0, tmpImg)
435+
414436
return imagesOut
415437

416438
# Create an example ROI <3

0 commit comments

Comments
 (0)