Perseus

org.appliedtopology.tda4j.io.Perseus
object Perseus

Perseus's own cubical toplex ("dense grid") input format, and its per-dimension persistence-interval output format -- verified against Perseus's own documentation page and cross-checked against GUDHI's own Bitmap_cubical_complex_base.h reader source (GUDHI's cubical-complex module reads real Perseus files directly), not reconstructed from memory. See .claude/WORKLOG-io-module.md.

'''Axis order''': "lexicographic order" in Perseus's own sense has the FIRST declared axis fastest-varying -- confirmed from GUDHI's own compute_position_in_bitmap/multiplier construction (multipliers[0] = 1), the only place either project's exact stride arithmetic is spelled out in source rather than prose. This is the OPPOSITE of CubicalImage.fromFlatArray's own last-axis-fastest convention -- the same reversal Dipha.readImageData already needs, for the same underlying reason, and handled the same way here.

'''Periodic boundaries''' (a negative grid size, GUDHI's own extension to this format) are not representable by CubicalGridStream and are rejected outright with a clear error rather than silently misinterpreted.

'''Missing cubes''': Perseus reserves filtration value -1 for a cube absent from the complex entirely -- CubicalGridStream has no "absent cell" concept, so -1 is mapped to Double.PositiveInfinity (GUDHI's own documented convention for the same gap), which has the intended effect: the cell exists in the stream but is never reached by any finite-threshold computation.

'''Perseus's own simplicial toplex format is deliberately not implemented here''' -- no primary-source verification of it was done (see .claude/WORKLOG-io-module.md), and a wrong parser for it would be worse than none.

Attributes

Experimental
true
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Perseus.type

Members list

Value members

Concrete methods

def readCubicalImageData(path: String): (IndexedSeq[Int], IndexedSeq[Double])

Line 1: dimension d. Next d lines: grid size along each axis (all positive -- see the class doc on periodic boundaries). Remaining tokens: d-many products worth of filtration values, in Perseus's own lexicographic (first-axis-fastest) order; -1 means "this cube is absent." Returns the raw (shape, flatValues) pair in CubicalImage.fromFlatArray's own last-axis-fastest convention (axes already reversed from Perseus's own order, -1 already mapped to Double.PositiveInfinity) -- mirrors Dipha.readImageData's own raw-array shape, so a caller that only needs the raw grid (not an already-built stream, e.g. to round-trip it through a different loader) isn't forced to build a CubicalGridStream just to immediately flatten it back out.

Line 1: dimension d. Next d lines: grid size along each axis (all positive -- see the class doc on periodic boundaries). Remaining tokens: d-many products worth of filtration values, in Perseus's own lexicographic (first-axis-fastest) order; -1 means "this cube is absent." Returns the raw (shape, flatValues) pair in CubicalImage.fromFlatArray's own last-axis-fastest convention (axes already reversed from Perseus's own order, -1 already mapped to Double.PositiveInfinity) -- mirrors Dipha.readImageData's own raw-array shape, so a caller that only needs the raw grid (not an already-built stream, e.g. to round-trip it through a different loader) isn't forced to build a CubicalGridStream just to immediately flatten it back out.

Attributes

def readCubicalToplex(path: String, sublevel: Boolean = ...): CubicalGridStream
def readPersistenceIntervals(path: String, dim: Int): Seq[PersistenceBar[Double, Nothing]]

Reads one Perseus output file (_.txt) back into bars of the given dimension -- dim must be supplied by the caller, since Perseus's own per-dimension output files don't repeat it inside the file.

Reads one Perseus output file (_.txt) back into bars of the given dimension -- dim must be supplied by the caller, since Perseus's own per-dimension output files don't repeat it inside the file.

Attributes

def writeCubicalToplex(path: String, shape: IndexedSeq[Int], flatValues: IndexedSeq[Double]): Unit

shape/flatValues in CubicalImage.fromFlatArray's own last-axis-fastest convention -- reversed internally to Perseus's own first-axis-fastest convention before writing. Double.PositiveInfinity round-trips back to -1.

shape/flatValues in CubicalImage.fromFlatArray's own last-axis-fastest convention -- reversed internally to Perseus's own first-axis-fastest convention before writing. Double.PositiveInfinity round-trips back to -1.

Attributes

def writePersistenceIntervals(pathPrefix: String, bars: Seq[PersistenceBar[Double, _]]): Unit

Perseus's own output convention: one file per dimension (_.txt), two whitespace-separated integer columns per line, birth death -- a death of -1 means the class is essential. Perseus's own birth/death values are filtration STEP indices (integers), not raw filtration values -- this writer rounds whatever Doubles it's given to their nearest integer; callers wanting genuine step-index semantics should convert their own filtration values to step indices first.

Perseus's own output convention: one file per dimension (_.txt), two whitespace-separated integer columns per line, birth death -- a death of -1 means the class is essential. Perseus's own birth/death values are filtration STEP indices (integers), not raw filtration values -- this writer rounds whatever Doubles it's given to their nearest integer; callers wanting genuine step-index semantics should convert their own filtration values to step indices first.

Attributes