Open BEGINRX opened 2 months ago
Hey @BEGINRX, seems like the problem is in the read_array()
function of phylib. As mmap_mode
is set to "r"
, this should just be loading the file out = np.load(path, mmap_mode=mmap_mode)
where the path is the path to 'pc_feature_ind.npy'
, and returning it directly. I am not certain from the final error message, but this loaded object may not be for some reason an ndarray, then applying squeeze()
on it is erroring out.
Can you try in in python my_file = np.load(...path to 'pc_feature_ind.npy')
and see what the my_file object is?
What sorter are you using? It is suspicious that there is only 1 unit, in this case maybe something has gone wrong in the 1-unit case with the saving of the data to an unexpected format.
Thank you for your reply! I have checked the array in pc_feature_ind.npy
. The data is array([[0]], dtype=int64)
. I used the mountainsorter5 sorter. I don't know why there is only one unit. Because in the similar condition in the next recording, there are many units. I will try to sort using other methods. Thank you again!
Weird, I don't see why that would error! Sorry I made a mistake in my last post, could you try:
out = np.load(...path to 'pc_feature_ind.npy', mmap_mode="r")
I think the next step if you are interested is to break into the phylib read_array
function (you can find where it is installed with pip show phylib
) and run it line-by-line to see exactly why the error is occuring. If you are interested but are not sure how I can tell you how, but it is a bit more hands on, so feel free to trying other methods to sort!
I used mmap_mode. The result is following.
>>> data = np.load('pc_feature_ind.npy', mmap_mode='r')
>>> data
memmap([[0]], dtype=int64)
It's similar to the previous result. Does it mean there is no feature extracted? I think I will run it line-by-line when I have free time. Thank you!
cool thanks, this seems possibly like a numpy bug! or something I am misunderstanding, but this should really work, and I think is due to there only being one unit.
import numpy as np
bad_array = np.array([0])
np.save("bad_array.npy", bad_array)
load_bad_array = np.load("bad_array.npy", mmap_mode="r")
load_bad_array.squeeze() # get error
good_array = np.array([0, 0])
np.save("good_array.npy", good_array )
load_good_array = np.load("good_array.npy", mmap_mode="r")
load_good_array .squeeze() # no error
99% sure it is a numpy bug because you dont get the same behaviour with a normal array. Feel free to open an issue at numpy
github.
If you want to load the data still there are workarounds by editing the phy code on your machine to handle the error, let me know if you have any questions about this.
It's funny. Thanks for your help. I will try it.
When I finish sorting, try to fix manually. But there are some problem.
phy template-gui params.py --debug
But other results can be imported into phy successfully. I find the number of cluster is one. Does the single cluster affect the process?