sqed 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d78e636e0c209d3cfd4de9f698bafd575686e1d393fd8148f3ae491d0396d140
4
- data.tar.gz: 51c75913c74ccebe5a172ed64408ce176d5a04d08f788d3be46aeef1a9595e8f
3
+ metadata.gz: e37468a467329ed8396654ad114e2c5977bdbf62570e116e4d90f6ededff622c
4
+ data.tar.gz: a51f2f3e8aae1f3d2e796d36813f9c6b0df93db0cb0d4498e36a61fb7ac03c2c
5
5
  SHA512:
6
- metadata.gz: 459da0e33636600618502410797123154988ce2a03f514cdf7dec9829ca6c747c5d26952ca2b247a613cd8968eb7cb5c0bcc3a6711db495e06175ec64c57da77
7
- data.tar.gz: 49fc0de43216358f44e2d89089a5605ec46a5ef526b6464588ea867301719932433841fd5a071b4cc41ef7ce8013a2eb5ee7f5aaac69786d4e7b46308c0e0f1e
6
+ metadata.gz: 2a2030764dced1506c89f03a4ddf762a1e3941d36254f74fd9d8a0d703b48dbf481efcf938ee24fceb1a5e2263d858fbe2214901dd8a5df816c801b3daa6ca94
7
+ data.tar.gz: d49b6d07f9f59e2d231f11c91d50a13cc720b41d9108b09165d824248d7567e6c86ac1baf16884fc4fddfc3e63ce1125336618c1437ea2849d562288f38f09e6
@@ -1 +1 @@
1
- 2.4.3
1
+ 2.5.1
@@ -32,6 +32,32 @@ class Sqed::BoundaryFinder::ColorLineFinder < Sqed::BoundaryFinder
32
32
  def find_bands
33
33
  case layout # boundaries.coordinates are referenced from stage image
34
34
 
35
+ when :cross # 4 zones, with perfectly intersected horizontal and vertical division
36
+ v = self.class.new(image: @image, layout: :vertical_split, boundary_color: boundary_color, use_thumbnail: false ).boundaries
37
+ h = self.class.new(image: @image, layout: :horizontal_split, boundary_color: boundary_color, use_thumbnail: false).boundaries
38
+
39
+ return if v.nil? || h.nil?
40
+
41
+ boundaries.set(0, [0,0, v.width_for(0), h.height_for(0) ])
42
+ boundaries.set(1, [ v.x_for(1), 0, v.width_for(1), h.height_for(0) ])
43
+ boundaries.set(2, [ v.x_for(1), h.y_for(1), v.width_for(1), h.height_for(1) ])
44
+ boundaries.set(3, [0, h.y_for(1), v.width_for(0), h.height_for(1) ])
45
+
46
+ # No specs for this yet
47
+ when :horizontal_offset_cross
48
+ horizontal = self.class.new(image: @image, layout: :horizontal_split, boundary_color: boundary_color, use_thumbnail: false ).boundaries
49
+
50
+ itop = image.crop(*horizontal.for(0), true)
51
+ ibottom = image.crop(*horizontal.for(1), true)
52
+
53
+ top = self.class.new(image: ilt, layout: :vertical_split, boundary_color: boundary_color, use_thumbnail: false ).boundaries
54
+ bottom = self.class.new(image: irt, layout: :vertical_split, boundary_color: boundary_color, use_thumbnail: false ).boundaries
55
+
56
+ boundaries.set(0, [0, 0, top.width_for(0), top.height_for(0) ])
57
+ boundaries.set(1, [top.x_for(1), 0, top.width_for(1), top.height_for(1) ])
58
+ boundaries.set(2, [bottom.x_for(1), horizontal.y_for(1), bottom.width_for(1), bottom.height_for(1) ])
59
+ boundaries.set(3, [0, horizontal.y_for(1), bottom.width_for(0), bottom.height_for(0) ])
60
+
35
61
  when :lep_stage
36
62
  top_bottom_split = Sqed::BoundaryFinder.color_boundary_finder(image: image, scan: :columns, boundary_color: boundary_color) # detect vertical division [array]
37
63
  left_right_split = Sqed::BoundaryFinder.color_boundary_finder(image: image, sample_subdivision_size: 2, boundary_color: boundary_color) # detect horizontal division [array]
