def __extract_nsx_file_spec(self, nsx_nb):
"""
Extract file specification from an .nsx file.
"""
filename = '.'.join([self._filenames['nsx'], 'ns%i' % nsx_nb])
# Header structure of files specification 2.2 and higher. For files 2.1
# and lower, the entries ver_major and ver_minor are not supported.
dt0 = [
('file_id', 'S8'),
('ver_major', 'uint8'),
('ver_minor', 'uint8')]
nsx_file_id = np.fromfile(filename, count=1, dtype=dt0)[0]
if nsx_file_id['file_id'].decode() == 'NEURALSG':
spec = '2.1'
elif nsx_file_id['file_id'].decode() == 'NEURALCD':
spec = '{0}.{1}'.format(
nsx_file_id['ver_major'], nsx_file_id['ver_minor'])
else:
raise IOError('Unsupported NSX file type.')
return spec
评论列表
文章目录