rosalindfranklininstitute / parakeet

Phantom generator
GNU General Public License v3.0
18 stars 5 forks source link

Add ability to export corrected mrc file to HDF5 #21

Open jmp1985 opened 2 years ago

DimitriosBellos commented 2 years ago

James thank for adding this issue. It will truly help me greatly to have this feature, because in order to use corrected image in conjuction with a deep learning approach they need to first by exported as hdf5 files. This is because hdf5 files allow multiple parallel reads (while mrc files do not), which is neccessary the fast supply of training instances to a neural network, allowing it to train within a reasonable time period.

jmp1985 commented 2 years ago

Hi Dimitrios

If this is something you really need now, I suggest writing a little script. I will try to implement this properly but in the meantime something like:

import h5py
import mrcfile

# Read mrcfile
infile = mrcfile.open(input_filename)
data = infile.data

# Write hdf5 file
outfile = h5py.File(output_filename)
outfile.create_dataset("data", shape=data.shape, dtype=data.dtype)
outfile["data"][:] = data[:]

This won't propagate any metadata but that may be ok for your usage for the moment.