title | tags | |||
---|---|---|---|---|
Getting started with SNIRF data |
|
The Shared Near Infrared Spectroscopy Format (SNIRF) is designed to facilitate sharing and analysis of NIRS data. The specification itself can be found on GitHub here.
The SNIRF format itself is base on the Hierarchical Data format HDF5. This is a very flexible container file format which in fact is also used by MATLAB for the .mat
file format from version 7.3 onward, see here. Specifying that it is HDF5 is not enough to standardize, it is also required to specify how data and metadata is organized inside the container. This is what has been defined in the SNIRF format specification. The SNIRF format resenbles the Homer NIRS format, but is more elaborate and flexible.
In FieldTrip you can read SNIRF files using the low-level reading functions ft_read_header, ft_read_data and ft_read_event, which also means that you can browse, import and preprocess the data in the standard way as explained in the tutorials using ft_databrowser and ft_preprocessing.
You can write data that is represented as a continuous FieldTrip raw data structure (see this FAQ) to a SNIRF file. That means that any data format supported by FieldTrip can be converted to SNIRF; this includes NIRS formats such as Artinis and Homer, but also non-NIRS data such as EEG. Channels in the raw data structure that are recognized as NIRS will be written in the data field, all other channels will be written in the aux field.
Events or triggers are represented very differently in the different file formats; in FieldTrip we always use the format as returned by ft_read_event. To write events to a SNIRF file you have to pass them as additional argument to ft_write_data like this
ft_write_data(filename, dat, 'header', hdr, 'event', event)
where the filename has the .snirf
extension. For the hdr
argument you can use the data.hdr
field, for the dat
argument you can use data.trial{1}
, i.e. the Nchans*Nsamples matrix that contains the data. In case you selected a subset of channels, you should use the chanindx
argument to ensure that the mapping between hdr.label
and the rows from the dat
matrix is consistent.