Declaration: TMetaData.CountSpectralGroups (FirstLayer, LastLayer: integer): integer;
Returns the number of currently defined non-zero spectral groups in the range between (and including) FirstLayer and LastLayer. If any of the parameters is outside the range of available layers it is automatically adjusted to the nearest limit (either 1 or SizeL). Calling the function with both parameters set to zero is equivalent to checking all layers of the dataset.

Hint: In order to directly access the metadata of the currently loaded dataset you can use the pre-declared global variable MData.