Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend correlating annotation element bounding boxes #1632

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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