11from math import floor , ceil
22
33from neo .core .baseneo import BaseNeo
4+ from neo .core .imagesequence import ImageSequence
45
56
67class RegionOfInterest (BaseNeo ):
78 """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 )
930
1031
1132class CircularRegionOfInterest (RegionOfInterest ):
@@ -23,8 +44,9 @@ class CircularRegionOfInterest(RegionOfInterest):
2344 Radius of the ROI in pixels
2445 """
2546
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 )
2850 self .y = y
2951 self .x = x
3052 self .radius = radius
@@ -72,7 +94,9 @@ class RectangularRegionOfInterest(RegionOfInterest):
7294 Height (y-direction) of the ROI in pixels
7395 """
7496
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 )
76100 self .x = x
77101 self .y = y
78102 self .width = width
@@ -115,7 +139,9 @@ class PolygonRegionOfInterest(RegionOfInterest):
115139 of the vertices of the polygon
116140 """
117141
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 )
119145 self .vertices = vertices
120146
121147 def polygon_ray_casting (self , bounding_points , bounding_box_positions ):
0 commit comments