1
1
from math import floor , ceil
2
2
3
3
from neo .core .baseneo import BaseNeo
4
+ from neo .core .imagesequence import ImageSequence
4
5
5
6
6
7
class RegionOfInterest (BaseNeo ):
7
8
"""Abstract base class"""
8
- pass
9
+
10
+ _parent_objects = ('Group' ,)
11
+ _parent_attrs = ('group' ,)
12
+ _necessary_attrs = (
13
+ ('obj' , ('ImageSequence' , ), 1 ),
14
+ )
15
+
16
+ def __init__ (self , image_sequence , name = None , description = None , file_origin = None , ** annotations ):
17
+ super ().__init__ (name = name , description = description ,
18
+ file_origin = file_origin , ** annotations )
19
+
20
+ if not (isinstance (image_sequence , ImageSequence ) or (
21
+ hasattr (image_sequence , "proxy_for" ) and issubclass (image_sequence .proxy_for , ImageSequence ))):
22
+ raise ValueError ("Can only take a RegionOfInterest of an ImageSequence" )
23
+ self .image_sequence = image_sequence
24
+
25
+ def resolve (self ):
26
+ """
27
+ Return a signal from within this region of the underlying ImageSequence.
28
+ """
29
+ return self .image_sequence .signal_from_region (self )
9
30
10
31
11
32
class CircularRegionOfInterest (RegionOfInterest ):
@@ -23,8 +44,9 @@ class CircularRegionOfInterest(RegionOfInterest):
23
44
Radius of the ROI in pixels
24
45
"""
25
46
26
- def __init__ (self , x , y , radius ):
27
-
47
+ def __init__ (self , image_sequence , x , y , radius , name = None , description = None ,
48
+ file_origin = None , ** annotations ):
49
+ super ().__init__ (image_sequence , name , description , file_origin , ** annotations )
28
50
self .y = y
29
51
self .x = x
30
52
self .radius = radius
@@ -72,7 +94,9 @@ class RectangularRegionOfInterest(RegionOfInterest):
72
94
Height (y-direction) of the ROI in pixels
73
95
"""
74
96
75
- def __init__ (self , x , y , width , height ):
97
+ def __init__ (self , image_sequence , x , y , width , height , name = None , description = None ,
98
+ file_origin = None , ** annotations ):
99
+ super ().__init__ (image_sequence , name , description , file_origin , ** annotations )
76
100
self .x = x
77
101
self .y = y
78
102
self .width = width
@@ -115,7 +139,9 @@ class PolygonRegionOfInterest(RegionOfInterest):
115
139
of the vertices of the polygon
116
140
"""
117
141
118
- def __init__ (self , * vertices ):
142
+ def __init__ (self , image_sequence , * vertices , name = None , description = None ,
143
+ file_origin = None , ** annotations ):
144
+ super ().__init__ (image_sequence , name , description , file_origin , ** annotations )
119
145
self .vertices = vertices
120
146
121
147
def polygon_ray_casting (self , bounding_points , bounding_box_positions ):
0 commit comments