# Does Slicer Allow Us to Export a Single Slice?

**URL:** https://discourse.vtk.org/t/does-slicer-allow-us-to-export-a-single-slice/3158
**Category:** Support
**Created:** [April 25, 2020, 7:02pm UTC](https://discourse.vtk.org/t/does-slicer-allow-us-to-export-a-single-slice/3158 "2020-04-25T19:02:05Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![MichelleKline](https://discourse.vtk.org/user_avatar/discourse.vtk.org/michellekline/32/2155_2.png) [@MichelleKline](https://discourse.vtk.org/u/MichelleKline)
#### Post date: [April 25, 2020, 7:02pm UTC](https://discourse.vtk.org/t/does-slicer-allow-us-to-export-a-single-slice/3158/1 "2020-04-25T19:02:06Z")

</div>

Hello,  
Is there a way in Slicer to export the currently displayed (and likely reformatted) slice of a volume to an output file?  
For example, I have loaded a double-oblique DICOM, and I am viewing the volume in an axial orientation in Slicer. I “scroll through” the slices of the volume to a slice of interest, and now I would like to export that slice. Preferably to a text file. Is this possible?  
Thank you,  
Michelle

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [April 25, 2020, 7:13pm UTC](https://discourse.vtk.org/t/does-slicer-allow-us-to-export-a-single-slice/3158/2 "2020-04-25T19:13:40Z")

</div>

Probably this question is better suited to the 3D Slicer forum, but I answer here anyway.

In 3D Slicer, You can save the frame as it is displayed using Screen Capture module (using GUI or [Python scripting](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Capture)).

However, probably what you need is not the displayed image (with annotations, overlays, etc.) but the resliced input volume as a vtkImageData or numpy array ([this example](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Get_reformatted_image_from_a_slice_viewer_as_numpy_array) shows how).

Text file is for humans to read, so if your image contains more than a few hundred pixels then you should not ever think about saving it as text file, because you’ll not be able to read it and it is a very bad file format otherwise (wastes storage space and very slow to read/write). Instead, save it in a standard image file format if you want to view it as an image; or get it as a numpy array if you want to manually inspect, slice, or plot parts of it.

---

<div class="post-metadata">

### Author: ![MichelleKline](https://discourse.vtk.org/user_avatar/discourse.vtk.org/michellekline/32/2155_2.png) [@MichelleKline](https://discourse.vtk.org/u/MichelleKline)
#### Post date: [May 4, 2020, 10:01pm UTC](https://discourse.vtk.org/t/does-slicer-allow-us-to-export-a-single-slice/3158/3 "2020-05-04T22:01:28Z")

</div>

Thank you, Andras. I apologize for not posting my question in the appropriate forum.  
You are correct that what I am really after is the vtkImageData or numpy array. Using the example that you pointed me to, I was able to figure out how to export the data and save it to a .npy file. I had never used the Python interpreter from within Slicer, so that was new. Now I just need to figure out how to read the .npy file in C++.

- Michelle

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [May 4, 2020, 11:08pm UTC](https://discourse.vtk.org/t/does-slicer-allow-us-to-export-a-single-slice/3158/4 "2020-05-04T23:08:37Z")

</div>

Numpy is great for processing data, but I would not use numpy to save the array. because .npy files are not easy to read/write it without numpy. Instead, you can use a standard research image file format, such metaimage, as it is very simple and VTK and many other libraries has readers/writers for it (see [vtkMetaImageWriter](https://vtk.org/doc/nightly/html/classvtkMetaImageWriter.html)).
