namespace io
IO namespace contains write/read functionality for most common file formats.
Summary
Members | Descriptions |
---|---|
class ASCParser |
|
class DATParser |
|
class JSONParser |
|
class JSONWriter |
|
class Parser |
|
class SWCParser |
|
class SWCWriter |
|
struct contour_info |
Contour header in DAT files. |
struct marker_type |
Markerset structure for NL files. |
struct subtree_info |
SubTree header in DAT files. |
struct tree_info |
Tree header in DAT files. |
class ASCParser
class ASCParser
: public neurostr::io::Parser
Summary
Members | Descriptions |
---|---|
public inline ASCParser(std::istream & stream) |
Creates a ASC parser. |
public inline ~ASCParser() |
Default. |
public virtual std::unique_ptr< Reconstruction > read(const std::string & name) |
Reads a reconstruction from the stream. |
protected block_type next_block_type(bool in_block) |
Deduces the type of the next block. |
protected void process_( Reconstruction & r) |
Process a single reconstruction. |
protected PropertyMap::property_type process_property() |
Process a property in the stream. |
protected Node process_sample() |
Process a sample (node) in the stream. |
protected Neurite::branch_iterator process_container_(const Neurite::branch_iterator & pos) |
Process a Tree (or contour) inserting the nodes in the container as children of the given parent. |
Members
public inline ASCParser(std::istream & stream)
Creates a ASC parser.
Parameters
s
Input stream to read from
Returns
A ASC parser
public inline ~ASCParser()
Default.
public virtual std::unique_ptr<
Reconstruction
> read(const std::string & name)
Reads a reconstruction from the stream.
Parameters
name
Reconstruction ID
Returns
Unique ptr to the reconstruction (Ownership)
protected
block_type
next_block_type(bool in_block)
Deduces the type of the next block.
Parameters
in_block
Flag: Called inside another block
Returns
block type
protected void process_(
Reconstruction
& r)
Process a single reconstruction.
Parameters
r
Reconstruction to be fill
protected PropertyMap::property_type process_property()
Process a property in the stream.
Returns
Extracted property
protected
Node
process_sample()
Process a sample (node) in the stream.
Returns
protected Neurite::branch_iterator process_container_(const Neurite::branch_iterator & pos)
Process a Tree (or contour) inserting the nodes in the container as children of the given parent.
Parameters
parent
Point of insertion
Returns
Last point of insertion
class DATParser
class DATParser
: public neurostr::io::Parser
Summary
Members | Descriptions |
---|---|
public inline DATParser(std::istream & stream) |
Creates a DAT parser. |
public inline ~DATParser() |
Default. |
public virtual std::unique_ptr< Reconstruction > read(const std::string &) |
Reads a reconstruction from the stream. |
protected bool valid_header() |
Checks that the header is correct. |
protected std::string process_string(std::size_t len) |
Process binary string block. |
protected Node process_sample() |
Process binary sample block. |
protected PropertyMap::property_type process_property() |
Process binary property block. |
protected marker_type process_markerset() |
Proces binary markeset block. |
protected std::vector< Node > process_samplelist_() |
Process sample list block. |
protected std::vector< PropertyMap::property_type > process_proplist_() |
Porcess list of properties. |
protected std::vector< marker_type > process_markersetlist_() |
Process list of markers. |
protected std::size_t process_container_(const Neurite::branch_iterator & pos) |
Process container block in buffer. |
protected void process_block_( Reconstruction & r) |
Process block in buffer. |
protected void skip_block() |
Skips current block in buffer. |
Members
public inline DATParser(std::istream & stream)
Creates a DAT parser.
Parameters
s
Input stream to read from
Returns
A DAT parser
public inline ~DATParser()
Default.
public virtual std::unique_ptr<
Reconstruction
> read(const std::string &)
Reads a reconstruction from the stream.
Parameters
name
Reconstruction ID
Returns
Unique ptr to the reconstruction (Ownership)
protected bool valid_header()
Checks that the header is correct.
Returns
True if header is valid
protected std::string process_string(std::size_t len)
Process binary string block.
Parameters
len
String length
Returns
String
protected
Node
process_sample()
Process binary sample block.
Returns
protected PropertyMap::property_type process_property()
Process binary property block.
Returns
Property
protected
marker_type
process_markerset()
Proces binary markeset block.
Returns
Marker
protected std::vector<
Node
> process_samplelist_()
Process sample list block.
Returns
Node vector
protected std::vector< PropertyMap::property_type > process_proplist_()
Porcess list of properties.
Returns
Property vector
protected std::vector<
marker_type
> process_markersetlist_()
Process list of markers.
Returns
Vector of markers
protected std::size_t process_container_(const Neurite::branch_iterator & pos)
Process container block in buffer.
Parameters
pos
Insertion position
Returns
Number of bytes extended
protected void process_block_(
Reconstruction
& r)
Process block in buffer.
Parameters
r
Reconstruction to fill
protected void skip_block()
Skips current block in buffer.
class JSONParser
class JSONParser
: public neurostr::io::Parser
Summary
Members | Descriptions |
---|---|
public inline JSONParser(std::istream & stream) |
Creates a JSON parser. |
public inline ~JSONParser() |
Default. |
public virtual std::unique_ptr< Reconstruction > read(const std::string & name) |
Reads a reconstruction from the stream. |
Members
public inline JSONParser(std::istream & stream)
Creates a JSON parser.
Parameters
s
Input stream to read from
Returns
JSON parser
public inline ~JSONParser()
Default.
public virtual std::unique_ptr<
Reconstruction
> read(const std::string & name)
Reads a reconstruction from the stream.
Parameters
name
Reconstruction ID
Returns
Unique ptr to the reconstruction (Ownership)
class JSONWriter
Summary
Members | Descriptions |
---|---|
public JSONWriter(std::ostream & s,bool pretty) |
Creates a writer over the given output stream. |
public inline ~JSONWriter() |
Default. |
public void write(const neurostr::Reconstruction & r) |
Writes a reconstruction. |
public void writeNeuron(const neurostr::Neuron & n) |
Writes a single neuron (wo rec. |
protected void writePoint(const neurostr::point_type & point) |
Writes a point object as {x,y,z}. |
protected void writeProperty(const neurostr::PropertyMap::const_iterator & p) |
Writes the given property as key:value. |
protected void writeSoma(const neurostr::Neuron & n) |
Writes the neuron soma as {nodes:[nodes]}. |
protected void writeContour(const neurostr::Contour & c) |
Writes the given contour as an object. |
protected void writePropertyMap(const neurostr::PropertyMap & pm) |
Writes the property map as an object {}. |
protected void writeNeurite(const neurostr::Neurite & n) |
Writes the neurite as an object { id:, type: , tree:}. |
protected void writeBranch(const neurostr::Neurite::tree_type::iterator_base & b,const neurostr::Neurite & n) |
Writes the given branch (member of n) as {root: node, properties: , nodes:[], children:[] }. |
protected void writeNode(const neurostr::Node & n) |
Writes a single node as {id,x,y,z,r,properties:{}}. |
Members
public JSONWriter(std::ostream & s,bool pretty)
Creates a writer over the given output stream.
Parameters
-
s
Stream pretty
If true, ouptut is prettyfied
public inline ~JSONWriter()
Default.
public void write(const
neurostr::Reconstruction
& r)
Writes a reconstruction.
Parameters
public void writeNeuron(const
neurostr::Neuron
& n)
Writes a single neuron (wo rec.
contours)
Parameters
n
Neuron
protected void writePoint(const neurostr::point_type & point)
Writes a point object as {x,y,z}.
Parameters
point
3D Point
protected void writeProperty(const neurostr::PropertyMap::const_iterator & p)
Writes the given property as key:value.
Parameters
p
Property iterator
protected void writeSoma(const
neurostr::Neuron
& n)
Writes the neuron soma as {nodes:[nodes]}.
Parameters
n
Neuron
protected void writeContour(const
neurostr::Contour
& c)
Writes the given contour as an object.
Contour points are in a array
Parameters
c
Contour
protected void writePropertyMap(const
neurostr::PropertyMap
& pm)
Writes the property map as an object {}.
Parameters
pm
Property map
protected void writeNeurite(const
neurostr::Neurite
& n)
Writes the neurite as an object { id:, type: , tree:}.
Parameters
n
Neurite
protected void writeBranch(const neurostr::Neurite::tree_type::iterator_base & b,const
neurostr::Neurite
& n)
Writes the given branch (member of n) as {root: node, properties: , nodes:[], children:[] }.
Parameters
protected void writeNode(const
neurostr::Node
& n)
Writes a single node as {id,x,y,z,r,properties:{}}.
Parameters
n
Node
class Parser
Summary
Members | Descriptions |
---|---|
public inline Parser(std::istream & s) |
Constructs copy the istream reference. |
public inline virtual ~Parser() |
|
public Parser(const Parser &) = delete |
Deleted copy constructor. |
public Parser & operator=(const Parser &) = delete |
Deleted copy operator. |
public inline void reset_errors() |
Set the error count to the default state. |
public inline int error() const |
Get number of errors. |
public inline int warn() const |
Get number of warnigs. |
public inline bool critical() const |
Critical error flag. |
public std::unique_ptr< Reconstruction > read(const std::string & name) |
Reads a reconstruction from the stream and returns a unique_ptr. |
protected std::istream & stream_ |
Input stream variable. |
protected int error_count |
Error status. |
protected int warn_count |
|
protected bool critical_error |
|
protected inline void process_error(const std::exception & e) |
Processes the error, log it and increments the error count. |
Members
public inline Parser(std::istream & s)
Constructs copy the istream reference.
Parameters
s
Input stream
public inline virtual ~Parser()
public Parser(const
Parser
&) = delete
Deleted copy constructor.
public
Parser
& operator=(const
Parser
&) = delete
Deleted copy operator.
public inline void reset_errors()
Set the error count to the default state.
public inline int error() const
Get number of errors.
Returns
Error count
public inline int warn() const
Get number of warnigs.
Returns
Warning count
public inline bool critical() const
Critical error flag.
Returns
True if a critical error has happened.
public std::unique_ptr<
Reconstruction
> read(const std::string & name)
Reads a reconstruction from the stream and returns a unique_ptr.
Parameters
name
Reconstruction ID
Returns
Unique ptr to the reconstruction (Ownership)
protected std::istream & stream_
Input stream variable.
protected int error_count
Error status.
protected int warn_count
protected bool critical_error
protected inline void process_error(const std::exception & e)
Processes the error, log it and increments the error count.
Parameters
e
Error
class SWCParser
class SWCParser
: public neurostr::io::Parser
luis
28/10/16
Summary
Members | Descriptions |
---|---|
public const char comment_char |
|
public const size_t field_count |
|
public SWCParser(std::istream & s) |
Creates a SWC parser with default separators (space) |
public SWCParser(std::istream & s,const std::string & sep) |
Creates a SWC parser with given separators. |
public ~SWCParser() |
Default. |
public virtual std::unique_ptr< Reconstruction > read(const std::string & name) |
Reads a reconstruction from the stream. |
public bool is_key(const std::string & s) const |
Checks if the given string is a known property name. |
public void add_property_key(const std::string &) |
Adds a string to the set of recognized property keys. |
public void remove_property_key(const std::string &) |
Removes a string of the set of recognized property keys. |
public const std::set< std::string > & get_property_keys() const |
Retrieves the set of recognized property keys. |
protected separator sep_ |
|
protected Neuron * neuron_ |
|
protected std::set< std::string > property_keys_ |
Members
public const char comment_char
public const size_t field_count
public SWCParser(std::istream & s)
Creates a SWC parser with default separators (space)
Parameters
s
Input stream to read from
Returns
A SWC parser
public SWCParser(std::istream & s,const std::string & sep)
Creates a SWC parser with given separators.
Parameters
-
s
Input stream sep
String of separator characters
Returns
A SWC parser
public ~SWCParser()
Default.
public virtual std::unique_ptr<
Reconstruction
> read(const std::string & name)
Reads a reconstruction from the stream.
For SWC files the return will always consist of a reconstruction with exactly one neuron and no contour
Parameters
name
Reconstruction ID
Returns
Unique ptr to the reconstruction (Ownership)
public bool is_key(const std::string & s) const
Checks if the given string is a known property name.
Parameters
s
String to check
Returns
True if the string is in the property key set
public void add_property_key(const std::string &)
Adds a string to the set of recognized property keys.
Parameters
s
String to add
public void remove_property_key(const std::string &)
Removes a string of the set of recognized property keys.
Parameters
s
String to add
public const std::set< std::string > & get_property_keys() const
Retrieves the set of recognized property keys.
Returns
Set of strings
protected separator sep_
protected
Neuron
* neuron_
protected std::set< std::string > property_keys_
class SWCWriter
Summary
Members | Descriptions |
---|---|
public const char comment_char |
|
public const int no_parent_id |
|
public SWCWriter(std::ostream &) |
Creates a writer over the given stream. |
public ~SWCWriter() |
|
public std::ostream & write( Neuron &) const |
Writes the given neuron in SWC format. |
protected void writeHeader( Neuron &) const |
Writes document header. |
protected void writeData( Neuron &) const |
Writes Neuron node positions (SWC DATA) |
Members
public const char comment_char
public const int no_parent_id
public SWCWriter(std::ostream &)
Creates a writer over the given stream.
Returns
public ~SWCWriter()
public std::ostream & write(
Neuron
&) const
Writes the given neuron in SWC format.
Returns
Output stream reference
protected void writeHeader(
Neuron
&) const
Writes document header.
Static header + properties as comments
protected void writeData(
Neuron
&) const
Writes Neuron node positions (SWC DATA)
struct contour_info
Contour header in DAT files.
Summary
Members | Descriptions |
---|---|
public std::uint16_t closed |
|
public std::uint8_t face_color |
|
public std::uint8_t back_color |
Members
public std::uint16_t closed
public std::uint8_t face_color
public std::uint8_t back_color
struct marker_type
Markerset structure for NL files.
Summary
Members | Descriptions |
---|---|
public std::string name |
|
public std::uint8_t color |
|
public std::vector< property_type > properties |
|
public std::vector< Node > samples |
Members
public std::string name
public std::uint8_t color
public std::vector< property_type > properties
public std::vector<
Node
> samples
struct subtree_info
SubTree header in DAT files.
Summary
Members | Descriptions |
---|---|
public uint16_t value1 |
|
public uint16_t value2 |
Members
public uint16_t value1
public uint16_t value2
struct tree_info
Tree header in DAT files.
Summary
Members | Descriptions |
---|---|
public tree_type_cd type |
|
public uint8_t face_color |
|
public uint8_t back_color |