17#ifndef __dwi_tractography_scalar_file_h__
18#define __dwi_tractography_scalar_file_h__
35 namespace Tractography
69 template <
typename T =
float>
class ScalarReader :
public __ReaderBase__
75 open (file,
"track scalars", properties);
86 if (std::isinf (val)) {
95 if (std::isnan (val)) {
99 tck_scalar.push_back (val);
107 using __ReaderBase__::in;
108 using __ReaderBase__::dtype;
109 using __ReaderBase__::current_index;
113 using namespace ByteOrder;
118 in.read ((
char*) &val,
sizeof (val));
124 in.read ((
char*) &val,
sizeof (val));
130 in.read ((
char*) &val,
sizeof (val));
136 in.read ((
char*) &val,
sizeof (val));
166 template <
typename T =
float>
171 using __WriterBase__<T>::count;
172 using __WriterBase__<T>::count_offset;
173 using __WriterBase__<T>::total_count;
175 using __WriterBase__<T>::dtype;
177 using __WriterBase__<T>::update_counts;
178 using __WriterBase__<T>::verify_stream;
179 using __WriterBase__<T>::open_success;
182 __WriterBase__<T> (file),
189 out.
open (
name, std::ios::out | std::ios::binary | std::ios::trunc);
191 throw Exception (
e,
"Unable to create output track scalar file");
195 const_cast<Properties&
> (properties).set_version_info();
196 const_cast<Properties&
> (properties).update_command_history();
197 create (out, properties,
"track scalars");
213 assert (std::isfinite (*i));
238 using namespace ByteOrder;
239 if (dtype.is_little_endian())
249 File::OFStream out (
name, std::ios::in | std::ios::out | std::ios::binary | std::ios::ate);
void set_index(const size_t i)
ScalarReader(const std::string &file, Properties &properties)
bool operator()(TrackScalar< T > &tck_scalar)
ScalarReader(const ScalarReader &)=delete
value_type get_next_scalar()
class to handle writing track scalars to file
value_type delimiter() const
ScalarWriter(const ScalarWriter &)=delete
bool operator()(const TrackScalar< T > &tck_scalar)
void format_scalar(const value_type &s, value_type &destination)
const size_t buffer_capacity
void add_scalar(const value_type &s)
ScalarWriter(const std::string &file, const Properties &properties)
std::unique_ptr< value_type[]> buffer
static constexpr uint8_t Float64LE
static constexpr uint8_t Float32BE
static constexpr uint8_t Float32LE
static constexpr uint8_t Float64BE
open output files for writing, checking for pre-existing file if necessary
void open(const std::string &path, const std::ios_base::openmode mode=std::ios_base::out|std::ios_base::binary)
ValueType BE(ValueType v)
ValueType LE(ValueType v)
void check_counts(const Properties &, const Properties &, const std::string &, bool abort_on_fail)
void check_properties_match(const Properties &p_tck, const Properties &p_tsf, const std::string &type, bool abort_on_fail=true)
convenience function to verify that tck/tsf files match
void check_timestamps(const Properties &, const Properties &, const std::string &)
std::unique_ptr< ImageIO::Base > create(Header &H)
constexpr default_type NaN