Skip to content

Commit

Permalink
Merge pull request #135 from DigitalSlideArchive/more-associated-images
Browse files Browse the repository at this point in the history
Handle more associated images for Aperio and Hamamatsu.
  • Loading branch information
manthey authored Oct 1, 2020
2 parents 5bb666a + 894d6f9 commit e80fb94
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@

## Unreleased

### Improvements
- Handle more associated images for Aperio and Hamamatsu files

### Changes
- Updated the home page (#133, #134)

## Version 1.2.4

### Bug Fixes
- Fix a potential plugin load order issue
- Fix a potential plugin load order issue (#133, #134)

## Version 1.2.3

Expand Down
22 changes: 15 additions & 7 deletions wsi_deid/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,12 +460,19 @@ def redact_format_aperio(item, tempdir, redactList, title, labelImage):
'data'] = thumbnailDescription
# redact other images
for idx in range(len(ifds) - 1, 0, -1):
key = ifds[idx]['tags'].get(tifftools.Tag.ImageDescription.value, {}).get(
ifd = ifds[idx]
key = None
keyparts = ifd['tags'].get(tifftools.Tag.ImageDescription.value, {}).get(
'data', '').split('\n', 1)[-1].strip().split()
if len(key) and key[0].lower():
desc = key[0].lower()
if desc in redactList['images'] or desc == 'label':
ifds.pop(idx)
if len(keyparts) and keyparts[0].lower():
key = keyparts[0].lower()
if (key is None and ifd['tags'].get(tifftools.Tag.NewSubfileType.value) and
ifd['tags'][tifftools.Tag.NewSubfileType.value]['data'][0] &
tifftools.Tag.NewSubfileType.bitfield.Page.value):
key = 'label' if ifd['tags'][
tifftools.Tag.NewSubfileType.value]['data'][0] == 1 else 'macro'
if key in redactList['images'] or key == 'label':
ifds.pop(idx)
# Add back label image
labelPath = os.path.join(tempdir, 'label.tiff')
labelImage.save(labelPath, format='tiff', compression='jpeg', quality=90)
Expand Down Expand Up @@ -506,10 +513,11 @@ def redact_format_hamamatsu(item, tempdir, redactList, title, labelImage):
tiffinfo = tifftools.read_tiff(sourcePath)
ifds = tiffinfo['ifds']
sourceLensTag = tifftools.Tag.NDPI_SOURCELENS.value
if 'macro' in redactList['images']:
for key in redactList['images']:
lensval = {'macro': -1, 'nonempty': -2}
ifds = [ifd for ifd in ifds
if sourceLensTag not in ifd['tags'] or
ifd['tags'][sourceLensTag]['data'][0] > 0]
ifd['tags'][sourceLensTag]['data'][0] != lensval.get(key)]
redact_tiff_tags(ifds, redactList, title)
add_deid_metadata(item, ifds)
propertyTag = tifftools.Tag.NDPI_PROPERTY_MAP.value
Expand Down

0 comments on commit e80fb94

Please sign in to comment.