@Josiah_McAllister (Josiah McAllister) posted a new topic, subject "How can I convert an rtstruct to an nrrd". It read:

   Operating system: Windows  
    Slicer version:4.6.2  
    Expected behavior:  
    Actual behavior:

@lassoan (Andras Lasso) replied

    In Segmentations module change Master representation to binary labelmap (click `Make master` button in the `Binary labelmap` row in Representations section) then save the scene. Structure sets may overlap, therefore the nrrd file will be a 4-dimensional volume, each segment is stored in a separate 3D subvolume.
    
    Use latest nightly build, it's stable and contains many fixes and improvements.

To which @Josiah_McAllister (Josiah McAllister) replied

    Thank you for the help

Then @gcsharp (Greg Sharp) said

    Andras, is there a way to create a separate 3D volume file for each segment?
    
    The information in this e-mail is intended only for the person to whom it is  
    addressed. If you believe this e-mail was sent to you in error and the e-mail  
    contains patient information, please contact the Partners Compliance HelpLine at  
    http://www.partners.org/complianceline . If the e-mail was sent to you in error  
    but does not contain patient information, please contact the sender and properly  
    dispose of the e-mail.

@Josiah_McAllister (Josiah McAllister) replied

    Andras, is there a way to get my segmentation and my image to both be the  
    same dimensions?

Then @lassoan (Andras Lasso) said

    gcsharp:
    
    > Andras, is there a way to create a separate 3D volume file for each segment?
    
    This option is not easily available for the user. You can load the .seg.nrrd file as a volume sequence if you choose “Volume Sequence” in the Add data dialog and then save it, but by default it is saved again as a 4D sequence. You would need to change the default storage node to vtkMRMLSequenceStorageNode to save as a zip file that contains each volume as a separate file.
    
    ITK and VTK can both read volume sequences from 4D files, we also have a Matlab reader/writer that supports 4D volumes, so we never needed them as separate volumes.

So @lassoan (Andras Lasso) replied

    Josiah_McAllister:
    
    > is there a way to get my segmentation and my image to both be the  
    >  same dimensions?
    
    Segmentation will have the same origin, axis direction, and spacing as the input image, but extent usually does not match the input image.
    
    Note that the nrrd header contains SegmentN_Extent:=imin imax jmin jmax kmin kmax field that you can use to efficiently extract only that part of the 3D volume where your particular segment is. You can copy that extent into a larger volume that matches extent of your image.

So @lassoan (Andras Lasso) replied

    2 posts were split to a new topic: Convert image and segmentation to DICOM

After which, @lassoan (Andras Lasso) added

    A post was merged into an existing topic: Convert image and segmentation to DICOM

So @mete_naz (Mete Naz) replied

    Andras,
    
    Is there a way to share the code with us? I have been trying to figure out how to read my segmented nrrd file however i has been giving me a lot of issues so I couldn't… I would appreciate if you could possible share your code with me.
    
    Thanks!

@lassoan (Andras Lasso) replied

    Segmentation is a 4D image in standard nrrd format. You can read it using either VTK or ITK nrrd reader or any nrrd reader that supports 4D volumes. See for example how Slicer reads it: https://github.com/Slicer/Slicer/blob/0ab294089b4827fea3272417a23c321d57e391b4/Libs/MRML/Core/vtkMRMLSegmentationStorageNode.cxx#L290


{'source': 'discourse', 'url': 'https://discourse.slicer.org/t/how-can-i-convert-an-rtstruct-to-an-nrrd/539', 'title': 'How can I convert an rtstruct to an nrrd', 'views': 1995, 'has_accepted_answer': False, 'word_count': 768, 'like_count': 0, 'reply_count': 10, 'participant_count': 4, 'posts': 11, 'tags': '', 'author': '@Josiah_McAllister (Josiah McAllister)', 'participants': '@Josiah_McAllister (Josiah McAllister), @lassoan (Andras Lasso), @gcsharp (Greg Sharp), @mete_naz (Mete Naz)', 'image_url': [None], 'created_at': '2017-06-20T13:48:27.248Z', 'last_posted_at': '2018-03-05T23:06:09.467Z'}