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

Example to use this library for Slicer3D? #111

Open
Optimox opened this issue Nov 9, 2020 · 1 comment
Open

Example to use this library for Slicer3D? #111

Optimox opened this issue Nov 9, 2020 · 1 comment

Comments

@Optimox
Copy link

Optimox commented Nov 9, 2020

Hi,

I'm complete novice in 3D visulization. I have some 3D stacks in Dicom format that I read and use with python to create segmentations based on Machine Learning algorithm.

I'd like to export those segmentations (there are many of them) into a compatible format for 3D slicer. I thought nrrd format would be good but I can't find any tutorial on what 3D slicer is expecting.

Would you, by chance, have any idea on where I can find examples?

Thank you!

@lassoan
Copy link

lassoan commented Nov 30, 2022

3D Slicer can load any 3D nrrd file. There is no special requirement.

Example:

import numpy as np
import nrrd

filename = 'c:/tmp/testdata.nrrd'
data = np.random.randint(100, size=[20,40,30])
header = {
    'space': 'left-posterior-superior',
    'space directions': [[0., 1., 0.], [ 0., 0., -1.], [-1.3, 0., 0.]],
    'space origin': [  86.64489746, -133.92860413,  116.78569794]
}

nrrd.write(filename, data, header)

You can load this into Slicer:

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