Homer3 icon indicating copy to clipboard operation
Homer3 copied to clipboard

[BUG]: Origin/delta time vector in compliant SNIRF data is unsupported

Open samuelpowell opened this issue 1 year ago • 0 comments

Version of Homer3 you are using

v1.80.2 & master

Your environment (MATLAB environment and OS)

OS and MATLAB independent

Description of the issue

The SNIRF specification allows for the time vector to be either equal in length to the associated data time series, or to be of length two, containing the start time and the sample time spacing.

/nirs(i)/data(j)/time

Presence: required Type: numeric 1-D array Location: /nirs(i)/data(j)/time

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 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.

However, when loading the data, Homer3 asserts that the time vector corresponds only to option one of the specification, as can be seen here:

https://github.com/BUNPC/Homer3/blob/666ab6d0b054e9b2eb829d62736aaa2148638f67/DataTree/AcquiredData/Snirf/DataClass.m#L299-L301

As such, Homer3 throws an error when loading standards compliant SNIRF files.

(debugged by @ernesto-vidal)

Steps to reproduce: Attempt to load a SNIRF file with a time vector of length two, corresponding to option two of the SNIRF specification for this field.

Expected behavior: A standards compliant implementation will extrapolate the time series based upon the initial time series and delta.

Actual behavior: Homer3 indicates an error (-3) and does not load the data.

samuelpowell avatar Jun 16 '23 15:06 samuelpowell