Skip to content

Standalone SNIRF loading and saving

David Boas edited this page Dec 26, 2020 · 2 revisions

If Homer3 is in your path then you can easily load a SNIRF file using

snirf = SnirfLoad( filenm );

Likewise, you can save your snirf object using

SnirfSave( filenm, snirf );

See below for more details about the snirf object class.


The .snirf format is new to Homer3, replacing the .nirs format. It is a universal HDF5-based file format for storing and sharing NIRS data independently of any specific application-specific file format such as MATLAB.

When loading .nirs files into Homer3 for the first time, Homer3 will automatically convert the .nirs format files to the equivalent .snirf files and store the generated .snirf file in the same folder.

Homer3 provides the SnirfClass interface to manage .snirf files. The interface is made up of other classes (DataClass, ProbeClass, etc) which provide interfaces to properties of Snirf.

The Snirf interface is a part of Homer3 and can be found on the following path:

...\Homer3\DataTree\AcquiredData\Snirf\

However, the Homer3 Snirf interface works as a standalone reader, writer, and interface for Snirf files.

To load a .snirf file into Matlab workspace outside Homer3 GUI, you need to provide a path to the .snirf file to the SnirfClass constructor:

snirfObj = SnirfClass('path\snirf_to_be_loaded.snirf');

You can also create a snirf object from a .nirs file:

snirfObj = SnirfClass('path\nirs_to_convert.nirs');

Alternatively, you can create an empty SnirfClass and call its Load method by using:

snirfObj = SnirfClass();
snirfObj.Load('path\snirf_to_be_loaded.snirf');

For example, we load the ‘subjA_run01.snirf’ file which is in the ‘D:\0-BU\Homer3 test\Datasample’ path by typing:

snirfObj = SnirfClass('D:\0-BU\Homer3 test\Datasample\subjA_run01.snirf');

OR

snirfObj = SnirfClass();
snirfObj.Load('D:\0-BU\Homer3 test\Datasample\subjA_run01.snirf');

in the Matlab command window.

Then the SnirfClass object will be loaded into Matlab workspace, and the format is shown below:



Detailed descriptions about the format could be found from this link. To save changes you have made to a SnirfClass object back to disk, use the following method:

snirfObj.Save('name_of_saved_snirf.snirf');

Clone this wiki locally