# Unable to load tiff sequence created by python3 tifffile module

**URL:** <https://discourse.slicer.org/t/unable-to-load-tiff-sequence-created-by-python3-tifffile-module/1792>\
**Category:** Support\
**Created:** [January 9, 2018, 2:51pm UTC](https://discourse.slicer.org/t/unable-to-load-tiff-sequence-created-by-python3-tifffile-module/1792 "2018-01-09T14:51:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![hclai](https://avatars.discourse-cdn.com/v4/letter/h/e0b2c6/32.png) [@hclai](https://discourse.slicer.org/u/hclai)\
**Post date:** [January 9, 2018, 2:51pm UTC](https://discourse.slicer.org/t/unable-to-load-tiff-sequence-created-by-python3-tifffile-module/1792/1 "2018-01-09T14:51:28Z")

</div>

Operating system: Windows 10  
Slicer version: 4.8.1  
Expected behavior: Load tiff sequence created by python3 tifffile module and render the volume  
Actual behavior: The loading bar shows up but the Active Volume is empty.

I try to create tiff sequence with python 3.4.5 on a CentOS 7 server. The py code is demonstrated as follow:

============================TIFF generation============================

```auto
import numpy as np
import tifffile as tiff

data = np.zeros((x_axis, y_axis, z_axis)) #just a sample
for z in range(z_axis):
  tiff.imsave(str(z)+'.tiff', data[:, :, z])
  image = tiff.imread(str(z)+'.tiff')
  print(np.array_equal(image, data[:, :, z])) #always print True

```

============================TIFF generation============================

The last line of the code always print True, which means that I can successfully write and load the tiff image and they are the same.

However, when I try to load it with Slicer, it fails. The steps I take was:

1. Add data
2. Choose a directory and add
3. Show options and uncheck singlefile

The loading bar shows up and finishes. However, the Active Volume in the Volume module is empty. I cannot select volume loaded from Volume Rendering module, either. I’m wondering where I do it wrong.

Thanks for answering!

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ihnorton/32/9_2.png) [@ihnorton](https://discourse.slicer.org/u/ihnorton)\
**Post date:** [January 9, 2018, 2:55pm UTC](https://discourse.slicer.org/t/unable-to-load-tiff-sequence-created-by-python3-tifffile-module/1792/2 "2018-01-09T14:55:39Z")

</div>

> [@hclai](#):
>
> Choose a directory and add

Try `Choose files to add` rather than adding directory. Also, does the file load in other software?

If that doesn’t work, you could upload a (small) example file for someone to look at.

(by the way, for code you can quote with triple-backtick: “```”`)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [January 9, 2018, 3:12pm UTC](https://discourse.slicer.org/t/unable-to-load-tiff-sequence-created-by-python3-tifffile-module/1792/3 "2018-01-09T15:12:50Z")

</div>

See detailed instructions here: [https://www.slicer.org/wiki/Documentation/4.6/FAQ#How\_to\_load\_data\_from\_a\_sequence\_of\_jpg.2C\_tif.2C\_or\_png\_files.3F](https://www.slicer.org/wiki/Documentation/4.6/FAQ#How_to_load_data_from_a_sequence_of_jpg.2C_tif.2C_or_png_files.3F)

---

<div class="post-metadata">

**Author:** ![hclai](https://avatars.discourse-cdn.com/v4/letter/h/e0b2c6/32.png) [@hclai](https://discourse.slicer.org/u/hclai)\
**Post date:** [January 9, 2018, 3:34pm UTC](https://discourse.slicer.org/t/unable-to-load-tiff-sequence-created-by-python3-tifffile-module/1792/4 "2018-01-09T15:34:34Z")

</div>

Thanks for your comment. I also try to open the tiff files with GIMP 2 but it doesn’t work either.  
I tried to upload some examples but it says tiff files are not authorized. Only jpg, png, gif is allowed.

I’m wondering if the data type of the numpy array should be uint16 or anything else. The original intensities are designed to be 16 bit unsigned integer. However, although I tried to modify the array to np.uint16, the output tiff files are still unreadable.

---

<div class="post-metadata">

**Author:** ![hclai](https://avatars.discourse-cdn.com/v4/letter/h/e0b2c6/32.png) [@hclai](https://discourse.slicer.org/u/hclai)\
**Post date:** [January 9, 2018, 3:37pm UTC](https://discourse.slicer.org/t/unable-to-load-tiff-sequence-created-by-python3-tifffile-module/1792/5 "2018-01-09T15:37:53Z")

</div>

Thanks for your comment. I tried your suggestion but it also failed.  
There is no options for me in “Active Volume” in Volume module.

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ihnorton/32/9_2.png) [@ihnorton](https://discourse.slicer.org/u/ihnorton)\
**Post date:** [January 9, 2018, 4:09pm UTC](https://discourse.slicer.org/t/unable-to-load-tiff-sequence-created-by-python3-tifffile-module/1792/6 "2018-01-09T16:09:17Z")

</div>

If the file doesn’t load in GIMP then it certainly won’t load in Slicer, unfortunately. (your code sample doesn’t run as-is so I can’t try it myself)

> [@hclai](#):
>
> I tried to upload some examples but it says tiff files are not authorized.

Try dropbox, onedrive, etc and post a link.

---

<div class="post-metadata">

**Author:** ![hclai](https://avatars.discourse-cdn.com/v4/letter/h/e0b2c6/32.png) [@hclai](https://discourse.slicer.org/u/hclai)\
**Post date:** [January 10, 2018, 5:26am UTC](https://discourse.slicer.org/t/unable-to-load-tiff-sequence-created-by-python3-tifffile-module/1792/7 "2018-01-10T05:26:08Z")

</div>

Thanks for your help! I think I just figure it out and solve it.  
The data type of 3D numpy array should be “float32” so that the output image can be correctly loaded and rendered.
