Class: WadrcBcpScripts::Tensor
- Inherits:
-
Object
- Object
- WadrcBcpScripts::Tensor
- Defined in:
- lib/wadrc-bcp-scripts/tensor.rb
Overview
A class for manipulating Tensor info for DTI.
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(filepath) ⇒ Tensor
constructor
A new instance of Tensor.
-
#to_fsl_txt(output_file = 'out.txt') ⇒ Object
Write out Data to a file.
Constructor Details
#initialize(filepath) ⇒ Tensor
Returns a new instance of Tensor.
7 8 9 10 11 12 |
# File 'lib/wadrc-bcp-scripts/tensor.rb', line 7 def initialize(filepath) @data = [] open(filepath, 'r').each do |line| @data << line.split(/[\,\:\s]+/).each { |val| val.strip } end end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
5 6 7 |
# File 'lib/wadrc-bcp-scripts/tensor.rb', line 5 def data @data end |
Instance Method Details
#to_fsl_txt(output_file = 'out.txt') ⇒ Object
Write out Data to a file.
15 16 17 18 19 20 21 22 |
# File 'lib/wadrc-bcp-scripts/tensor.rb', line 15 def to_fsl_txt(output_file = 'out.txt') puts "Writing " + output_file open(output_file, 'w') do |file| @data.transpose.each do |line| file.puts line.join(' ') end end end |