@@ -81,6 +107,16 @@ class Sqed::BoundaryFinder::ColorLineFinder < Sqed::BoundaryFinder
81
107
  bottom_right_left_image.rows - bottom_right_left_split[2]
82
108
  ])
83
109
 
110
+ when :right_t
111
+ vertical = self.class.new(image: @image, layout: :vertical_split, boundary_color: boundary_color, use_thumbnail: false ).boundaries
112
+
113
+ irt = image.crop(*vertical.for(1), true)
114
+ right = self.class.new(image: irt, layout: :horizontal_split, boundary_color: boundary_color, use_thumbnail: false ).boundaries
115
+
116
+ boundaries.set(0, vertical.for(0))
117
+ boundaries.set(1, [ vertical.x_for(1), 0, right.width_for(0), right.height_for(0) ] )
118
+ boundaries.set(2, [ vertical.x_for(1), right.y_for(1), right.width_for(1), right.height_for(1)] )
119
+
84
120
  when :seven_slot
85
121
  top_bottom_split = Sqed::BoundaryFinder.color_boundary_finder(image: image, scan: :columns, boundary_color: boundary_color) # detect vertical division [array]
86
122
  left_right_split = Sqed::BoundaryFinder.color_boundary_finder(image: image, sample_subdivision_size: 2, boundary_color: boundary_color) # detect horizontal division [array]
@@ -112,29 +148,6 @@ class Sqed::BoundaryFinder::ColorLineFinder < Sqed::BoundaryFinder
112
148
 
113
149
  boundaries.set(4, [left_right_split[2], top_bottom_split[2] + right_bottom_split[2], image.columns - left_right_split[2], right_bottom_image.rows ])
114
150
 
115
- when :vertical_split
116
- t = Sqed::BoundaryFinder.color_boundary_finder(image: image, boundary_color: boundary_color) #detect vertical division
117
- return if t.nil?
118
- boundaries.set(0, [0, 0, t[0], image.rows]) # left section of image
119
- boundaries.set(1, [t[2], 0, image.columns - t[2], image.rows]) # right section of image
120
-
121
- when :horizontal_split
122
- t = Sqed::BoundaryFinder.color_boundary_finder(image: image, scan: :columns, boundary_color: boundary_color) # set to detect horizontal division
123
- return if t.nil?
124
-
125
- boundaries.set(0, [0, 0, image.columns, t[0]]) # upper section of image
126
- boundaries.set(1, [0, t[2], image.columns, image.rows - t[2]]) # lower section of image
127
-
128
- when :right_t # only 3 zones expected, with horizontal division in right-side of vertical division
129
- vertical = self.class.new(image: @image, layout: :vertical_split, boundary_color: boundary_color, use_thumbnail: false ).boundaries
130
-
131
- irt = image.crop(*vertical.for(1), true)
132
- right = self.class.new(image: irt, layout: :horizontal_split, boundary_color: boundary_color, use_thumbnail: false ).boundaries
133
-
134
- boundaries.set(0, vertical.for(0))
135
- boundaries.set(1, [ vertical.x_for(1), 0, right.width_for(0), right.height_for(0) ] )
136
- boundaries.set(2, [ vertical.x_for(1), right.y_for(1), right.width_for(1), right.height_for(1)] )
137
-
138
151
  when :vertical_offset_cross # 4 zones expected, with (varying) horizontal division in left- and right- sides of vertical division
139
152
  vertical = self.class.new(image: @image, layout: :vertical_split, boundary_color: boundary_color, use_thumbnail: false).boundaries
140
153
 
@@ -149,31 +162,20 @@ class Sqed::BoundaryFinder::ColorLineFinder < Sqed::BoundaryFinder
149
162
  boundaries.set(2, [vertical.x_for(1), right.y_for(1), right.width_for(1), right.height_for(1) ])
150
163
  boundaries.set(3, [0, left.y_for(1), left.width_for(1), left.height_for(1) ])
151
164
 
