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

sw2vtkImage doesn't include spacing or origin (fixed in pymodule_conv) #899

Closed
cchriste opened this issue Jan 14, 2021 · 7 comments
Closed
Assignees

Comments

@cchriste
Copy link
Contributor

vtkImg.spacing = swImg.spacing() needs to be added to this function
Might also be able to maintain origin and other parts of the Image.

@cchriste cchriste self-assigned this Jan 14, 2021
@cchriste
Copy link
Contributor Author

related to #825

@cchriste
Copy link
Contributor Author

It might help to show the function here. This is from the "getting-started-with-exploring-segmentations" notebook, and the function will soon be included directly in the shapeworks module.

# a helper function that converts shapeworks Image object to vtk image
def sw2vtkImage(swImg, verbose = False):
            
    # get the numpy array of the shapeworks image
    array  = swImg.toArray()
    
    # the numpy array needs to be permuted to match the shapeworks image dimensions
    array = np.transpose(array,(2,1,0))
    
    # converting a numpy array to a vtk image using pyvista's wrap function
    vtkImg = pv.wrap(array)
    
    if verbose:
        print('shapeworks image header information: ')
        print(swImg)

        print('\nvtk image header information: ')
        print(vtkImg) 
    
    return vtkImg

@cchriste
Copy link
Contributor Author

Add this to the function and it works (it'll be added to helper function in pymodule branch):

    # set spacing
    spacing = swImg.spacing()
    vtkImg.spacing = [spacing[0], spacing[1], spacing[2]]
    
    # set origin
    origin = img.origin()
    vtkImg.origin = [origin[0], origin[1], origin[2]]

@cchriste cchriste changed the title sw2vtkImage doesn't include spacing sw2vtkImage doesn't include spacing or origin (fixed in pymodule) Jan 21, 2021
@sheryjoe sheryjoe modified the milestones: 6.0 Leftover, 6.1 Release (May 2021) Feb 15, 2021
@cchriste cchriste added the QA label Feb 22, 2021
@archanasri archanasri changed the title sw2vtkImage doesn't include spacing or origin (fixed in pymodule) sw2vtkImage doesn't include spacing or origin Mar 24, 2021
@archanasri archanasri removed the QA label Mar 24, 2021
@archanasri
Copy link
Contributor

Done in pymodule_conv

@archanasri archanasri changed the title sw2vtkImage doesn't include spacing or origin sw2vtkImage doesn't include spacing or origin (fixed in pymodule_conv) Apr 5, 2021
@sheryjoe
Copy link
Contributor

@archanasri can we close this?

@sheryjoe
Copy link
Contributor

@archanasri is this still an issue?

@archanasri
Copy link
Contributor

Done.

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

3 participants