Skip to content

Commit

Permalink
Merge pull request #1632 from girder/plottable-bbox
Browse files Browse the repository at this point in the history
Extend correlating annotation element bounding boxes
  • Loading branch information
manthey authored Sep 10, 2024
2 parents 4c3abb4 + 7adcd96 commit 01d4284
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
### Bug Fixes

- Fix scaling small images in the multi source with bicubic smoothing ([#1627](../../pull/1627))
- Fix correlating annotation bounding boxes on adjacent items for plottable data ([#1628](../../pull/1628))
- Fix correlating annotation bounding boxes on adjacent items for plottable data ([#1628](../../pull/1628), ([#1632](../../pull/1632))

## 1.29.7

Expand Down
16 changes: 12 additions & 4 deletions girder_annotation/girder_large_image_annotation/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,8 +780,7 @@ def _keysToColumns(self, columns, parts, doctype, getData, selector, length):
if len(cols) == 4:
# If we load all of these from annotation elements, use all
# three keys:
# for akey in {'annotation.id', 'annotation.name', 'annotationelement.id'}:
for akey in {'annotationelement.id'}:
for akey in {'annotation.id', 'annotation.name', 'annotationelement.id'}:
if self._datacolumns and akey in self._datacolumns:
self._requiredColumns.add(akey)
self._ensureColumn(
Expand Down Expand Up @@ -1014,6 +1013,10 @@ def _collectColumns(self, columns, recordlist, doctype, first=True, iid='', aid=
lambda record, data, row: record['label']['value'])
self._commonColumn(columns, 'annotationelement.type', doctype, getData,
lambda record, data, row: record['type'])
self._commonColumn(columns, 'annotation.id', doctype, getData,
lambda record, data, row: str(record['_aid']))
self._commonColumn(columns, 'annotation.name', doctype, getData,
lambda record, data, row: str(record['_aname']))
self._commonColumn(columns, 'bbox.x0', doctype, getData,
lambda record, data, row: record['_bbox']['lowx'])
self._commonColumn(columns, 'bbox.y0', doctype, getData,
Expand Down Expand Up @@ -1054,6 +1057,8 @@ def _getColumnsFromAnnotations(self, columns):
if ((not self._sources or 'annotationelement' in self._sources) and
Annotationelement().countElements(annot) <= self.maxAnnotationElements):
for element in Annotationelement().yieldElements(annot, bbox=True):
element['_aid'] = annot['_id']
element['_aname'] = annot['annotation']['name']
count += self._collectColumns(
columns, [element], 'annotationelement', iid=iid, aid=str(annot['_id']))
if not iidx:
Expand Down Expand Up @@ -1141,15 +1146,18 @@ def computeSelectorAxis(record, data, row):
return 0
rows = {}
cols = sorted({col for col in self._compute['columns'] if col in self._datacolumns})
for kidx, key in enumerate(cols):
lencols = len(cols)
needcols = cols + sorted(set(self._requiredColumns) - set(cols) - self.computeColumns)
for kidx, key in enumerate(needcols):
for row, value in self._datacolumns[key].items():
if not kidx:
rows[row] = [value]
elif row in rows and len(rows[row]) == kidx:
rows[row].append(value)
rows = {k: row for k, row in rows.items() if len(row) == len(cols)}
rows = {k: row for k, row in rows.items() if len(row) == len(needcols)}
if not len(rows):
return 0
rows = {k: row[:lencols] for k, row in rows.items()}
if not self._computeFunction(rows):
return 0
for key in self.computeColumns:
Expand Down

0 comments on commit 01d4284

Please sign in to comment.