152
- # No specs for this yet
153
- when :horizontal_offset_cross
154
- horizontal = self.class.new(image: @image, layout: :horizontal_split, boundary_color: boundary_color, use_thumbnail: false ).boundaries
155
-
156
- itop = image.crop(*horizontal.for(0), true)
157
- ibottom = image.crop(*horizontal.for(1), true)
158
-
159
- top = self.class.new(image: ilt, layout: :vertical_split, boundary_color: boundary_color, use_thumbnail: false ).boundaries
160
- bottom = self.class.new(image: irt, layout: :vertical_split, boundary_color: boundary_color, use_thumbnail: false ).boundaries
165
+ when :vertical_split
166
+ t = Sqed::BoundaryFinder.color_boundary_finder(image: image, boundary_color: boundary_color) #detect vertical division
167
+ return if t.nil?
168
+ boundaries.set(0, [0, 0, t[0], image.rows]) # left section of image
169
+ boundaries.set(1, [t[2], 0, image.columns - t[2], image.rows]) # right section of image
161
170
 
162
- boundaries.set(0, [0, 0, top.width_for(0), top.height_for(0) ])
163
- boundaries.set(1, [top.x_for(1), 0, top.width_for(1), top.height_for(1) ])
164
- boundaries.set(2, [bottom.x_for(1), horizontal.y_for(1), bottom.width_for(1), bottom.height_for(1) ])
165
- boundaries.set(3, [0, horizontal.y_for(1), bottom.width_for(0), bottom.height_for(0) ])
171
+ when :horizontal_split
172
+ t = Sqed::BoundaryFinder.color_boundary_finder(image: image, scan: :columns, boundary_color: boundary_color) # set to detect horizontal division
173
+ return if t.nil?
166
174
 
167
- when :cross # 4 zones, with perfectly intersected horizontal and vertical division
168
- v = self.class.new(image: @image, layout: :vertical_split, boundary_color: boundary_color, use_thumbnail: false ).boundaries
169
- h = self.class.new(image: @image, layout: :horizontal_split, boundary_color: boundary_color, use_thumbnail: false).boundaries
175
+ boundaries.set(0, [0, 0, image.columns, t[0]]) # upper section of image
176
+ boundaries.set(1, [0, t[2], image.columns, image.rows - t[2]]) # lower section of image
170
177
 
171
- return if v.nil? || h.nil?
172
178
 
173
- boundaries.set(0, [0,0, v.width_for(0), h.height_for(0) ])
174
- boundaries.set(1, [ v.x_for(1), 0, v.width_for(1), h.height_for(0) ])
175
- boundaries.set(2, [ v.x_for(1), h.y_for(1), v.width_for(1), h.height_for(1) ])
176
- boundaries.set(3, [0, h.y_for(1), v.width_for(0), h.height_for(1) ])
177
179
 
178
180
  else # no @layout provided !?
179
181
 
@@ -1,3 +1,3 @@
1
1
  class Sqed
2
- VERSION = '0.5.0'.freeze
2
+ VERSION = '0.5.1'.freeze
3
3
  end
@@ -21,42 +21,33 @@ module SqedConfig
21
21
  # in a clockwise position. For example:
22
22
  #
23
23
  # 0 | 1
24
- # ----|---- :equal_cross (always perfectly divided through the center)
25
- # 3 | 2
26
- #
27
- #
28
- # 0 | 1
29
- # ----|---- :cross - height of [0, 1], [2,3] same, width of [0,1], [2,3] same, otherwise variable, i.e. height(0) != height(3)
24
+ # ----|---- :cross (any cross pattern)
30
25
  # |
31
26
  # 3 | 2
32
- #
27
+ #
33
28
  #
34
29
  # 0 | 1
35
30
  # |
36
31
  # --------- :horizontal_offset_cross
37
- # 3 | 2
32
+ # 3 | 2
33
+ #
38
34
  #
35
+ # 0
36
+ # -------- :horizontal_split
37
+ # 1
38
+ #
39
+ #
40
+ # 0 | 1 | 2
41
+ # ------------
42
+ # | 5 | :lep_stage
43
+ # 6 |---- 3
44
+ # | 4 |
39
45
  #
40
- # 0 | 1
41
- # |____
42
- # ----| :vertical_offset_cross
43
- # 3 | 2
44
46
  #
45
47
  # | 1
46
48
  # 0 |---- :right_t
47
49
  # | 2
48
50
  #
