Skip to content

Commit

Permalink
ENH: Cell Locator 0.2.0
Browse files Browse the repository at this point in the history
- Update slicer-application-properties.cmake
- Update current version in CHANGES.md
- Update the current annotation file format version to match release.
    - Add corresponding converter to the file conversion script.
    - Add entry to AnnotationFileFormat.md
  • Loading branch information
allemangD committed Aug 12, 2021
1 parent e7df7fa commit c2b8c6b
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set(VERSION_MAJOR
0
)
set(VERSION_MINOR
1
2
)
set(VERSION_PATCH
0
Expand Down
8 changes: 8 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

Features:

Fixes:

Documentation:

## Cell Locator 0.2.0 2021-08-12

Features:

- Created script to convert between Cell Locator file formats. [#181](https://github.com/BICCN/cell-locator/pull/181), [#182](https://github.com/BICCN/cell-locator/pull/182)

Fixes:
Expand Down
4 changes: 4 additions & 0 deletions Documentation/developer_guide/AnnotationFileFormat.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ We mean it.

## Versions

## 0.2.0 (2021-08-11)

Unchanged from 0.1.1; this version synchronizes the file format and cell locator release.

## 0.1.1 (2021-06-11)

Removed the `"measurements"` key from markups.
Expand Down
2 changes: 1 addition & 1 deletion Modules/Scripted/Home/Home.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def setMetadata(self, data):
class AnnotationManager:
"""Manage serialization and bookkeeping for a collection of annotations."""

FORMAT_VERSION = '0.1.1+2021.06.11'
FORMAT_VERSION = '0.2.0+2021.08.12'

DefaultReferenceView = 'Coronal'
DefaultOntology = 'Structure'
Expand Down
1 change: 1 addition & 0 deletions Scripts/convert/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

# most-recent versions first
version_order = [
'v0.2.0+2021.08.12',
'v0.1.1+2021.06.11',
'v0.1.0+2020.09.18',
'v0.0.0+2020.08.26',
Expand Down
73 changes: 73 additions & 0 deletions Scripts/convert/versions/v0.2.0+2021.08.12.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import model


class Converter(model.Converter):
@classmethod
def normalize(cls, data: dict):
doc = model.Document()
doc.current_id = data['currentId']
doc.reference_view = data['referenceView']
doc.ontology = data['ontology']
doc.stepSize = data['stepSize']
doc.camera_position = tuple(data['cameraPosition'])
doc.camera_view_up = tuple(data['cameraViewUp'])

for dann in data['markups']:
dmark = dann['markup']

ann = model.Annotation()
ann.name = dann['name']
ann.orientation = dann['orientation']
ann.markup_type = dmark['type']

if ann.markup_type == 'ClosedCurve':
ann.representation_type = dann['representationType']
ann.thickness = dann['thickness']

ann.coordinate_system = dmark['coordinateSystem']
if 'coordinateUnits' in dmark:
ann.coordinate_units = dmark['coordinateUnits']

for point in dmark['controlPoints']:
ann.points.append(tuple(point['position']))

doc.annotations.append(ann)

return doc

@classmethod
@model.versioned
def specialize(cls, doc: model.Document):
data = dict()
data['markups'] = [
{
'markup': {
'type': ann.markup_type,
'coordinateSystem': ann.coordinate_system,
'coordinateUnits': ann.coordinate_units,
'controlPoints': [
{
'id': str(i),
'position': pt,
'orientation': [-1.0, -0.0, -0.0,
-0.0, -1.0, -0.0,
+0.0, +0.0, +1.0]
}
for i, pt in enumerate(ann.points, start=1)
],
},
'name': ann.name,
'orientation': ann.orientation,
'representationType': ann.representation_type,
'thickness': ann.thickness
}
for ann in doc.annotations
]
data['currentId'] = doc.current_id
data['referenceView'] = doc.reference_view
data['ontology'] = doc.ontology
data['stepSize'] = doc.stepSize
data['cameraPosition'] = doc.camera_position
data['cameraViewUp'] = doc.camera_view_up

return data

0 comments on commit c2b8c6b

Please sign in to comment.