# How to download the 3D Slicer Sample Images?

**URL:** <https://discourse.slicer.org/t/how-to-download-the-3d-slicer-sample-images/36320>\
**Category:** Support\
**Created:** [May 22, 2024, 1:13pm UTC](https://discourse.slicer.org/t/how-to-download-the-3d-slicer-sample-images/36320 "2024-05-22T13:13:38Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![DaniTheStudent](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@DaniTheStudent](https://discourse.slicer.org/u/DaniTheStudent)\
**Post date:** [May 22, 2024, 1:13pm UTC](https://discourse.slicer.org/t/how-to-download-the-3d-slicer-sample-images/36320/1 "2024-05-22T13:13:38Z")

</div>

Hi, i would like to request some help. I am trying to do something with 3d slicer but i also need the images for something else related to C++ and opencv.

I am new in all of this, and found the brain tumor sample to be perfect… however i don’t know how to download the images from it. Could anyone guide me?  
Also i tried finding other images on the internet but for 3 hours i coudn’t find a single useful one… Either unrelated images or they do not load properly, only in the red window

Thanks for the help

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [May 22, 2024, 1:20pm UTC](https://discourse.slicer.org/t/how-to-download-the-3d-slicer-sample-images/36320/2 "2024-05-22T13:20:40Z")

</div>

> [@DaniTheStudent](#):
>
> the brain tumor sample

Can you please identify it? A link or screenshot maybe. Thanks

---

<div class="post-metadata">

**Author:** ![DaniTheStudent](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@DaniTheStudent](https://discourse.slicer.org/u/DaniTheStudent)\
**Post date:** [May 22, 2024, 2:46pm UTC](https://discourse.slicer.org/t/how-to-download-the-3d-slicer-sample-images/36320/3 "2024-05-22T14:46:45Z")

</div>

Sorry for the late reply just came back home, i’ll go eat something quick and be back  
Sure i will send a screenshot, also if you would like we can add each other on discord and i could screenshare my screen (name: Dezmodani)

 ![Imagine în linie](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/4/a4945f29a6717e9fa58582cbd8c3d4738eb70673.jpeg "Imagine în linie")  
MRBrainTumor1, the one on the left

---

<div class="post-metadata">

**Author:** ![mikebind](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mikebind](https://discourse.slicer.org/u/mikebind)\
**Post date:** [May 22, 2024, 7:21pm UTC](https://discourse.slicer.org/t/how-to-download-the-3d-slicer-sample-images/36320/4 "2024-05-22T19:21:54Z")

</div>

When you click on it in SampleData, you download it, so you already have it. If you click “Save”, you can choose what format you want to save the image it in the save scene dialog window. Or, you can go to the Data module, right click on the entry for the image you want, and select “Export to file” to save only the image volume without saving the scene file as well.

---

<div class="post-metadata">

**Author:** ![DaniTheStudent](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@DaniTheStudent](https://discourse.slicer.org/u/DaniTheStudent)\
**Post date:** [May 23, 2024, 4:01pm UTC](https://discourse.slicer.org/t/how-to-download-the-3d-slicer-sample-images/36320/5 "2024-05-23T16:01:24Z")

</div>

Could you please provide some screenshots please? I really struggle to understand how to do it…  
(Also i need all the images not just one)

---

<div class="post-metadata">

**Author:** ![mikebind](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@mikebind](https://discourse.slicer.org/u/mikebind)\
**Post date:** [May 23, 2024, 4:25pm UTC](https://discourse.slicer.org/t/how-to-download-the-3d-slicer-sample-images/36320/6 "2024-05-23T16:25:35Z")

</div>

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/c/ecc650de98dc8549fa9cd415edeb06e4aaf655af.jpeg)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/2/029bb280e9a27be22308ac4226e863a095c2df4c.jpeg)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/f/0f83565cf443d9e77eecd0fc3092aad4b2e05b39.png)

There are many export format options:

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/d/ad9b72972b7a1c3e7998a3a8eefead4e90324b9c.png)

3D Slicer is conceptually built around volumetric images rather than single image slices. The main output formats (NRRD, NifTI, etc) contain all the image slices organized in 3D in a single file. So, when you export MRBrainTumor1, you get all the slices and their 3D organization.

---

<div class="post-metadata">

**Author:** ![DaniTheStudent](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@DaniTheStudent](https://discourse.slicer.org/u/DaniTheStudent)\
**Post date:** [June 1, 2024, 9:59am UTC](https://discourse.slicer.org/t/how-to-download-the-3d-slicer-sample-images/36320/7 "2024-06-01T09:59:23Z")

</div>

Thank you but still doesn’t work. I am trying to get a jpg format not nrrd and i get this error for some reason…

 ![Imagine în linie](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/a/aad4ade719594856750ab40c4e31c25a3d7822a5.jpeg "Imagine în linie")  
Any idea how to solve it? What i want to get is something like this:  
 ![Imagine în linie](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/d/9d3f62dc813b5a0bb51721cb31e309c9359d3ccc.jpeg "Imagine în linie")

Pe joi, 23 mai 2024 la 19:30:48 EEST, Mike Bindschadler via 3D Slicer Community [notifications@slicer.discoursemail.com](mailto:notifications@slicer.discoursemail.com) a scris:

There are many export format options:

3D Slicer is conceptually built around volumetric images rather than single image slices. The main output formats (NRRD, NifTI, etc) contain all the image slices organized in 3D in a single file. So, when you export MRBrainTumor1, you get all the slices and their 3D organization.

–  
_Previous Replies_  
Could you please provide some screenshots please? I really struggle to understand how to do it…  
(Also i need all the images not just one)

Pe miercuri, 22 mai 2024 la 22:21:55 EEST, Mike Bindschadler via 3D Slicer Community [notifications@slicer.discoursemail.com](mailto:notifications@slicer.discoursemail.com) a scris:

When you click on it in SampleData, you download it, so you already have it. If you click “Save”, you can choose what format you want to save the image it in the save scene dialog window. Or, you can go to the Data module, right click on the entry for the image you want, and select “Export to file” to save only the image volume without saving the scene file as well.

–  
_Previous Replies_

Sorry for the late reply just came back home, i’ll go eat something quick and be back  
Sure i will send a screenshot, also if you would like we can add each other on discord and i could screenshare my screen (name: Dezmodani)

MRBrainTumor1, the one on the left

---

<div class="post-metadata">

**Author:** ![DaniTheStudent](https://avatars.discourse-cdn.com/v4/letter/d/5f9b8f/32.png) [@DaniTheStudent](https://discourse.slicer.org/u/DaniTheStudent)\
**Post date:** [June 1, 2024, 4:34pm UTC](https://discourse.slicer.org/t/how-to-download-the-3d-slicer-sample-images/36320/8 "2024-06-01T16:34:25Z")

</div>

NVM i have finally done it!

Here is the python code that i had to introduce in the console

import os  
import slicer  
import vtk  
from vtk.util.numpy\_support import numpy\_to\_vtk

# Define the output directory

outputDir = r’G:/Kaggle imagini/Extract test din 3d slicer/MRBrainTumor1\_Images’  
if not os.path.exists(outputDir):  
os.makedirs(outputDir)

# Load the sample data

import SampleData  
sampleDataLogic = SampleData.SampleDataLogic()  
mrBrainTumorVolume = sampleDataLogic.downloadSample(‘MRBrainTumor1’)

# Get the volume node

volumeNode = slicer.util.getNode(‘MRBrainTumor1’)

# Get the volume array

volumeArray = slicer.util.arrayFromVolume(volumeNode)

# Save each slice as a JPG file

numSlices = volumeArray.shape[0]  
for sliceIndex in range(numSlices):  
sliceArray = volumeArray[sliceIndex, :, :]

# Flip the array vertically

sliceArray = sliceArray[::-1, :]

# Convert the numpy array to a vtkImageData

vtkImageData = vtk.vtkImageData()  
vtkImageData.SetDimensions(sliceArray.shape[1], sliceArray.shape[0], 1)  
vtkImageData.AllocateScalars(vtk.VTK\_UNSIGNED\_CHAR, 1)  
sliceArrayVtk = numpy\_to\_vtk(sliceArray.ravel(), deep=True, array\_type=vtk.VTK\_UNSIGNED\_CHAR)  
vtkImageData.GetPointData().SetScalars(sliceArrayVtk)

# Write the slice to a JPG file

writer = vtk.vtkJPEGWriter()  
sliceFilename = os.path.join(outputDir, f’MRBrainTumor1\_slice{sliceIndex:03}.jpg’)  
writer.SetFileName(sliceFilename)  
writer.SetInputData(vtkImageData)  
writer.Write()

print(“Export completed.”)

Pe joi, 23 mai 2024 la 19:30:48 EEST, Mike Bindschadler via 3D Slicer Community [notifications@slicer.discoursemail.com](mailto:notifications@slicer.discoursemail.com) a scris:

There are many export format options:

3D Slicer is conceptually built around volumetric images rather than single image slices. The main output formats (NRRD, NifTI, etc) contain all the image slices organized in 3D in a single file. So, when you export MRBrainTumor1, you get all the slices and their 3D organization.

–  
_Previous Replies_  
Could you please provide some screenshots please? I really struggle to understand how to do it…  
(Also i need all the images not just one)

Pe miercuri, 22 mai 2024 la 22:21:55 EEST, Mike Bindschadler via 3D Slicer Community [notifications@slicer.discoursemail.com](mailto:notifications@slicer.discoursemail.com) a scris:

When you click on it in SampleData, you download it, so you already have it. If you click “Save”, you can choose what format you want to save the image it in the save scene dialog window. Or, you can go to the Data module, right click on the entry for the image you want, and select “Export to file” to save only the image volume without saving the scene file as well.

–  
_Previous Replies_

Sorry for the late reply just came back home, i’ll go eat something quick and be back  
Sure i will send a screenshot, also if you would like we can add each other on discord and i could screenshare my screen (name: Dezmodani)

MRBrainTumor1, the one on the left