49
- # 0
50
- # -------- :horizontal_split
51
- # 1
52
- #
53
- # |
54
- # 0 | 1 :vertical_split
55
- # |
56
- #
57
- # -----
58
- # | 0 | :internal_box
59
- # -----
60
51
  #
61
52
  # 0 | 1 | 2
62
53
  # ------------
@@ -64,25 +55,33 @@ module SqedConfig
64
55
  # 6 |--------
65
56
  # | 4
66
57
  #
67
- # 0 | 1 | 2
68
- # ------------
69
- # | 5 | :lep_stage
70
- # 6 |---- 3
71
- # | 4 |
58
+ #
59
+ # 0 | 1
60
+ # |____
61
+ # ----| :vertical_offset_cross
62
+ # 3 | 2
63
+ #
72
64
  #
65
+ # |
66
+ # 0 | 1 :vertical_split
67
+ # |
68
+ #
69
+ # -----
70
+ # | 0 | :internal_box
71
+ # -----
72
+ #
73
73
  # Hash values are used to stub out
74
74
  # the Sqed::Boundaries instance.
75
- # TODO: deprecate for simpler breakdown (cross, split, t)
76
75
  LAYOUTS = {
77
76
  cross: [0, 1, 2, 3],
78
- vertical_offset_cross: [0, 1, 2, 3],
77
+ horizontal_offset_cross: [0, 1, 2, 3],
79
78
  horizontal_split: [0, 1],
80
- vertical_split: [0, 1],
79
+ lep_stage: [0, 1, 2, 3, 4, 5, 6],
81
80
  right_t: [0, 1, 2],
82
- left_t: [0, 1, 2],
83
- internal_box: [0],
84
81
  seven_slot: [0, 1, 2, 3, 4, 5, 6],
85
- lep_stage: [0, 1, 2, 3, 4, 5, 6]
82
+ vertical_offset_cross: [0, 1, 2, 3],
83
+ vertical_split: [0, 1],
84
+ internal_box: [0]
86
85
  }.freeze
87
86
 
88
87
  # Each element of the layout is a "section".
@@ -116,34 +115,40 @@ module SqedConfig
116
115
  }.freeze
117
116
 
