Skip to content
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

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

Open
scorpio921 opened this issue Jun 28, 2024 · 2 comments

Comments

@scorpio921
Copy link

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

@jbms
Copy link
Collaborator

jbms commented Jun 28, 2024

By 3-d model, do you mean volume rendering in the 3d panel?

You have to enable that by selecting "Volume rendering" in the "Rendering" tab of the layer.

@scorpio921
Copy link
Author

@jbms Thanks ,you are right, but, I have one more question. Why doesn't my 2D image have rendering nodes and the 3D model looks very blurry? Do you know why
image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants