• Stars
    star
    626
  • Rank 69,006 (Top 2 %)
  • Language
    C++
  • License
    Boost Software Li...
  • Created over 8 years ago
  • Updated 25 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

HighFive - Header-only C++ HDF5 interface

Note: In preparation of v3 of HighFive, we've started merging breaking changes into the main branch. More information and opportunity to comment can be found at: #864

HighFive - HDF5 header-only C++ Library

Doxygen -> gh-pages codecov HighFive_Integration_tests Zenodo

Documentation: https://bluebrain.github.io/HighFive/

Brief

HighFive is a modern header-only C++14 friendly interface for libhdf5.

HighFive supports STL vector/string, Boost::UBLAS, Boost::Multi-array and Xtensor. It handles C++ from/to HDF5 with automatic type mapping. HighFive does not require additional libraries (see dependencies).

It integrates nicely with other CMake projects by defining (and exporting) a HighFive target.

Design

  • Simple C++-ish minimalist interface
  • No other dependency than libhdf5
  • Zero overhead
  • Support C++14

Feature support

  • create/read/write files, datasets, attributes, groups, dataspaces.
  • automatic memory management / ref counting
  • automatic conversion of std::vector and nested std::vector from/to any dataset with basic types
  • automatic conversion of std::string to/from variable length string dataset
  • selection() / slice support
  • parallel Read/Write operations from several nodes with Parallel HDF5
  • Advanced types: Compound, Enum, Arrays of Fixed-length strings, References
  • half-precision (16-bit) floating-point datasets
  • std::byte in C++17 mode (with -DCMAKE_CXX_STANDARD=17 or higher)
  • etc... (see ChangeLog)

Dependencies

  • HDF5 or pHDF5, including headers
  • boost >= 1.41 (recommended)
  • eigen3 (optional)
  • xtensor (optional)
  • half (optional)

Known flaws

  • HighFive is not thread-safe. At best it has the same limitations as the HDF5 library. However, HighFive objects modify their members without protecting these writes. Users have reported that HighFive is not thread-safe even when using the threadsafe HDF5 library, e.g., #675.
  • Eigen support in core HighFive is broken. See #532. H5Easy is not affected.
  • The support of fixed length strings isn't ideal.

Examples

Write a std::vector to 1D HDF5 dataset and read it back

#include <highfive/highfive.hpp>

using namespace HighFive;

std::string filename = "/tmp/new_file.h5";

{
    // We create an empty HDF55 file, by truncating an existing
    // file if required:
    File file(filename, File::Truncate);

    std::vector<int> data(50, 1);
    file.createDataSet("grp/data", data);
}

{
    // We open the file as read-only:
    File file(filename, File::ReadOnly);
    auto dataset = file.getDataSet("grp/data");

    // Read back, with allocating:
    auto data = dataset.read<std::vector<int>>();

    // Because `data` has the correct size, this will
    // not cause `data` to be reallocated:
    dataset.read(data);
}

Note: As of 2.8.0, one can use highfive/highfive.hpp to include everything HighFive. Prior to 2.8.0 one would include highfive/H5File.hpp.

Note: For advanced usecases the dataset can be created without immediately writing to it. This is common in MPI-IO related patterns, or when growing a dataset over the course of a simulation.

Write a 2 dimensional C double float array to a 2D HDF5 dataset

See create_dataset_double.cpp

Write and read a matrix of double float (boost::ublas) to a 2D HDF5 dataset

See boost_ublas_double.cpp

Write and read a subset of a 2D double dataset

See select_partial_dataset_cpp11.cpp

Create, write and list HDF5 attributes

See create_attribute_string_integer.cpp

And others

See src/examples/ subdirectory for more info.

H5Easy

For several 'standard' use cases the highfive/H5Easy.hpp interface is available. It allows:

  • Reading/writing in a single line of:

  • Getting in a single line:

    • the size of a DataSet,
    • the shape of a DataSet.

Example

#include <highfive/H5Easy.hpp>

int main() {
    H5Easy::File file("example.h5", H5Easy::File::Overwrite);

    int A = ...;
    H5Easy::dump(file, "/path/to/A", A);

    A = H5Easy::load<int>(file, "/path/to/A");
}

whereby the int type of this example can be replaced by any of the above types. See easy_load_dump.cpp for more details.

Note: Classes such as H5Easy::File are just short for the regular HighFive classes (in this case HighFive::File). They can thus be used interchangeably.

CMake integration

There's two common paths of integrating HighFive into a CMake based project. The first is to "vendor" HighFive, the second is to install HighFive as a normal C++ library. Since HighFive makes choices about how to integrate HDF5, sometimes following the third Bailout Approach is needed.

Regular HDF5 CMake variables can be used. Interesting variables include:

  • HDF5_USE_STATIC_LIBRARIES to link statically against the HDF5 library.
  • HDF5_PREFER_PARALLEL to prefer pHDF5.
  • HDF5_IS_PARALLEL to check if HDF5 is parallel.

Please consult tests/cmake_integration for examples of how to write libraries or applications using HighFive.

Vendoring HighFive

In this approach the HighFive sources are included in a subdirectory of the project (typically as a git submodule), for example in third_party/HighFive.

The projects CMakeLists.txt add the following lines

add_subdirectory(third_party/HighFive)
target_link_libraries(foo HighFive)

Note: add_subdirectory(third_party/HighFive) will search and "link" HDF5 but wont search or link any optional dependencies such as Boost.

Regular Installation of HighFive

Alternatively, HighFive can be install and "found" like regular software.

The project's CMakeLists.txt should add the following:

find_package(HighFive REQUIRED)
target_link_libraries(foo HighFive)

Note: find_package(HighFive) will search for HDF5. "Linking" to HighFive includes linking with HDF5. The two commands will not search for or "link" to optional dependencies such as Boost.

Bailout Approach

To prevent HighFive from searching or "linking" to HDF5 the project's CMakeLists.txt should contain the following:

# Prevent HighFive CMake code from searching for HDF5:
set(HIGHFIVE_FIND_HDF5 Off)

# Then "find" HighFive as usual:
find_package(HighFive REQUIRED)
# alternatively, when vendoring:
# add_subdirectory(third_party/HighFive)

# Finally, use the target `HighFive::Include` which
# doesn't add a dependency on HDF5.
target_link_libraries(foo HighFive::Include)

# Proceed to find and link HDF5 as required.

Optional Dependencies

HighFive does not attempt to find or "link" to any optional dependencies, such as Boost, Eigen, etc. Any project using HighFive with any of the optional dependencies must include the respective header:

#include <highfive/boost.hpp>
#include <highfive/eigen.hpp>

and add the required CMake code to find and link against the dependencies. For Boost the required lines might be

find_package(Boost REQUIRED)
target_link_libraries(foo PUBLIC Boost::headers)

Questions?

Do you have questions on how to use HighFive? Would you like to share an interesting example or discuss HighFive features? Head over to the Discussions forum and join the community.

For bugs and issues please use Issues.

Funding & Acknowledgment

The development of this software was supported by funding to the Blue Brain Project, a research center of the École polytechnique fédérale de Lausanne (EPFL), from the Swiss government's ETH Board of the Swiss Federal Institutes of Technology.

HighFive releases are uploaded to Zenodo. If you wish to cite HighFive in a scientific publication you can use the DOIs for the Zenodo records.

Copyright © 2015-2022 Blue Brain Project/EPFL

License

Boost Software License 1.0

More Repositories

1

Brayns

Visualizer for large-scale and interactive ray-tracing of neurons
C++
284
star
2

nexus

Blue Brain Nexus - A knowledge graph for data-driven science
Scala
269
star
3

BluePyOpt

Blue Brain Python Optimisation Library
Python
189
star
4

CoreNeuron

Simulator optimized for large scale neural network simulations.
C++
133
star
5

NeuroMorphoVis

A lightweight, interactive, extensible and cross-platform framework for building, visualizing and analyzing digital reconstructions of neuronal morphology skeletons extracted from microscopy stacks.
Python
121
star
6

NeuroM

Neuronal Morphology Analysis Tool
Python
96
star
7

BioExplorer

The Blue Brain BioExplorer (BBBE) is a tool for data visualization experts and scientists to extract and analyze scientific data from visualization and interactive exploration
C++
62
star
8