118
117
  EXTRACTION_PATTERNS = {
119
- right_t: {
118
+ cross: {
120
119
  boundary_finder: Sqed::BoundaryFinder::ColorLineFinder,
121
- layout: :right_t,
122
- metadata_map: { 0 => :annotated_specimen, 1 => :identifier, 2 => :image_registration }
120
+ layout: :cross,
121
+ metadata_map: { 0 => :curator_metadata, 1 => :identifier, 2 => :image_registration, 3 => :annotated_specimen }
123
122
  },
124
123
 
125
- vertical_offset_cross: {
124
+ horizontal_split: {
126
125
  boundary_finder: Sqed::BoundaryFinder::ColorLineFinder,
127
- layout: :vertical_offset_cross,
128
- metadata_map: { 0 => :curator_metadata, 1 => :identifier, 2 => :image_registration, 3 => :annotated_specimen }
126
+ layout: :horizontal_split,
127
+ metadata_map: { 0 => :annotated_specimen, 1 => :identifier }
129
128
  },
130
129
 
131
- equal_cross: {
132
- boundary_finder: Sqed::BoundaryFinder::CrossFinder,
133
- layout: :equal_cross,
130
+ horizontal_offset_cross: {
131
+ boundary_finder: Sqed::BoundaryFinder::ColorLineFinder,
132
+ layout: :horizontal_offset_cross,
134
133
  metadata_map: { 0 => :curator_metadata, 1 => :identifier, 2 => :image_registration, 3 => :annotated_specimen }
135
134
  },
136
135
 
137
- cross: {
136
+ lep_stage: {
138
137
  boundary_finder: Sqed::BoundaryFinder::ColorLineFinder,
139
- layout: :cross,
140
- metadata_map: { 0 => :curator_metadata, 1 => :identifier, 2 => :image_registration, 3 => :annotated_specimen }
138
+ layout: :lep_stage,
139
+ metadata_map: { 0 => :curator_metadata, 1 => :collecting_event_labels, 2 => :image_registration, 3 => :identifier, 4 => :other_labels, 5 => :determination_labels, 6 => :specimen }
140
+ },
141
+
142
+ right_t: {
143
+ boundary_finder: Sqed::BoundaryFinder::ColorLineFinder,
144
+ layout: :right_t,
145
+ metadata_map: { 0 => :annotated_specimen, 1 => :identifier, 2 => :image_registration }
141
146
  },
142
147
 
143
148
  stage: {
144
149
  boundary_finder: Sqed::BoundaryFinder::StageFinder,
145
150
  layout: :internal_box,
146
- metadata_map: { 0 => :stage}
151
+ metadata_map: { 0 => :stage }
147
152
  },
148
153
 
149
154
  seven_slot: {
@@ -152,14 +157,19 @@ module SqedConfig
152
157
  metadata_map: { 0 => :collecting_event_labels, 1 => :determination_labels, 2 => :other_labels, 3 => :image_registration, 4 => :curator_metadata, 5 => :identifier, 6 => :specimen }
153
158
  },
154
159
 
155
- lep_stage: {
160
+ vertical_offset_cross: {
156
161
  boundary_finder: Sqed::BoundaryFinder::ColorLineFinder,
157
- layout: :lep_stage,
158
- metadata_map: { 0 => :curator_metadata, 1 => :collecting_event_labels, 2 => :image_registration, 3 => :identifier, 4 => :other_labels, 5 => :determination_labels, 6 => :specimen }
162
+ layout: :vertical_offset_cross,
163
+ metadata_map: { 0 => :curator_metadata, 1 => :identifier, 2 => :image_registration, 3 => :annotated_specimen }
164
+ },
165
+
166
+ vertical_split: {
167
+ boundary_finder: Sqed::BoundaryFinder::ColorLineFinder,
168
+ layout: :vertical_split,
169
+ metadata_map: { 0 => :annotated_specimen, 1 => :identifier }
159
170
  }
160
171
  }.freeze
161
172
 
162
-
163
173
  BOUNDARY_COLORS = [:red, :green, :blue, :black].freeze
164
174
 
165
175
  DEFAULT_TMP_DIR = '/tmp'.freeze
@@ -168,14 +178,14 @@ module SqedConfig
168
178
  EXTRACTION_PATTERNS[pattern][:metadata_map].invert[section_type]
169
179
  end
170
180
 
171
- # Format to return JSON
181
+ # Format to return JSON that is externaly exposed
172
182
  def self.metadata
173
183
  return {
174
184
  boundary_colors: BOUNDARY_COLORS,
175
- extraction_patterns: EXTRACTION_PATTERNS,
185
+ extraction_patterns: EXTRACTION_PATTERNS.select{|k,v| k != :stage},
176
186
  section_parsers: SECTION_PARSERS,
177
187
  layout_section_types: LAYOUT_SECTION_TYPES,
178
- layouts: LAYOUTS
188
+ layouts: LAYOUTS.select{|k,v| k != :internal_box }
179
189
  }
180
190
  end
181
191
  end
@@ -6,4 +6,14 @@ describe SqedConfig do
6
6
  expect(SqedConfig.metadata.keys).to contain_exactly(:boundary_colors, :extraction_patterns, :section_parsers, :layout_section_types, :layouts)
7
7
  end
8
8
 
9
+ specify 'layouts' do
10
+ expect(SqedConfig.metadata[:layouts].keys).to contain_exactly(:cross, :horizontal_offset_cross, :horizontal_split, :lep_stage, :right_t, :seven_slot, :vertical_offset_cross, :vertical_split)
11
+ end
12
+
13
+ specify 'layouts are in patterns' do
14
+ expect(SqedConfig.metadata[:layouts].keys + [:stage]).to contain_exactly(*SqedConfig::EXTRACTION_PATTERNS.keys)
15
+ end
16
+
17
+
18
+
9
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Yoder
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-02-06 00:00:00.000000000 Z
12
+ date: 2019-02-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -208,7 +208,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
208
  - !ruby/object:Gem::Version
209
209
  version: '0'
210
210
  requirements: []
211
- rubygems_version: 3.0.2
211
+ rubyforge_project:
212
+ rubygems_version: 2.7.8
212
213
  signing_key:
213
214
  specification_version: 4
214
215
  summary: Specimens Quickly extracted and Digitized, or just "squid". A ruby gem for