Write subvolumes into .h5 format

Hi

How exactly do you write the extracted subvolumes into .h5 format?
I have been trying on this but seems I’m not doing it the right way.
And also is there any visualising tool to check the .h5 file is correct or not?

Hi @Shay,

A few years ago I wrote code to make a .h5 file for some images, hope this helps. Also, I used jupyter notebook to visualise the files.

import numpy as np
import h5py
import glob

from matplotlib.image import imread

image = {}
I=0
img_mask = '/Users/mubsi/Desktop/Total2/*.jpg'
img_names = glob.glob(img_mask)
for fn in img_names:
    print(i, fn)
    image[i] = imread(fn)
    i = i + 1

with h5py.File('/Users/mubsi/Desktop/Test.h5', 'w' ) as hdf:
    hdf.create_dataset('trainSet_x', shape=(47,64,64))
    dset = hdf['trainSet_x']
    for x in range(0, 47):
        dset[x] = image[x]

Cheers,
Mubsi

1 Like

Hi @Mubsi,
Thanks for answering my question.
I thought the write-in method I used was wrong. But I recently found that when I generate the training volume on google colab, the data in the .h5 file became null. It’s pretty weird… the file size was 11.5MB and after training it became 800KB