Script use .nrrd file but saved .npy

I explain my problem:

BACKGROUND: I used a file to correct a particular section of cerebellum image like this.


Raw Image

TO THIS: enter image description here

File help me with a GUI to correct the file that saved like annotation_corrected5.npy

The next step will be use everyslice created with this tool for build a 3D structure like this (it's another region, not the one of topic):

Another region

Now: the original file was a .nrrd called annotations.nrrd. But the last save of my modify will always be .npy file.

I simply try to call .npy file from:

ann, h ="data/annotations.nrrd")


ann, h = np.load(data_path+"data/annotation_corrected5.npy")

but it returns:

Traceback (most recent call last):
  File "/Users/*****/github/full_mouse_cerebellum/", line 29, in <module>
    ann, h = np.load(data_path+"data/annotation_corrected5.npy")
ValueError: too many values to unpack (expected 2)

So I try to correct with:

ann = np.load(data_path+"data/annotation_corrected5.npy")

h = np.load(data_path+"data/annotation_corrected5.npy")

And the code run.

The problem will be with this error line with "RuntimeWarning":

dens cell  (528, 320, 456)
orientation:  (3, 528, 320, 456)
(528, 320, 456)
[10677, 10676, 10675]
molecular layer
Purkinje layer
/Users/*******/github/full_mouse_cerebellum/ RuntimeWarning: invalid value encountered in double_scalars
/Users/*******/github/full_mouse_cerebellum/ RuntimeWarning: invalid value encountered in double_scalars
granular layer
['Crus 1, molecular layer', 'Crus 1, Purkinje layer', 'Crus 1, granular layer', 'Crus 1']
i_molecular:  0
Volume molecular layer: 3.246390625
Volume purkinje layer: 0.0
Volume granular layer: 2.9016875
[12.5 12.5 12.5 ... 62.5 62.5 62.5]
Mean down layer:  0.0
Mean up layer:  0.0
/Users/*******/github/full_mouse_cerebellum/ RuntimeWarning: invalid value encountered in true_divide
  + down_layer_distance)
Volume Stellate layer: 0.0
Volume Basket layer: 3.246390625
Total volume: 6.148078125
Voxels Granular layer: 185708
Voxels Purkinje layer: 0
Voxels Stellate layer: 0
Voxels Basket layer: 207769
Traceback (most recent call last):
  File "/Users/*******/github/full_mouse_cerebellum/", line 173, in <module>
    print("Density stellate cells - max: ", np.amax(density_stellate_all),", min: ", np.amin(density_stellate_all))
  File "<__array_function__ internals>", line 6, in amax
  File "/Users/*******/opt/anaconda3/lib/python3.7/site-packages/numpy/core/", line 2706, in amax
    keepdims=keepdims, initial=initial, where=where)
  File "/Users/*******/opt/anaconda3/lib/python3.7/site-packages/numpy/core/", line 87, in _wrapreduction
    return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
ValueError: zero-size array to reduction operation maximum which has no identity

The first part is correct (apparently), but I can't fix this problem.

I thought to convert .npy in .nrrd to bypass directly the issue.

Could be a good idea?

If yes: could anyone help me for conversion?

Thanks a lot for patient.

Read more here:

Content Attribution

This content was originally published by SimoneT at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: