cicada 0.9.0-java → 0.9.1-java

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.
@@ -293,7 +293,7 @@ module Cicada
293
293
  y = fp.getPosition(ImageCoordinate::Y)
294
294
  z = fp.getPosition(ImageCoordinate::Z)
295
295
 
296
- ok = (range_x.include?(x) and range_y.include?(y) and range_z.include?(z))
296
+ ok = (range_x.include?(x) and range_y.include?(y) and (range_z.include?(z) or toCheck.getParent.getDimensionSizes[:z] == 1))
297
297
 
298
298
  unless ok then
299
299
 
@@ -538,6 +538,7 @@ module Cicada
538
538
  FileInteraction.write_position_data(image_objects, @parameters)
539
539
 
540
540
  pc = PositionCorrector.new(@parameters)
541
+ pc.logger= @logger
541
542
 
542
543
  c = pc.generate_correction(image_objects)
543
544
 
@@ -545,7 +546,7 @@ module Cicada
545
546
 
546
547
  if @parameters[:determine_tre] and @parameters[:determine_correction] then
547
548
 
548
- puts "calculating tre"
549
+ self.logger.info("calculating tre")
549
550
 
550
551
  tre = pc.determine_tre(image_objects)
551
552
 
@@ -117,46 +117,69 @@ module Cicada
117
117
 
118
118
  end
119
119
 
120
+
120
121
  ##
121
- # Writes the correction to a string in XML format
122
- #
123
- # @return [String] the correction data encoded as XML
122
+ # Writes all the points used for correction to XML within a supplied correction
123
+ # XML element
124
124
  #
125
- def write_to_xml
126
-
127
- doc = REXML::Document.new
125
+ # @param [REXML::Element] correction_element the XML element representing the correction
126
+ #
127
+ # @return [void]
128
+ #
129
+ def write_all_correction_point_xml(correction_element)
128
130
 
129
- ce = doc.add_element XML_STRINGS[:correction_element]
131
+ @distance_cutoffs.each_with_index do |e,i|
130
132
 
131
- ce.attributes[XML_STRINGS[:n_points_attr]] = @distance_cutoffs.size
133
+ write_correction_point_xml(correction_element, i)
132
134
 
133
- ce.attributes[XML_STRINGS[:ref_channel_attr]] = @reference_channel
135
+ end
134
136
 
135
- ce.attributes[XML_STRINGS[:corr_channel_attr]] = @correction_channel
136
-
137
- @distance_cutoffs.each_with_index do |e, i|
137
+ end
138
138
 
139
- cp = ce.add_element XML_STRINGS[:correction_point_element]
140
139
 
141
- cp.attributes[XML_STRINGS[:x_pos_attr]]= @positions_for_correction[i,0]
142
- cp.attributes[XML_STRINGS[:y_pos_attr]]= @positions_for_correction[i,1]
143
- cp.attributes[XML_STRINGS[:z_pos_attr]]= @positions_for_correction[i,2]
140
+ ##
141
+ # Writes a single point used for correction to XML within a supplied correction
142
+ # XML element
143
+ #
144
+ # @param [REXML::Element] correction_element the XML element representing the correction
145
+ # @param [Integer] i the index of the point to write
146
+ #
147
+ # @return [void]
148
+ #
149
+ def write_correction_point_xml(correction_element, i)
150
+
151
+ cp = correction_element.add_element XML_STRINGS[:correction_point_element]
152
+
153
+ cp.attributes[XML_STRINGS[:x_pos_attr]]= @positions_for_correction[i,0]
154
+ cp.attributes[XML_STRINGS[:y_pos_attr]]= @positions_for_correction[i,1]
155
+ cp.attributes[XML_STRINGS[:z_pos_attr]]= @positions_for_correction[i,2]
144
156
 
145
- xp = cp.add_element XML_STRINGS[:x_param_element]
157
+ point_dims_to_corr = {XML_STRINGS[:x_param_element] => @correction_x,
158
+ XML_STRINGS[:y_param_element] => @correction_y,
159
+ XML_STRINGS[:z_param_element] => @correction_z}
146
160
 
147
- xp.text = @correction_x[i].to_a.join(", ")
148
161
 
149
- yp = cp.add_element XML_STRINGS[:y_param_element]
162
+ point_dims_to_corr.each do |dim_el, corr_txt|
150
163
 
151
- yp.text = @correction_y[i].to_a.join(", ")
164
+ p = cp.add_element dim_el
165
+
166
+ p.text = corr_txt[i].to_a.join(", ")
152
167
 
153
- zp = cp.add_element XML_STRINGS[:z_param_element]
154
-
155
- zp.text = @correction_z[i].to_a.join(", ")
156
-
157
168
  end
158
169
 