eFEL

Electrophys Feature Extraction Library
Python
61
star
9

Tide

Tiled Interactive Display Environment
C++
47
star
10

nmodl

Code Generation Framework For NEURON MODeling Language
C++
46
star
11

MOOC-neurons-and-synapses-2017

Reference data for the "Simulation Neuroscience:Neurons and Synapses" Massive Online Open Course
Jupyter Notebook
43
star
12

Search

Blue Brain text mining toolbox for semantic search and structured information extraction
Python
40
star
13

Rockets

REST and websockets C++ library
C++
39
star
14

NeuroTS

Topological Neuron Synthesis
Python
34
star
15

nexus-forge

Building and Using Knowledge Graphs made easy
Python
34
star
16

VessMorphoVis

A lightweight, interactive, extensible and cross-platform framework for building, visualizing and analyzing vasculature (or blood vessels) morphologies.
Python
32
star
17

Livre

Large-scale Interactive Volume Rendering Engine
C++
31
star
18

RTNeuron

Interactive visualization framework for geometrically detailed neuron simulations
C++
30
star
19

BlueGraph

Python framework for graph analytics and co-occurrence analysis
Python
28
star
20

TMD

A python package for the topological analysis of neurons.
Python
27
star
21

MorphIO

A python and C++ library for reading and writing neuronal morphologies
C++
26
star
22

SimulationTutorials

Public tutorials around electrophysiological simulations
Jupyter Notebook
26
star
23

bluima

Natural Language Processing Toolkit for Neuroscience
Java
24
star
24

Ultraliser

Reconstruction of watertight meshes and annotated volumes of neuroscience spatial structures from non-watertight inputs, segmented masks, skeletons of NGV morphologies and volumes.
C++
24
star
25

Brion

Blue Brain C++ File IO Library
C++
23
star
26

Deflect

C++ library for building applications to stream pixels to Tide
C++
21
star
27

bbp-nixpkgs

Blue Brain Project nixpkgs configuration - Build a brain with Nix
Nix
17
star
28

snap

The Blue Brain Pythonic Simulation and Network Analysis Productivity layer
Python
17
star
29

nexus-web

Nexus Web is the interface of Blue Brain Nexus
TypeScript
16
star
30

nexus-kg

Nexus KnowledgeGraph Service
Scala
16
star
31

neurocurator

Desktop application (GUI) to perform systematic and collaborative curation of neuroscientific literature.
Python
15
star
32

EModelRunner

Runs cells from stand-alone packages.
Python
15
star
33

osgTransparency

OSG render bins for transparent geometry
C
13
star
34

Atlas-Download-Tools

Search, download, and prepare brain atlas data.
Python
13
star
35

BluePyEfe

BluePyEfe: Blue Brain Python E-feature extraction
Python
13
star
36

cyme

Framework to facilitate SIMD programming, without any tedious SIMD intrinsics.
C++
12
star
37

BluePyMM

Blue Brain Python Cell Model Management
Python
11
star
38

atlas-alignment

Blue Brain multi-modal registration and alignment toolbox
Python
11
star
39

dash

Data Access and Sharing
C++
10
star
40

libsonata

A python and C++ interface to the SONATA format
C++
10
star
41

Long-range-micro-connectome

BlueBrain's recipe writer to parameterize structure and logic of a mouse whole-neocortex connectome
Python
10
star
42

nexus-js

A set of JavaScript libraries built on top of Nexus
TypeScript
10
star
43

bluebrain.github.com

API documentation for BlueBrain projects:
HTML
10
star
44

nexus-bbp-domains

BBP domains specification (schemas, vocabularies)
Scala
9
star
45

NeuroR

A collection of tools to repair morphologies
Python
9
star
46

neurodamus

A BBP Simulation Control application for NEURON
Python
8
star
47

BlueCelluLab

Simulating and experimenting on single neurons
Python
8
star
48

singlecell-emodel-suite

8
star
49

MOOC-hippocampus-network-simulation-2019

Jupyter Notebook
8
star
50

Currentscape

Currentscape is a Python tool enabling scientists to easily plot the currents in electrical neuron models. The code is based on the paper Alonso and Marder, 2019.
Python
8
star
51

