BUNPC / pysnirf2

Python package for reading, writing and validating Shared Near Infrared Spectroscopy Format (SNIRF) files
GNU General Public License v3.0
15 stars 11 forks source link

Validation of souceLabels #32

Closed samuelpowell closed 2 years ago

samuelpowell commented 2 years ago

The SNIRF specification states that the probe/sourceLabels dataset can "be of size <number of sources>x 1 or <number of sources> x <number of wavelengths>". However, when using pysnirf2 to validate a SNIRF file in which the probe/sourceLabels dataset is two-dimensional, I get an INVALID_DATASET_SHAPE.

I assume this results from the following section of code:

           name = self.location + '/sourceLabels'
            if type(self._sourceLabels) in [type(_AbsentDataset), type(None)]:
                result._add(name, 'OPTIONAL_DATASET_MISSING')
            else:
                try:
                    if type(self._sourceLabels) is type(_PresentDataset) or 'sourceLabels' in self._h:
                        dataset = self._h['sourceLabels']
                    else:
                        dataset = _create_dataset_string_array(tmp, 'sourceLabels', self._sourceLabels)
                    result._add(name, _validate_string_array(dataset, ndims=[1]))

Is this an oversight or have I misunderstood the intent of the specification?

sstucker commented 2 years ago

Yes, this is a mistaken constraint on the dimensionality of sourceLabels and detectorLabels. Thank you! I will advance a fix to the generation code, this likely affects other arrays in the spec