# what thing do I miss to create volume sequence from tiff

**URL:** <https://discourse.slicer.org/t/what-thing-do-i-miss-to-create-volume-sequence-from-tiff/20039>\
**Category:** Support\
**Tags:** sequences, python, nrrd\
**Created:** [October 6, 2021, 7:00pm UTC](https://discourse.slicer.org/t/what-thing-do-i-miss-to-create-volume-sequence-from-tiff/20039 "2021-10-06T19:00:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![BingYen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/bingyen/32/8904_2.png) [@BingYen](https://discourse.slicer.org/u/BingYen)\
**Post date:** [October 6, 2021, 7:00pm UTC](https://discourse.slicer.org/t/what-thing-do-i-miss-to-create-volume-sequence-from-tiff/20039/1 "2021-10-06T19:00:42Z")

</div>

Hi,  
I’m new to Slicer and Python  
I want to load 512x512x619x9 uint16 data from microscopy into Slicer as volume sequence data.

First, I save ome.tiff as nrrd (_C2withmeta.nrrd_) via Fiji after I checked the properties.  
I tried load it in slicer but it became 512x512x5571.  
Then I used python to edit and save nrrd data via CMD.  
(Python 3.8.11 (default, Aug 3 2021, 06:49:12) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32)

[From this post, I tried to add some header for .seq.nrdd and reshape to make frame as first dimension.](https://discourse.slicer.org/t/hdf5-to-nrrd-to-seq-nrrd/18277/4)

Here are the code

```auto
import numpy as np
import nrrd
import os
filename = "~/Desktop/C2nrrd/C2withmeta.nrrd"
filedata, fileheader = nrrd.read(filename)
filedata.shape
(512, 512, 5571)
newdata = filedata.reshape(619,512,512,9)
newheader = {
    'type': 'uint16',
    'encoding': 'raw',
    'endian': 'big',
    'dimension': 4,
    'sizes': [619, 512, 512,9],
    'kinds': ['list', 'domain', 'domain', 'domain'],
    'labels': ['frame', '', '', ''],
    'space': 'right-anterior-superior',
    'space dimension': 3, 
    'space directions': [[0.184687, 0. , 0.], [0. , 0.184687, 0.], [0. , 0. , 3.75]],
    'space origin': [0, 0, 0],
    'space units': ['s','microns', 'microns', 'microns'],
    'measurement frame': [[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]],
    'axis 0 index type': 'numeric',
    'axis 0 index values': tuple(range(0,619))
    }
outname = "~Desktop/C2nrrd/C2new2.nrrd" 
nrrd.write (outname, newdata, newheader)

```

I tried save .nrrd or .seq.nrrd and tried load them in slicer as volum or sequence, but all failed.  
when I load it as sequence, error

> Error: Loading ~/Desktop/C2nrrd/C2new.seq.nrrd - Failed to read node C2new\_1 (vtkMRMLSequenceNode2) from filename=‘~/Desktop/C2nrrd/C2new.seq.nrrd’

when I load it as volume

> Error: Loading ~/Desktop/C2nrrd/C2new.seq.nrrd - load failed.

So I want to know what is the problem?

---

<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:** [October 7, 2021, 5:20am UTC](https://discourse.slicer.org/t/what-thing-do-i-miss-to-create-volume-sequence-from-tiff/20039/2 "2021-10-07T05:20:39Z")

</div>

There are a number of differences between your header fields and the working example looked. Do not add any extra fields (`space dimension`, `sizes`, …) and specify `space directions`, and `set axis 0 index vales` as a space separated list.

I would recommend to first start with a small volume, for example 62x512x512x9 (it can be a small patch that you cut from the full volume). If it fails then upload the .seq.nrrd file somewhere and I’ll take a look.

---

<div class="post-metadata">

**Author:** ![BingYen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/bingyen/32/8904_2.png) [@BingYen](https://discourse.slicer.org/u/BingYen)\
**Post date:** [October 7, 2021, 5:22pm UTC](https://discourse.slicer.org/t/what-thing-do-i-miss-to-create-volume-sequence-from-tiff/20039/3 "2021-10-07T17:22:32Z")

</div>

Thank your reply, lassoan.

In this [post](https://github.com/SlicerRt/Sequences/issues/31), there is `size` field and the `space directions` looks like it is a 4D list.

So I don’t understand this

> [@lassoan](#):
>
> Do not add any extra fields ( `space dimension` , `sizes` , …) and specify `space directions` , and `set axis 0 index vales` as a space separated list.

1. Where should I put `size` info in my data?

2. What should `space directions` look like?  
`[[nan,nan,nan], [0.184687, 0. , 0.], [0. , 0.184687, 0.], [0. , 0. , 3.75]` ?  
or  
`[nan], [0.184687, 0. , 0.], [0. , 0.184687, 0.], [0. , 0. , 3.75]` ?

---

<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:** [October 7, 2021, 5:56pm UTC](https://discourse.slicer.org/t/what-thing-do-i-miss-to-create-volume-sequence-from-tiff/20039/4 "2021-10-07T17:56:47Z")

</div>

> [@BingYen](#):
>
> - Where should I put `size` info in my data?

Nowhere. Size is defined by your numpy array.

> [@BingYen](#):
>
> What should `space directions` look like?

It should be the same as [the working example](https://discourse.slicer.org/t/hdf5-to-nrrd-to-seq-nrrd/18277/4) - with three `float('nan')` values.

---

<div class="post-metadata">

**Author:** ![BingYen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/bingyen/32/8904_2.png) [@BingYen](https://discourse.slicer.org/u/BingYen)\
**Post date:** [October 8, 2021, 6:32am UTC](https://discourse.slicer.org/t/what-thing-do-i-miss-to-create-volume-sequence-from-tiff/20039/5 "2021-10-08T06:32:09Z")

</div>

Thank you for reply, lassoan

I found the problem also come from units,  
it doesn’t accept others except time,  
so I successfully load it in using `'units': "s", "","",""`

---

<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:** [October 9, 2021, 7:49pm UTC](https://discourse.slicer.org/t/what-thing-do-i-miss-to-create-volume-sequence-from-tiff/20039/6 "2021-10-09T19:49:26Z")

</div>

Yes, you need to follow the nrrd standard - see details here: [http://teem.sourceforge.net/nrrd/format.html](http://teem.sourceforge.net/nrrd/format.html)

Could you post your final, working code snippet for future reference?
