module pysnirf2
August 7, 2025 · View on GitHub
module pysnirf2
Module for reading, writing and validating SNIRF files.
SNIRF files are HDF5 files designed to facilitate the sharing of near-infrared spectrocopy data. Their specification is defined at https://github.com/fNIRS/snirf.
This library wraps each HDF5 Group and offers a Pythonic interface on lists of like-Groups which the SNIRF specification calls "indexed Groups".
Example: Load a file:
from snirf import Snirf
>>> with Snirf(
Maintained by the Boston University Neurophotonics Center
function loadSnirf
loadSnirf(
path: str,
dynamic_loading: bool = False,
enable_logging: bool = False
) → Snirf
Load a SNIRF file from disk.
Returns a Snirf object loaded from path if a SNIRF file exists there. Takes the same kwargs as the Snirf object constructor
Args:
path(str): Path to a SNIRF file on disk.dynamic_loading(bool): If True, Datasets will not be read from the SNIRF file unless accessed with a property, conserving memory and loading time with larger datasets. Default False.enable_logging(bool): If True, theSnirfinstance will write to a log file which shares its name. Default False.
Returns:
Snirf: aSnirfinstance loaded from the SNIRF file.
Raises:
FileNotFoundError:pathwas not found on disk.
function saveSnirf
saveSnirf(path: str, snirf: Snirf)
Saves a SNIRF file to disk.
Args:
path(str): Path to save the file.snirf(Snirf):Snirfinstance to write to disk.
function validateSnirf
validateSnirf(path: str) → ValidationResult
Validate a SNIRF file on disk.
Returns truthy ValidationResult instance which holds detailed results of validation
class SnirfFormatError
Raised when SNIRF-specific error prevents file from loading or saving properly.
class ValidationIssue
Information about the validity of a given SNIRF file location.
Properties: location: A relative HDF5 name corresponding to the location of the issue name: A string describing the issue. Must be predefined in _CODES id: An integer corresponding to the predefined error type severity: An integer ranking the serverity level of the issue. 0 OK, Nothing remarkable 1 Potentially useful INFO 2 WARNING, the file is valid but exhibits undefined behavior or features marked deprecation 3 FATAL, The file is invalid. message: A string containing a more verbose description of the issue
method __init__
__init__(name: str, location: str)
method dictize
dictize()
Return dictionary representation of Issue.
class ValidationResult
The result of Snirf file validation routines.
Validation results in a list of issues. Each issue records information about the validity of each location (each named Dataset and Group) in a SNIRF file. ValidationResult organizes the issues catalogued during validation and affords interfaces to retrieve and display them.
<ValidationResult> = <Snirf instance>.validate()
<ValidationResult> = validateSnirf(<path>)
method __init__
__init__()
ValidationResult should only be created by a Snirf instance's validate method.
property codes
A list of each unique code name associated with all catalogued issues.
property errors
A list of the FATAL issues catalogued during validation.
property info
A list of the INFO issues catalogued during validation.
property issues
A comprehensive list of all ValidationIssue instances for the result.
property locations
A list of the HDF5 location associated with each issue.
property warnings
A list of the WARNING issues catalogued during validation.
method display
display(severity=2)
Reads the contents of an h5py.Dataset to an array of dtype=str.
Args:
severity: Anintwhich sets the minimum severity message to display. Default is 2. severity=0 All messages will be shown, includingOKseverity=1 PrintsINFO,WARNING, andFATALmessages severity=2 PrintsWARNINGandFATALmessages severity=3 Prints onlyFATALerror messages
method is_valid
is_valid() → bool
Returns True if no FATAL issues were catalogued during validation.
method serialize
serialize(indent=4)
Render serialized JSON ValidationResult.
class SnirfConfig
Structure containing Snirf-wide data and settings.
Properties: logger (logging.Logger): The logger that the Snirf instance writes to dynamic_loading (bool): If True, data is loaded from the HDF5 file only on access via property
method __init__
__init__()
class Group
method __init__
__init__(varg, cfg: SnirfConfig)
Wrapper for an HDF5 Group element defined by SNIRF.
Base class for an HDF5 Group element defined by SNIRF. Must be created with a Group ID or string specifying a complete path relative to file root--in the latter case, the wrapper will not correspond to a real HDF5 group on disk until _save() (with no arguments) is executed for the first time
Args:
varg(h5py.h5g.GroupID or str): Either a string which maps to a future Group location or an ID corresponding to a current one on diskcfg(SnirfConfig): Injected configuration of parentSnirfinstance
property filename
The filename the Snirf object was loaded from and will save to.
None if not associated with a Group on disk.
property location
The HDF5 relative location indentifier.
method is_empty
is_empty()
If the Group has no member Groups or Datasets.
Returns:
bool: True if empty, False if not
method save
save(*args)
Group level save to a SNIRF file on disk.
Args:
args(str or h5py.File): A path to a closed SNIRF file on disk or an openh5py.Fileinstance
Examples:
save can be called on a Group already on disk to overwrite the current contents: mysnirf.nirs[0].probe.save()
or using a new filename to write the Group there:
>>> mysnirf.nirs[0].probe.save(<new destination>)
class IndexedGroup
method __init__
__init__(parent: Group, cfg: SnirfConfig)
Represents several Groups which share a name, an "indexed group".
Represents the "indexed group" which is defined by v1.0 of the SNIRF specification as: If a data element is an HDF5 group and contains multiple sub-groups, it is referred to as an indexed group. Each element of the sub-group is uniquely identified by appending a string-formatted index (starting from 1, with no preceding zeros) in the name, for example, /.../name1 denotes the first sub-group of data element name, and /.../name2 denotes the 2nd element, and so on.
Because the indexed group is not a true HDF5 group but rather an iterable list of HDF5 groups, it takes a base group or file and searches its keys, appending the appropriate elements to itself in order.
The appropriate elements are identified using the _name attribute: if a key begins with _name and ends with a number, or is equal to _name.
Args:
parent(h5py.h5g.Group): An HDF5 group which is the parent of the indexed groupscfg(SnirfConfig): Injected configuration of parentSnirfinstance
property filename
The filename the Snirf object was loaded from and will save to.
method append
append(item)
Append a new Group to the IndexedGroup.
Args:
item: must be of type _element
method appendGroup
appendGroup()
Insert a new Group at the end of the Indexed Group.
Creates an empty Group with the appropriate name at the end of the list of Groups managed by the IndexedGroup.
method insert
insert(i, item)
Insert a new Group into the IndexedGroup.
Args:
i(int): an indexitem: must be of type _element
method insertGroup
insertGroup(i)
Insert a new Group following the index given.
Creates an empty Group with a placeholder name within the list of Groups managed by the IndexedGroup. The placeholder name will be replaced with a name with the correct order once save is called.
Args:
i(int): the position at which to insert the new Group
method is_empty
is_empty()
Returns True if the Indexed Group has no member Groups with contents.
Returns:
bool: True if empty, False if not
method save
save(*args)
Save the groups to a SNIRF file on disk.
When saving, the naming convention defined by the SNIRF spec is enforced: groups are named /<name>1, /<name>2, /<name>3, and so on.
Args:
args(str or h5py.File): A path to a closed SNIRF file on disk or an openh5py.Fileinstance
Examples:
save can be called on an Indexed Group already on disk to overwrite the current contents: mysnirf.nirs[0].stim.save()
or using a new filename to write the Indexed Group there:
>>> mysnirf.nirs[0].stim.save(<new destination>)
class MetaDataTags
method __init__
__init__(var, cfg: SnirfConfig)
property FrequencyUnit
SNIRF field FrequencyUnit.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This record stores the case-sensitive SI frequency unit used in this measurement. Sample frequency units "Hz", "MHz" and "GHz". Please note that "mHz" is milli-Hz while "MHz" denotes "mega-Hz" according to SI unit system.
We do not limit the total number of metadata records in the metaDataTags. Users can add additional customized metadata records; no duplicated metadata record names are allowed.
Additional metadata record samples can be found in the below table.
| Metadata Key Name | Metadata value | |-------------------|----------------| |ManufacturerName | "Company Name" | |Model | "Model Name" | |SubjectName | "LastName, FirstName" | |DateOfBirth | "YYYY-MM-DD" | |AcquisitionStartTime | "1569465620" | |StudyID | "Infant Brain Development" | |StudyDescription | "In this study, we measure ...." | |AccessionNumber | "##########################" | |InstanceNumber | 2 | |CalibrationFileName | "phantomcal_121015.snirf" | |UnixTime | "1569465667" |
The metadata records "StudyID" and "AccessionNumber" are unique strings that can be used to link the current dataset to a particular study and a particular procedure, respectively. The "StudyID" tag is similar to the DICOM tag "Study ID" (0020,0010) and "AccessionNumber" is similar to the DICOM tag "Accession Number"(0008,0050), as defined in the DICOM standard (ISO 12052).
The metadata record "InstanceNumber" is defined similarly to the DICOM tag "Instance Number" (0020,0013), and can be used as the sequence number to group multiple datasets into a larger dataset - for example, concatenating streamed data segments during a long measurement session.
The metadata record "UnixTime" defines the Unix Epoch Time, i.e. the total elapse time in seconds since 1970-01-01T00:00:00Z (UTC) minus the leap seconds.
property LengthUnit
SNIRF field LengthUnit.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This record stores the case-sensitive SI length unit used in this measurement. Sample length units include "mm", "cm", and "m". A value of "um" is the same as "mm", i.e. micrometer.
property MeasurementDate
SNIRF field MeasurementDate.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This record stores the date of the measurement as a string. The format of the date string must either be "unknown", or follow the ISO 8601 date string format YYYY-MM-DD, where
YYYYis the 4-digit yearMMis the 2-digit month (padding zero if a single digit)DDis the 2-digit date (padding zero if a single digit)
property MeasurementTime
SNIRF field MeasurementTime.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This record stores the time of the measurement as a string. The format of the time string must either be "unknown" or follow the ISO 8601 time string format hh:mm:ss.sTZD, where
hhis the 2-digit hourmmis the 2-digit minutessis the 2-digit second.sis 1 or more digit representing a decimal fraction of a second (optional)TZDis the time zone designator (Zor+hh:mmor-hh:mm)
property SubjectID
SNIRF field SubjectID.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This record stores the string-valued ID of the study subject or experiment.
property TimeUnit
SNIRF field TimeUnit.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This record stores the case-sensitive SI time unit used in this measurement. Sample time units include "s", and "ms". A value of "us" is the same as "ms", i.e. microsecond.
property filename
The filename the Snirf object was loaded from and will save to.
None if not associated with a Group on disk.
property location
The HDF5 relative location indentifier.
method add
add(name, value)
Add a new tag to the list.
Args:
name(str): The name of the tag to add (will be added as an attribute of thisMetaDataTagsinstance)value: The value of the new tag
method is_empty
is_empty()
If the Group has no member Groups or Datasets.
Returns:
bool: True if empty, False if not
method remove
remove(name)
Remove a tag from the list. You cannot remove a required tag.
Args:
name(str): The name of the tag to remove.
method save
save(*args)
Group level save to a SNIRF file on disk.
Args:
args(str or h5py.File): A path to a closed SNIRF file on disk or an openh5py.Fileinstance
Examples:
save can be called on a Group already on disk to overwrite the current contents: mysnirf.nirs[0].probe.save()
or using a new filename to write the Group there:
>>> mysnirf.nirs[0].probe.save(<new destination>)
class MeasurementLists
method __init__
__init__(var, cfg: SnirfConfig)
property dataType
SNIRF field dataType.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
A 1-D array with length equal to the size of the second dimension of /nirs(i)/data(j)/dataTimeSeries. See Appendix for list of possible values.
property dataTypeIndex
SNIRF field dataTypeIndex.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
Data-type specific parameter indices. A 1-D array with length equal to the size of the second dimension of /nirs(i)/data(j)/dataTimeSeries. Note that the Time Domain and Diffuse Correlation Spectroscopy data types have two additional parameters and so dataTimeIndex must be a 2-D array with 2 columns that index the additional parameters.
property dataTypeLabel
SNIRF field dataTypeLabel.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
Data-type label. A 1-D array with length equal to the size of the second dimension of /nirs(i)/data(j)/dataTimeSeries.
property dataUnit
SNIRF field dataUnit.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
International System of Units (SI units) identifier for each channel. A 1-D array with length equal to the size of the second dimension of /nirs(i)/data(j)/dataTimeSeries.
property detectorGain
SNIRF field detectorGain.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
A 1-D array with length equal to the size of the second dimension of /nirs(i)/data(j)/dataTimeSeries. Units are optionally defined in metaDataTags.
property detectorIndex
SNIRF field detectorIndex.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
Detector indices for each channel. A 1-D array with length equal to the size of the second dimension of /nirs(i)/data(j)/dataTimeSeries.
property filename
The filename the Snirf object was loaded from and will save to.
None if not associated with a Group on disk.
property location
The HDF5 relative location indentifier.
property sourceIndex
SNIRF field sourceIndex.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
Source indices for each channel. A 1-D array with length equal to the size of the second dimension of /nirs(i)/data(j)/dataTimeSeries.
property sourcePower
SNIRF field sourcePower.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
A 1-D array with length equal to the size of the second dimension of /nirs(i)/data(j)/dataTimeSeries. Units are optionally defined in metaDataTags.
property wavelengthActual
SNIRF field wavelengthActual.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
Actual (measured) wavelength in nm, if available, for the source in each channel. A 1-D array with length equal to the size of the second dimension of /nirs(i)/data(j)/dataTimeSeries.
property wavelengthEmissionActual
SNIRF field wavelengthEmissionActual.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
Actual (measured) emission wavelength in nm, if available, for the source in each channel. A 1-D array with length equal to the size of the second dimension of /nirs(i)/data(j)/dataTimeSeries.
property wavelengthIndex
SNIRF field wavelengthIndex.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
Index of the "nominal" wavelength (in probe.wavelengths) for each channel. A 1-D array with length equal to the size of the second dimension of /nirs(i)/data(j)/dataTimeSeries.
method is_empty
is_empty()
If the Group has no member Groups or Datasets.
Returns:
bool: True if empty, False if not
method save
save(*args)
Group level save to a SNIRF file on disk.
Args:
args(str or h5py.File): A path to a closed SNIRF file on disk or an openh5py.Fileinstance
Examples:
save can be called on a Group already on disk to overwrite the current contents: mysnirf.nirs[0].probe.save()
or using a new filename to write the Group there:
>>> mysnirf.nirs[0].probe.save(<new destination>)
class Probe
method __init__
__init__(var, cfg: SnirfConfig)
property coordinateSystem
SNIRF field coordinateSystem.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
Defines the coordinate system for sensor positions. The string must be one of the coordinate systems listed in the BIDS specification (Appendix VII) such as "MNI152NLin2009bAsym", "CapTrak" or "Other". If the value "Other" is specified, then a defition of the coordinate system must be provided in /nirs(i)/probe/coordinateSystemDescription. See the FieldTrip toolbox web page for detailed descriptions of different coordinate systems.
property coordinateSystemDescription
SNIRF field coordinateSystemDescription.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
Free-form text description of the coordinate system. May also include a link to a documentation page or paper describing the system in greater detail. This field is required if the coordinateSystem field is set to "Other".
property correlationTimeDelayWidths
SNIRF field correlationTimeDelayWidths.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This field describes the time delay widths (in TimeUnit units) used for diffuse correlation spectroscopy measurements. This field is only required for gated time domain data types, and is indexed by measurementList(k).dataTypeIndex. The indexing of this field is paired with the indexing of probe.correlationTimeDelays.
property correlationTimeDelays
SNIRF field correlationTimeDelays.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This field describes the time delays (in TimeUnit units) used for diffuse correlation spectroscopy measurements. This field is only required for diffuse correlation spectroscopy data types, and is indexed by measurementList(k).dataTypeIndex. The indexing of this field is paired with the indexing of probe.correlationTimeDelayWidths.
property detectorLabels
SNIRF field detectorLabels.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This is a string array providing user friendly or instrument specific labels for each detector. Each element of the array must be a unique string among both probe.sourceLabels and probe.detectorLabels. This is indexed by measurementList(k).detectorIndex.
property detectorPos2D
SNIRF field detectorPos2D.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
Same as probe.sourcePos2D, but describing the detector positions in a flattened 2D probe layout.
property detectorPos3D
SNIRF field detectorPos3D.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This field describes the position (in LengthUnit units) of each detector optode in 3D, defined similarly to sourcePos3D.
property filename
The filename the Snirf object was loaded from and will save to.
None if not associated with a Group on disk.
property frequencies
SNIRF field frequencies.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This field describes the frequencies used (in FrequencyUnit units) for frequency domain measurements. This field is only required for frequency domain data types, and is indexed by measurementList(k).dataTypeIndex.
property landmarkLabels
SNIRF field landmarkLabels.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This string array stores the names of the landmarks. The first string denotes the name of the landmarks with an index of 1 in the 4th column of probe.landmark, and so on. One can adopt the commonly used 10-20 landmark names, such as "Nasion", "Inion", "Cz" etc, or use user-defined landmark labels. The landmark label can also use the unique source and detector labels defined in probe.sourceLabels and probe.detectorLabels, respectively, to associate the given landmark to a specific source or detector. All strings are ASCII encoded char arrays.
property landmarkPos2D
SNIRF field landmarkPos2D.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This is a 2-D array storing the neurological landmark positions projected along the 2-D (flattened) probe plane in order to map optical data from the flattened optode positions to brain anatomy. This array should contain a minimum of 2 columns, representing the x and y coordinates (in LengthUnit units) of the 2-D projected landmark positions. If a 3rd column presents, it stores the index to the labels of the given landmark. Label names are stored in the probe.landmarkLabels subfield. An label index of 0 refers to an undefined landmark.
property landmarkPos3D
SNIRF field landmarkPos3D.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This is a 2-D array storing the neurological landmark positions measurement from 3-D digitization and tracking systems to facilitate the registration and mapping of optical data to brain anatomy. This array should contain a minimum of 3 columns, representing the x, y and z coordinates (in LengthUnit units) of the digitized landmark positions. If a 4th column presents, it stores the index to the labels of the given landmark. Label names are stored in the probe.landmarkLabels subfield. An label index of 0 refers to an undefined landmark.
property location
The HDF5 relative location indentifier.
property momentOrders
SNIRF field momentOrders.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This field describes the moment orders of the temporal point spread function (TPSF) or the distribution of time-of-flight (DTOF) for moment time domain measurements. This field is only required for moment time domain data types, and is indexed by measurementList(k).dataTypeIndex. Note that the numeric value in this array is the exponent in the integral used for calculating the moments. For detailed/specific definitions of moments, see Wabnitz et al, 2020; for general definitions of moments see here.
In brief, given a TPSF or DTOF N(t) (photon counts vs. photon arrival time at the detector): / momentOrder = 0: total counts: N_total = /intergral N(t)dt / momentOrder = 1: mean time of flight: m = <t> = (1/N_total) /integral t N(t) dt / momentOrder = 2: variance/second central moment: V = (1/N_total) /integral (t - <t>)^2 N(t) dt / Please note that all moments (for orders >=1) are expected to be normalized by the total counts (i.e. n=0); Additionally all moments (for orders >= 2) are expected to be centralized.
property sourceLabels
SNIRF field sourceLabels.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This is a string array providing user friendly or instrument specific labels for each source. Each element of the array must be a unique string among both probe.sourceLabels and probe.detectorLabels.This can be of size <number of sources>x 1 or <number of sources> x <number of wavelengths>. This is indexed by measurementList(k).sourceIndex and measurementList(k).wavelengthIndex.
property sourcePos2D
SNIRF field sourcePos2D.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This field describes the position (in LengthUnit units) of each source optode. The positions are coordinates in a flattened 2D probe layout. This field has size <number of sources> x 2. For example, probe.sourcePos2D(1,:) = [1.4 1], and LengthUnit='cm' places source number 1 at x=1.4 cm and y=1 cm.
property sourcePos3D
SNIRF field sourcePos3D.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This field describes the position (in LengthUnit units) of each source optode in 3D. This field has size <number of sources> x 3.
property timeDelayWidths
SNIRF field timeDelayWidths.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This field describes the time delay widths (in TimeUnit units) used for gated time domain measurements. This field is only required for gated time domain data types, and is indexed by measurementList(k).dataTypeIndex. The indexing of this field is paired with the indexing of probe.timeDelays.
property timeDelays
SNIRF field timeDelays.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This field describes the time delays (in TimeUnit units) used for gated time domain measurements. This field is only required for gated time domain data types, and is indexed by measurementList(k).dataTypeIndex. The indexing of this field is paired with the indexing of probe.timeDelayWidths.
property wavelengths
SNIRF field wavelengths.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This field describes the "nominal" wavelengths used (in nm unit). This is indexed by the wavelengthIndex of the measurementList variable. For example, probe.wavelengths = [690, 780, 830]; implies that the measurements were taken at three wavelengths (690 nm, 780 nm, and 830 nm). The wavelength index of measurementList(k).wavelengthIndex variable refers to this field. measurementList(k).wavelengthIndex = 2 means the kth measurement was at 780 nm.
Please note that this field stores the "nominal" wavelengths. If the precise (measured) wavelengths differ from the nominal wavelengths, one can store those in the measurementList.wavelengthActual field in a per-channel fashion.
The number of wavelengths is not limited (except that at least two are needed to calculate the two forms of hemoglobin). Each source-detector pair would generally have measurements at all wavelengths.
This field must present, but can be empty, for example, in the case that the stored data are processed data (dataType=99999, see Appendix).
property wavelengthsEmission
SNIRF field wavelengthsEmission.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This field is required only for fluorescence data types, and describes the "nominal" emission wavelengths used (in nm unit). The indexing of this variable is the same wavelength index in measurementList used for probe.wavelengths such that the excitation wavelength is paired with this emission wavelength for a given measurement.
Please note that this field stores the "nominal" emission wavelengths. If the precise (measured) emission wavelengths differ from the nominal ones, one can store those in the measurementList.wavelengthEmissionActual field in a per-channel fashion.
method is_empty
is_empty()
If the Group has no member Groups or Datasets.
Returns:
bool: True if empty, False if not
method save
save(*args)
Group level save to a SNIRF file on disk.
Args:
args(str or h5py.File): A path to a closed SNIRF file on disk or an openh5py.Fileinstance
Examples:
save can be called on a Group already on disk to overwrite the current contents: mysnirf.nirs[0].probe.save()
or using a new filename to write the Group there:
>>> mysnirf.nirs[0].probe.save(<new destination>)
class NirsElement
Wrapper for an element of indexed group Nirs.
method __init__
__init__(gid: GroupID, cfg: SnirfConfig)
property aux
SNIRF field aux.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This optional array specifies any recorded auxiliary data. Each element of aux has the following required fields:
property data
SNIRF field data.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This group stores one block of NIRS data. This can be extended adding the count number (e.g. data1, data2,...) to the group name. This is intended to allow the storage of 1 or more blocks of NIRS data from within the same /nirs entry * /nirs/data1 = data block 1 * /nirs/data2 = data block 2
property filename
The filename the Snirf object was loaded from and will save to.
None if not associated with a Group on disk.
property location
The HDF5 relative location indentifier.
property metaDataTags
SNIRF field metaDataTags.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
The metaDataTags group contains the metadata associated with the measurements. Each metadata record is represented as a dataset under this group - with the name of the record, i.e. the key, as the dataset's name, and the value of the record as the actual data stored in the dataset. Each metadata record can potentially have different data types. Sub-groups should not be used to organize metadata records: a member of the metaDataTags Group must be a Dataset.
The below five metadata records are minimally required in a SNIRF file
property probe
SNIRF field probe.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This is a structured variable that describes the probe (source-detector) geometry. This variable has a number of required fields.
property stim
SNIRF field stim.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This is an array describing any stimulus conditions. Each element of the array has the following required fields.
method is_empty
is_empty()
If the Group has no member Groups or Datasets.
Returns:
bool: True if empty, False if not
method save
save(*args)
Group level save to a SNIRF file on disk.
Args:
args(str or h5py.File): A path to a closed SNIRF file on disk or an openh5py.Fileinstance
Examples:
save can be called on a Group already on disk to overwrite the current contents: mysnirf.nirs[0].probe.save()
or using a new filename to write the Group there:
>>> mysnirf.nirs[0].probe.save(<new destination>)
class Nirs
Interface for indexed group Nirs.
Can be indexed like a list to retrieve Nirs elements.
To add or remove an element from the list, use the appendGroup method and the del operator, respectively.
This group stores one set of NIRS data. This can be extended by adding the count number (e.g. /nirs1, /nirs2,...) to the group name. This is intended to allow the storage of 1 or more complete NIRS datasets inside a single SNIRF document. For example, a two-subject hyperscanning can be stored using the notation * /nirs1 = first subject's data * /nirs2 = second subject's data The use of a non-indexed (e.g. /nirs) entry is allowed when only one entry is present and is assumed to be entry 1.
method __init__
__init__(h: File, cfg: SnirfConfig)
property filename
The filename the Snirf object was loaded from and will save to.
method append
append(item)
Append a new Group to the IndexedGroup.
Args:
item: must be of type _element
method appendGroup
appendGroup()
Insert a new Group at the end of the Indexed Group.
Creates an empty Group with the appropriate name at the end of the list of Groups managed by the IndexedGroup.
method insert
insert(i, item)
Insert a new Group into the IndexedGroup.
Args:
i(int): an indexitem: must be of type _element
method insertGroup
insertGroup(i)
Insert a new Group following the index given.
Creates an empty Group with a placeholder name within the list of Groups managed by the IndexedGroup. The placeholder name will be replaced with a name with the correct order once save is called.
Args:
i(int): the position at which to insert the new Group
method is_empty
is_empty()
Returns True if the Indexed Group has no member Groups with contents.
Returns:
bool: True if empty, False if not
method save
save(*args)
Save the groups to a SNIRF file on disk.
When saving, the naming convention defined by the SNIRF spec is enforced: groups are named /<name>1, /<name>2, /<name>3, and so on.
Args:
args(str or h5py.File): A path to a closed SNIRF file on disk or an openh5py.Fileinstance
Examples:
save can be called on an Indexed Group already on disk to overwrite the current contents: mysnirf.nirs[0].stim.save()
or using a new filename to write the Indexed Group there:
>>> mysnirf.nirs[0].stim.save(<new destination>)
class DataElement
method __init__
__init__(gid: GroupID, cfg: SnirfConfig)
property dataOffset
SNIRF field dataOffset.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This stores an optional offset value per channel, which, when added to /nirs(i)/data(j)/dataTimeSeries, results in absolute data values.
The length of this array is equal to the dataTimeSeries.
property dataTimeSeries
SNIRF field dataTimeSeries.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This is the actual raw or processed data variable. This variable has dimensions of <number of time points> x <number of channels>. Columns in dataTimeSeries are mapped to the measurement list (measurementList variable described below).
dataTimeSeries can be compressed using the HDF5 filter (using the built-in deflate filter or 3rd party filters such as 305-LZO or 307-bzip2
Chunked data is allowed to support real-time streaming of data in this array.
property filename
The filename the Snirf object was loaded from and will save to.
None if not associated with a Group on disk.
property location
The HDF5 relative location indentifier.
property measurementList
SNIRF field measurementList.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
The measurement list. This variable serves to map the data array onto the probe geometry (sources and detectors), data type, and wavelength. This variable is an array structure that has the size <number of channels> that describes the corresponding column in the data matrix. For example, the measurementList3 describes the third column of the data matrix (i.e. dataTimeSeries(:,3)).
Each element of the array is a structure which describes the measurement conditions for this data with the following fields:
property measurementLists
SNIRF field measurementLists.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
The group for measurement list variables which map the data array onto the probe geometry (sources and detectors), data type, and wavelength. This group's datasets are arrays with size <number of channels>, with each position describing the corresponding column in the data matrix. (i.e. the values at measurementLists/sourceIndex(3) and measurementLists/detectorIndex(3) correspond to dataTimeSeries(:,3)).
This group is required only if the indexed-group format /nirs(i)/data(j)/measurementList(k) is not used to encode the measurement list. measurementLists is an alternative that may offer better performance for larger probes.
The arrays of measurementLists are:
property time
SNIRF field time.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
The time variable. This provides the acquisition time of the measurement relative to the time origin. This will usually be a straight line with slope equal to the acquisition frequency, but does not need to be equal spacing. For the special case of equal sample spacing an array of length <2> is allowed where the first entry is the start time and the second entry is the sample time spacing in TimeUnit specified in the metaDataTags. The default time unit is in second ("s"). For example, a time spacing of 0.2 (s) indicates a sampling rate of 5 Hz.
- Option 1 - The size of this variable is
<number of time points>and corresponds to the sample time of every data point * Option 2- The size of this variable is<2>and corresponds to the start time and sample spacing.
Chunked data is allowed to support real-time streaming of data in this array.
method is_empty
is_empty()
If the Group has no member Groups or Datasets.
Returns:
bool: True if empty, False if not
method measurementList_to_measurementLists
measurementList_to_measurementLists()
Converts measurementList to a measurementLists structure if it is present.
This method will populate the measurementLists Group structure with the contents of the measurementList indexed Group.
The measurementList indexedGroup is not be removed.
method measurementLists_to_measurementList
measurementLists_to_measurementList()
Converts measurementLists to a measurementList indexed Group structure if it is present.
This method will create new measurementList indexed Group entries populated with the contents of the measurementLists Group.
The measurementList Group is not removed.
method save
save(*args)
Group level save to a SNIRF file on disk.
Args:
args(str or h5py.File): A path to a closed SNIRF file on disk or an openh5py.Fileinstance
Examples:
save can be called on a Group already on disk to overwrite the current contents: mysnirf.nirs[0].probe.save()
or using a new filename to write the Group there:
>>> mysnirf.nirs[0].probe.save(<new destination>)
class Data
method __init__
__init__(h: File, cfg: SnirfConfig)
property filename
The filename the Snirf object was loaded from and will save to.
method append
append(item)
Append a new Group to the IndexedGroup.
Args:
item: must be of type _element
method appendGroup
appendGroup()
Insert a new Group at the end of the Indexed Group.
Creates an empty Group with the appropriate name at the end of the list of Groups managed by the IndexedGroup.
method insert
insert(i, item)
Insert a new Group into the IndexedGroup.
Args:
i(int): an indexitem: must be of type _element
method insertGroup
insertGroup(i)
Insert a new Group following the index given.
Creates an empty Group with a placeholder name within the list of Groups managed by the IndexedGroup. The placeholder name will be replaced with a name with the correct order once save is called.
Args:
i(int): the position at which to insert the new Group
method is_empty
is_empty()
Returns True if the Indexed Group has no member Groups with contents.
Returns:
bool: True if empty, False if not
method save
save(*args)
Save the groups to a SNIRF file on disk.
When saving, the naming convention defined by the SNIRF spec is enforced: groups are named /<name>1, /<name>2, /<name>3, and so on.
Args:
args(str or h5py.File): A path to a closed SNIRF file on disk or an openh5py.Fileinstance
Examples:
save can be called on an Indexed Group already on disk to overwrite the current contents: mysnirf.nirs[0].stim.save()
or using a new filename to write the Indexed Group there:
>>> mysnirf.nirs[0].stim.save(<new destination>)
class MeasurementListElement
Wrapper for an element of indexed group MeasurementList.
method __init__
__init__(gid: GroupID, cfg: SnirfConfig)
property dataType
SNIRF field dataType.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
Data-type identifier. See Appendix for list possible values.
property dataTypeIndex
SNIRF field dataTypeIndex.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
Data-type specific parameter index. The data type index specifies additional data type specific parameters that are further elaborated by other fields in the probe structure, as detailed below. Note that where multiple parameters are required, the same index must be used into each (examples include data types such as Time Domain and Diffuse Correlation Spectroscopy). One use of this parameter is as a stimulus condition index when measurementList(k).dataType = 99999 (i.e, processed and measurementList(k).dataTypeLabel = 'HRF ...' .
property dataTypeLabel
SNIRF field dataTypeLabel.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
Data-type label. Only required if dataType is "processed" (99999). See Appendix for list of possible values.
property dataUnit
SNIRF field dataUnit.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
International System of Units (SI units) identifier for the given channel. Encoding should follow the CMIXF-12 standard, avoiding special unicode symbols like U+03BC (m) or U+00B5 (u) and using '/' rather than 'per' for units such as V/us. The recommended export format is in unscaled units such as V, s, Mole.
property detectorGain
SNIRF field detectorGain.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
Detector gain
For example, if measurementList5 is a structure with sourceIndex=2, detectorIndex=3, wavelengthIndex=1, dataType=1, dataTypeIndex=1 would imply that the data in the 5th column of the dataTimeSeries variable was measured with source #2 and detector #3 at wavelength #1. Wavelengths (in nanometers) are described in the probe.wavelengths variable (described later). The data type in this case is 1, implying that it was a continuous wave measurement. The complete list of currently supported data types is found in the Appendix. The data type index specifies additional data type specific parameters that are further elaborated by other fields in the probe structure, as detailed below. Note that the Time Domain and Diffuse Correlation Spectroscopy data types have two additional parameters and so the data type index must be a vector with 2 elements that index the additional parameters.
sourcePower provides the option for information about the source power for that channel to be saved along with the data. The units are not defined, unless the user takes the option of using a metaDataTag described below to define, for instance, sourcePowerUnit. detectorGain provides the option for information about the detector gain for that channel to be saved along with the data.
Note: The source indices generally refer to the optode naming (probe positions) and not necessarily the physical laser numbers on the instrument. The same is true for the detector indices. Each source optode would generally, but not necessarily, have 2 or more wavelengths (hence lasers) plugged into it in order to calculate deoxy- and oxy-hemoglobin concentrations. The data from these two wavelengths will be indexed by the same source, detector, and data type values, but have different wavelength indices. Using the same source index for lasers at the same location but with different wavelengths simplifies the bookkeeping for converting intensity measurements into concentration changes. As described below, optional variables probe.sourceLabels and probe.detectorLabels are provided for indicating the instrument specific label for sources and detectors.
property detectorIndex
SNIRF field detectorIndex.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
Index of the detector.
property filename
The filename the Snirf object was loaded from and will save to.
None if not associated with a Group on disk.
property location
The HDF5 relative location indentifier.
property sourceIndex
SNIRF field sourceIndex.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
Index of the source.
property sourcePower
SNIRF field sourcePower.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
The units are not defined, unless the user takes the option of using a metaDataTag as described below.
property wavelengthActual
SNIRF field wavelengthActual.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
Actual (measured) wavelength in nm, if available, for the source in a given channel.
property wavelengthEmissionActual
SNIRF field wavelengthEmissionActual.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
Actual (measured) emission wavelength in nm, if available, for the source in a given channel.
property wavelengthIndex
SNIRF field wavelengthIndex.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
Index of the "nominal" wavelength (in probe.wavelengths).
method is_empty
is_empty()
If the Group has no member Groups or Datasets.
Returns:
bool: True if empty, False if not
method save
save(*args)
Group level save to a SNIRF file on disk.
Args:
args(str or h5py.File): A path to a closed SNIRF file on disk or an openh5py.Fileinstance
Examples:
save can be called on a Group already on disk to overwrite the current contents: mysnirf.nirs[0].probe.save()
or using a new filename to write the Group there:
>>> mysnirf.nirs[0].probe.save(<new destination>)
class MeasurementList
Interface for indexed group MeasurementList.
Can be indexed like a list to retrieve MeasurementList elements.
To add or remove an element from the list, use the appendGroup method and the del operator, respectively.
The measurement list. This variable serves to map the data array onto the probe geometry (sources and detectors), data type, and wavelength. This variable is an array structure that has the size <number of channels> that describes the corresponding column in the data matrix. For example, the measurementList3 describes the third column of the data matrix (i.e. dataTimeSeries(:,3)).
Each element of the array is a structure which describes the measurement conditions for this data with the following fields:
method __init__
__init__(h: File, cfg: SnirfConfig)
property filename
The filename the Snirf object was loaded from and will save to.
method append
append(item)
Append a new Group to the IndexedGroup.
Args:
item: must be of type _element
method appendGroup
appendGroup()
Insert a new Group at the end of the Indexed Group.
Creates an empty Group with the appropriate name at the end of the list of Groups managed by the IndexedGroup.
method insert
insert(i, item)
Insert a new Group into the IndexedGroup.
Args:
i(int): an indexitem: must be of type _element
method insertGroup
insertGroup(i)
Insert a new Group following the index given.
Creates an empty Group with a placeholder name within the list of Groups managed by the IndexedGroup. The placeholder name will be replaced with a name with the correct order once save is called.
Args:
i(int): the position at which to insert the new Group
method is_empty
is_empty()
Returns True if the Indexed Group has no member Groups with contents.
Returns:
bool: True if empty, False if not
method save
save(*args)
Save the groups to a SNIRF file on disk.
When saving, the naming convention defined by the SNIRF spec is enforced: groups are named /<name>1, /<name>2, /<name>3, and so on.
Args:
args(str or h5py.File): A path to a closed SNIRF file on disk or an openh5py.Fileinstance
Examples:
save can be called on an Indexed Group already on disk to overwrite the current contents: mysnirf.nirs[0].stim.save()
or using a new filename to write the Indexed Group there:
>>> mysnirf.nirs[0].stim.save(<new destination>)
class StimElement
method __init__
__init__(gid: GroupID, cfg: SnirfConfig)
property data
SNIRF field data.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
- Allowed attribute:
names
This is a numeric 2-D array with at least 3 columns, specifying the stimulus time course for the jth condition. Each row corresponds to a specific stimulus trial. The first three columns indicate [starttime duration value]. The starttime, in seconds, is the time relative to the time origin when the stimulus takes on a value; the duration is the time in seconds that the stimulus value continues, and value is the stimulus amplitude. The number of rows is not constrained. (see examples in the appendix).
Additional columns can be used to store user-specified data associated with each stimulus trial. An optional record /nirs(i)/stim(j)/dataLabels can be used to annotate the meanings of each data column.
property dataLabels
SNIRF field dataLabels.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This is a string array providing annotations for each data column in /nirs(i)/stim(j)/data. Each element of the array must be a string; the total length of this array must be the same as the column number of /nirs(i)/stim(j)/data, including the first 3 required columns.
property filename
The filename the Snirf object was loaded from and will save to.
None if not associated with a Group on disk.
property location
The HDF5 relative location indentifier.
property name
SNIRF field name.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This is a string describing the jth stimulus condition.
method is_empty
is_empty()
If the Group has no member Groups or Datasets.
Returns:
bool: True if empty, False if not
method save
save(*args)
Group level save to a SNIRF file on disk.
Args:
args(str or h5py.File): A path to a closed SNIRF file on disk or an openh5py.Fileinstance
Examples:
save can be called on a Group already on disk to overwrite the current contents: mysnirf.nirs[0].probe.save()
or using a new filename to write the Group there:
>>> mysnirf.nirs[0].probe.save(<new destination>)
class Stim
method __init__
__init__(h: File, cfg: SnirfConfig)
property filename
The filename the Snirf object was loaded from and will save to.
method append
append(item)
Append a new Group to the IndexedGroup.
Args:
item: must be of type _element
method appendGroup
appendGroup()
Insert a new Group at the end of the Indexed Group.
Creates an empty Group with the appropriate name at the end of the list of Groups managed by the IndexedGroup.
method insert
insert(i, item)
Insert a new Group into the IndexedGroup.
Args:
i(int): an indexitem: must be of type _element
method insertGroup
insertGroup(i)
Insert a new Group following the index given.
Creates an empty Group with a placeholder name within the list of Groups managed by the IndexedGroup. The placeholder name will be replaced with a name with the correct order once save is called.
Args:
i(int): the position at which to insert the new Group
method is_empty
is_empty()
Returns True if the Indexed Group has no member Groups with contents.
Returns:
bool: True if empty, False if not
method save
save(*args)
Save the groups to a SNIRF file on disk.
When saving, the naming convention defined by the SNIRF spec is enforced: groups are named /<name>1, /<name>2, /<name>3, and so on.
Args:
args(str or h5py.File): A path to a closed SNIRF file on disk or an openh5py.Fileinstance
Examples:
save can be called on an Indexed Group already on disk to overwrite the current contents: mysnirf.nirs[0].stim.save()
or using a new filename to write the Indexed Group there:
>>> mysnirf.nirs[0].stim.save(<new destination>)
class AuxElement
method __init__
__init__(gid: GroupID, cfg: SnirfConfig)
property dataTimeSeries
SNIRF field dataTimeSeries.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This is the aux data variable. This variable has dimensions of <number of time points> x <number of channels>. If multiple channels of related data are generated by a system, they may be encoded in the multiple columns of the time series (i.e. complex numbers). For example, a system containing more than one accelerometer may output this data as a set of ACCEL_X/ACCEL_Y/ACCEL_Z auxiliary time series, where each has the dimension of <number of time points> x <number of accelerometers>. Note that it is NOT recommended to encode the various accelerometer dimensions as multiple channels of the same aux Group: instead follow the "ACCEL_X", "ACCEL_Y", "ACCEL_Z" naming conventions described in the appendix. Chunked data is allowed to support real-time data streaming.
property dataUnit
SNIRF field dataUnit.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
International System of Units (SI units) identifier for the given channel. Encoding should follow the CMIXF-12 standard, avoiding special unicode symbols like U+03BC (m) or U+00B5 (u) and using '/' rather than 'per' for units such as V/us. The recommended export format is in unscaled units such as V, s, Mole.
property filename
The filename the Snirf object was loaded from and will save to.
None if not associated with a Group on disk.
property location
The HDF5 relative location indentifier.
property name
SNIRF field name.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This is string describing the jth auxiliary data timecourse. While auxiliary data can be given any title, standard names for commonly used auxiliary channels (i.e. accelerometer data) are specified in the appendix.
property time
SNIRF field time.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
The time variable. This provides the acquisition time (in TimeUnit units) of the aux measurement relative to the time origin. This will usually be a straight line with slope equal to the acquisition frequency, but does not need to be equal spacing. The size of this variable is <number of time points> or <2> similar to definition of the /nirs(i)/data(j)/time field.
Chunked data is allowed to support real-time data streaming
property timeOffset
SNIRF field timeOffset.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This variable specifies the offset of the file time origin relative to absolute (clock) time in TimeUnit units.
method is_empty
is_empty()
If the Group has no member Groups or Datasets.
Returns:
bool: True if empty, False if not
method save
save(*args)
Group level save to a SNIRF file on disk.
Args:
args(str or h5py.File): A path to a closed SNIRF file on disk or an openh5py.Fileinstance
Examples:
save can be called on a Group already on disk to overwrite the current contents: mysnirf.nirs[0].probe.save()
or using a new filename to write the Group there:
>>> mysnirf.nirs[0].probe.save(<new destination>)
class Aux
method __init__
__init__(h: File, cfg: SnirfConfig)
property filename
The filename the Snirf object was loaded from and will save to.
method append
append(item)
Append a new Group to the IndexedGroup.
Args:
item: must be of type _element
method appendGroup
appendGroup()
Insert a new Group at the end of the Indexed Group.
Creates an empty Group with the appropriate name at the end of the list of Groups managed by the IndexedGroup.
method insert
insert(i, item)
Insert a new Group into the IndexedGroup.
Args:
i(int): an indexitem: must be of type _element
method insertGroup
insertGroup(i)
Insert a new Group following the index given.
Creates an empty Group with a placeholder name within the list of Groups managed by the IndexedGroup. The placeholder name will be replaced with a name with the correct order once save is called.
Args:
i(int): the position at which to insert the new Group
method is_empty
is_empty()
Returns True if the Indexed Group has no member Groups with contents.
Returns:
bool: True if empty, False if not
method save
save(*args)
Save the groups to a SNIRF file on disk.
When saving, the naming convention defined by the SNIRF spec is enforced: groups are named /<name>1, /<name>2, /<name>3, and so on.
Args:
args(str or h5py.File): A path to a closed SNIRF file on disk or an openh5py.Fileinstance
Examples:
save can be called on an Indexed Group already on disk to overwrite the current contents: mysnirf.nirs[0].stim.save()
or using a new filename to write the Indexed Group there:
>>> mysnirf.nirs[0].stim.save(<new destination>)
class Snirf
method __init__
__init__(*args, dynamic_loading: bool = False, enable_logging: bool = False)
property filename
The filename the Snirf object was loaded from and will save to.
property formatVersion
SNIRF field formatVersion.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This is a string that specifies the version of the file format. This document describes format version "1.0"
property location
The HDF5 relative location indentifier.
property nirs
SNIRF field nirs.
If dynamic_loading=True, the data is loaded from the SNIRF file only when accessed through the getter
This group stores one set of NIRS data. This can be extended by adding the count number (e.g. /nirs1, /nirs2,...) to the group name. This is intended to allow the storage of 1 or more complete NIRS datasets inside a single SNIRF document. For example, a two-subject hyperscanning can be stored using the notation * /nirs1 = first subject's data * /nirs2 = second subject's data The use of a non-indexed (e.g. /nirs) entry is allowed when only one entry is present and is assumed to be entry 1.
method close
close()
Close the file underlying a Snirf instance.
After closing, the underlying SNIRF file cannot be accessed from this interface again. Use close if you need to open a new interface on the same HDF5 file.
close is called automatically by the destructor.
method copy
copy() → Snirf
Return a copy of the Snirf instance.
A copy of a Snirf instance is a brand new HDF5 file in memory. This can be expensive to create. Note that in lieu of copying you can make assignments between Snirf instances.
method is_empty
is_empty()
If the Group has no member Groups or Datasets.
Returns:
bool: True if empty, False if not
method measurementList_to_measurementLists
measurementList_to_measurementLists()
Convert the measurementList field of all Data elements to measurementLists.
Does not delete the measurementList Dataset.
method measurementLists_to_measurementList
measurementLists_to_measurementList()
Converts measurementLists to a measurementList indexed Group structure if it is present.
This method will create new measurementList indexed Group entries populated with the contents of the measurementLists Group.
The measurementList Group is not removed.
method save
save(*args)
Save a SNIRF file to disk.
Args:
args(str or h5py.File or file-like): A path to a closed or nonexistant SNIRF file on disk or an openh5py.Fileinstance
Examples:
save can overwrite the current contents of a Snirf file: mysnirf.save()
or take a new filename to write the file there:
>>> mysnirf.save(<new destination>)
or write to an IO stream:
>>> mysnirf.save(<io.BytesIO stream>)
method validate
validate() → ValidationResult
Validate a Snirf instance.
Returns the validity of the current state of a Snirf object, including modifications made in memory to a loaded SNIRF file.
Returns:
ValidationResult: truthy structure containing detailed validation results
This file was automatically generated via lazydocs.