morph-tool

Python
7
star
52

nat

Python module to use the annotations created with NeuroCurator, for example in a Jupyter notebook.
Jupyter Notebook
7
star
53

spack-packages

Repository of spack external packages
Python
7
star
54

hpc-coding-conventions

Python
7
star
55

Pydoxine

Python docstring generation for C++ projects using boost::python
Python
7
star
56

data-validation-framework

Simple framework to create data validation workflows.
Python
7
star
57

SSCxEModelExamples

Jupyter Notebook
7
star
58

nexus-prov

SHACL shapes for W3C PROV-O
Scala
7
star
59

morphoclass

Neuronal morphology preparation and classification using Machine Learning.
Python
6
star
60

nexus-search-webapp

The Searchable Knowledge-Graph Application
JavaScript
6
star
61

nexus-python-sdk

A Python API to interface with Nexus REST API
Python
6
star
62

luigi-tools

Extra tools to work with the Luigi library
Python
6
star
63

AstroVascPy

Vasculature blood flow computation and impact of astrocytic endfeet on vessels
Python
6
star
64

voxcell

Tools to work with voxel based brain atlases.
Python
5
star
65

bluepyentity

Manage entities within the knowledge graph
Jupyter Notebook
5
star
66

blueetl

Multiple simulations analysis tool
Python
5
star
67

learning_musculoskeletal_arm_control

This repository contains the source code of the paper titled "Optimum trajectory learning in musculoskeletal systems with model predictive control and deep reinforcement learning".
Python
5
star
68

nexus-iam

Nexus IAM Service
Scala
5
star
69

ConnectomeUtilities

Connectome Utilities
Python
5
star
70

BlueNaaS-Subcellular

A web environment for the simulation of brain molecular networks.
Vue
5
star
71

me-features-to-mo-ID-mapping

Python
4
star
72

Monsteer

Interactive Supercomputing Tools and Library
C++
4
star
73

hippocampus-workshop

Jupyter Notebook
4
star
74

Deep-Atlas

Python
4
star
75

atlas-annotation

Align and improve brain annotation atlases
Python
4
star
76

morphology-workflows

Workflows used for morphology processing.
Python
4
star
77

basalt

C++11 Graph Storage library
C++
4
star
78

codash

Collage-based distribution of DASH entities
C++
4
star
79

neuromapp

The neuromapp library reproduces the algorithms of the main software of the BBP as a collection of mini-apps
C++
4
star
80

atlas-direction-vectors

Tools to compute direction vectors in the context of brain atlases.
Python
3
star
81

nexus-service

Building blocks commonly used in Nexus services
Scala
3
star
82

emodel-generalisation

Generalisation of electrical models of neurons with MCMC
Python
3
star
83

RenderingResourceManager

A Python based service managing rendering resources for visualization web services
Python
3
star
84

morphology-documentation

Morphology Specifications used at BBP
Makefile
3
star
85

nexus-cli

A Command Line Interface (CLI) for Nexus
Python
3
star
86

sbt-nexus

An SBT Plugin for building Nexus Scala based projects
Scala
3
star
87

DMT

Python
3
star
88

BluePyEModel

Blue Brain Python Electrical Modeling Pipeline
Python
3
star
89

git-cmake-format

CMake
3
star
90

mod2c

Converter for mod files to C code
C
3
star
91

diameter-synthesis

Synthesize diameters of neuronal morphologies
Python
3
star
92

morphology-suite

3
star
93

dir-content-diff

Simple tool to compare directory contents.
Python
3
star
94

sphinx-bluebrain-theme

The Blue Brain Project's documentation theme.
HTML
3
star
95

neurox

A parallel & distributed asynchronous simulator of extended Hodgkin-Huxley neuron models
C++
3
star
96

EMSim

EMSim is a library that compute different electro-magnetic effects like LPF and VSD.
C++
2
star
97

bluima_resources

Resource files for bluima
2
star
98

me-types-mapper

Python
2
star
99

nexus-commons

Nexus Common Libraries
Scala
2
star
100

hwloc

Mirror of Portable Hardware Locality, with new features in the bbp branch.
C
2
star