159
- bd = ce.add_element XML_STRINGS[:binary_data_element]
170
+ end
171
+
172
+ ##
173
+ # Writes the internal binary representation of the correction into
174
+ # an XML element.
175
+ #
176
+ # @param [REXML::Element] correction_element the XML element representing the correction
177
+ #
178
+ # @return [void]
179
+ #
180
+ def write_correction_binary_data_element(correction_element)
181
+
182
+ bd = correction_element.add_element XML_STRINGS[:binary_data_element]
160
183
 
161
184
  bd.attributes[XML_STRINGS[:encoding_attr]]= XML_STRINGS[:encoding_name]
162
185
 
@@ -164,6 +187,29 @@ module Cicada
164
187
 
165
188
  bd.text = bin_data
166
189
 
190
+ end
191
+
192
+ ##
193
+ # Writes the correction to a string in XML format
194
+ #
195
+ # @return [String] the correction data encoded as XML
196
+ #
197
+ def write_to_xml
198
+
199
+ doc = REXML::Document.new
200
+
201
+ ce = doc.add_element XML_STRINGS[:correction_element]
202
+
203
+ ce.attributes[XML_STRINGS[:n_points_attr]] = @distance_cutoffs.size
204
+
205
+ ce.attributes[XML_STRINGS[:ref_channel_attr]] = @reference_channel
206
+
207
+ ce.attributes[XML_STRINGS[:corr_channel_attr]] = @correction_channel
208
+
209
+ write_all_correction_point_xml(ce)
210
+
211
+ write_correction_binary_data_element(ce)
212
+
167
213
  doc_string = ""
168
214
 
169
215
  doc.write doc_string, 2
@@ -29,6 +29,7 @@ require 'cicada/mutable_matrix'
29
29
  require 'cicada/correction/correction'
30
30
 
31
31
  require 'ostruct'
32
+ require 'logger'
32
33
 
33
34
  require 'pqueue'
34
35
 
@@ -59,7 +60,7 @@ module Cicada
59
60
  # for a 2d quadratic fit)
60
61
  NUM_CORR_PARAM = 6
61
62
 
62
- attr_accessor :parameters, :pixel_to_distance_conversions
63
+ attr_accessor :parameters, :pixel_to_distance_conversions, :logger
63
64
 
64
65
  ##
65
66
  # Constructs a new position corrector with the specified parameters
@@ -69,6 +70,7 @@ module Cicada
69
70
  def initialize(p)
70
71
  @parameters = p
71
72
  @pixel_to_distance_conversions = Vector[p[:pixelsize_nm].to_f, p[:pixelsize_nm].to_f, p[:z_sectionsize_nm].to_f]
73
+ @logger = Logger.new(STDOUT)
72
74
  end
73
75
 
74
76
 
@@ -281,12 +283,10 @@ module Cicada
281
283
 
282
284
  mean_corr_vec.map! { |e| e / corrected_vec_diffs.length }
283
285
 
284
- #TODO - logging
285
-
286
- puts "mean components uncorrected: [#{mean_uncorr_vec.join(', ')}]"
287
- puts "mean distance uncorrected: #{Vector[*mean_uncorr_vec].norm}"
288
- puts "mean components corrected: [#{mean_corr_vec.join(', ')}]"
289
- puts "mean distance corrected: #{Vector[*mean_corr_vec].norm}"
286
+ self.logger.info("mean components uncorrected: [#{mean_uncorr_vec.join(', ')}]")
287
+ self.logger.info("mean distance uncorrected: #{Vector[*mean_uncorr_vec].norm}")
288
+ self.logger.info("mean components corrected: [#{mean_corr_vec.join(', ')}]")
289
+ self.logger.info("mean distance corrected: #{Vector[*mean_corr_vec].norm}")
290
290
 
291
291
  end
292
292
 
@@ -426,7 +426,7 @@ module Cicada
426
426
 
427
427
  tq.submit do
428
428
 
429
- puts "Calculating TRE. Progress: #{ii} of #{objs.length}" if ii.modulo(10) == 0
429
+ self.logger.debug("Calculating TRE. Progress: #{ii} of #{objs.length}") if ii.modulo(10) == 0
430
430
 
431
431
  temp_objs = objs.select { |e| e != obj }
432
432
 
@@ -486,10 +486,8 @@ module Cicada
486
486
 
487
487
  tre_2d = Math.mean(tre_values) { |e| e.tre_xy }
488
488
 
489
- #TODO logging
490
-
491
- puts "TRE: #{tre_3d}"
492
- puts "X-Y TRE: #{tre_2d}"
489
+ self.logger.info("TRE: #{tre_3d}")
490
+ self.logger.info("X-Y TRE: #{tre_2d}")
493
491
 
494
492
  tre_3d
495
493
 
@@ -26,7 +26,7 @@
26
26
 
27
27
  module Cicada
28
28
 
29
- VERSION = "0.9.0"
29
+ VERSION = "0.9.1"
30
30
 
31
31
  end
32
32
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cicada
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  prerelease:
6
6
  platform: java
7
7
  authors: