Hdf5 to NRRD to SEQ.NRRD

You can write a valid seq.nrrd file from an img numpy array of size (26, 102, 102, 61) (corresponds to number of volumes, colums, rows, slices):

import nrrd
header = {
    'type': 'int',
    'dimension': 4,
    'space': 'right-anterior-superior',
    'space directions': [[     float('nan'),      float('nan'),      float('nan')], [1.953125, 0.      , 0.      ], [0.      , 1.953125, 0.      ], [0.      , 0.      , 1.953125]],
    'kinds': ['list', 'domain', 'domain', 'domain'],
    'labels': ['frame', '', '', ''], 
    'endian': 'little',
    'encoding': 'raw',
    'space origin': [-137.16099548,  -36.80649948, -309.71899414],
    'measurement frame': [[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]],
    'axis 0 index type': 'numeric',
    'axis 0 index values': '0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25'
}
nrrd.write("c:/tmp/test.seq.nrrd", img, header)
1 Like