Class: ImzML::Spectrum
- Inherits:
-
Object
- Object
- ImzML::Spectrum
- Defined in:
- lib/imzml/metadata/run/spectrum.rb
Defined Under Namespace
Classes: BinaryData
Constant Summary collapse
- POSITION_X =
"IMS:1000050"- POSITION_Y =
"IMS:1000051"
Instance Attribute Summary collapse
-
#intensity_binary ⇒ Object
Info about intensity binary data.
-
#mz_binary ⇒ Object
Info about mz binary data.
-
#position ⇒ Object
Attributes to describe the position of a spectrum in the image.
Instance Method Summary collapse
Instance Attribute Details
#intensity_binary ⇒ Object
Info about intensity binary data
Represented by class BinaryData
92 93 94 |
# File 'lib/imzml/metadata/run/spectrum.rb', line 92 def intensity_binary @intensity_binary end |
#mz_binary ⇒ Object
Info about mz binary data
Represented by class BinaryData
87 88 89 |
# File 'lib/imzml/metadata/run/spectrum.rb', line 87 def mz_binary @mz_binary end |
#position ⇒ Object
Attributes to describe the position of a spectrum in the image.
represented as Point with position x, y
80 81 82 |
# File 'lib/imzml/metadata/run/spectrum.rb', line 80 def position @position end |
Instance Method Details
#intensity(at, interval) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/imzml/metadata/run/spectrum.rb', line 94 def intensity(at, interval) # read whole the binary data mz_array = mz_binary.data intensity_array = intensity_binary.data default_from, default_to = mz_array.first, mz_array.first # find designated intensity if !at from = default_from to = default_to else from = at - interval from = default_from if from < 0 to = at + interval to = default_to if to > mz_array.last end # find values in mz array low_value = mz_array.binary_search(from, false) low_index = mz_array.index(low_value) high_value = mz_array.binary_search(to) high_index = mz_array.index(high_value) # sum all values in subarray intensity_array[low_index..high_index].inject{|sum, x| sum + x} end |