-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can I convert h5 format to knossos dataset? #28
Comments
Hi,
|
Thanks for the reply, I borrowed your code and got an error when I tried to convert a 3d h5 dataset to knossos form from knossos_utils import KnossosDataset
import numpy as np
import h5py
import os
from h5IO import ReadH5File
if __name__ == '__main__':
dataset_name = "cremi-sampleA"
target_dataset_folder = "/code/Syconn2/SyConn/data/knossosdatasets/"
scale = [4, 4, 40] # nm per voxel size
conf_path = f'{target_dataset_folder}/{dataset_name}.k.toml'
if os.path.exists(conf_path):
os.remove(conf_path)
# load h5 into memory
raw = ReadH5File("./sampleA_raw.h5")
seg = ReadH5File("./sampleA-segmentation.h5")
# only accepts destination datatypes np.uint8 or np.uint16 (raw) or np.uint64 (segmentation).
raw = raw.astype(np.uint8)
raw = raw.transpose(2, 1, 0) # (z,y,x) - > (x,y,z)
seg = seg.astype(np.uint64)
seg = seg.transpose(2, 1, 0)
# for 2d data, add z axis of size 1
# raw = raw[None]
# seg = seg[None]
ds = KnossosDataset.initialize_from_array(
data=raw,
experiment_name=dataset_name,
cube_shape=(128, 128, 128), # (512, 512, 1) for 2d data
scale=scale,
ds_factor=(2, 2, 2), # (2, 2, 1) for 2d data
file_extensions=('.jpg', '.png'), # available: .jpg, .png, .raw
write_path=target_dataset_folder
)
KnossosDataset.initialize_from_array(
data=seg,
experiment_name=dataset_name,
cube_shape=(128, 128, 128), # (512, 512, 1) for 2d data
scale=scale,
ds_factor=(2, 2, 2), # (2, 2, 1) for 2d data
file_extensions=('.seg.sz.zip',),
parent_dataset=ds
)
When I debugging the error place in
I found the How can i fix it? 😭 |
The lines of code in your stacktrace indicate to me that you don’t have the latest state of knossos_utils. Can you check? |
If my EM neuron image data and the corresponding segmentation data are saved in h5 form as volume, how do I convert to knossos dataset?
The text was updated successfully, but these errors were encountered: