Script use .nrrd file but saved .npy

I explain my problem:

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

FROM THIS SITUATION:

Raw Image

TO THIS: enter image description here

File find_borders.py 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 = nrrd.read(data_path+"data/annotations.nrrd")

to:

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

but it returns:

Traceback (most recent call last):
  File "/Users/*****/github/full_mouse_cerebellum/compute_results.py", 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]
10677
molecular layer
Purkinje layer
/Users/*******/github/full_mouse_cerebellum/compute_results.py:91: RuntimeWarning: invalid value encountered in double_scalars
  cell_densities.append(number_cells[-1]/volumes[-1])
/Users/*******/github/full_mouse_cerebellum/compute_results.py:92: RuntimeWarning: invalid value encountered in double_scalars
  neuron_densities.append(number_neurons[-1]/volumes[-1])
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
2937.5
0.0
[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/compute_results.py:145: 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/compute_results.py", 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/fromnumeric.py", line 2706, in amax
    keepdims=keepdims, initial=initial, where=where)
  File "/Users/*******/opt/anaconda3/lib/python3.7/site-packages/numpy/core/fromnumeric.py", 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: https://stackoverflow.com/questions/64668307/script-use-nrrd-file-but-saved-npy

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: