google / google/neuroglancer

There is no 3D model displayed after converting the nrrd format or tif images into the required data for neuroplanner

Open
#605 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.5k
Forks
389
Avg merge
3d 21h
Merged PRs (30d)
3

Description

### code

import numpy as np
from cloudvolume import CloudVolume
from cloudvolume.lib import Bbox
import nrrd

print(dir(nrrd))


nrrd_file_path = './I.nrrd'
data, header = nrrd.read(nrrd_file_path)


print("Original NRRD data shape:", data.shape)
print("Original NRRD data type:", data.dtype)
print("Data min:", np.min(data))
print("Data max:", np.max(data))


normalized_data = ((data - np.min(data)) / (np.max(data) - np.min(data)) * 255).astype(np.uint8)


print("Normalized data min:", np.min(normalized_data))
print("Normalized data max:", np.max(normalized_data))
print("Normalized data type:", normalized_data.dtype)


output_path = 'file:///path/to/nrrd'
volume = CloudVolume(output_path, info={
'type': 'image',
'data_type': 'uint8',
'num_channels': 1,
'scales': [{
'resolution': [2,2, 2],
'size': normalized_data.shape,
"key": "d2",
'chunk_sizes': [[64, 64, 64]],
'encoding': 'raw'
}]
}, compress=False)


volume.commit_info()


bbox = Bbox((0, 0, 0), normalized_data.shape)


volume[bbox] = normalized_data


downloaded_data = volume[bbox]
print("Downloaded data shape:", downloaded_data.shape)
print("Downloaded data type:", downloaded_data.dtype)
print("Downloaded data min:", np.min(downloaded_data))
print("Downloaded data max:", np.max(downloaded_data))

print("TIFF data has been converted and uploaded to precomputed format.")

![image](https://github.com/google/neuroglancer/assets/41108082/1320ebff-17b6-4b89-be5c-15b756c2fdcf)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.