Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix broken _load_channel_shanks(). #41

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions phylib/io/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,11 +560,24 @@ def _load_channel_probes(self):
return np.zeros(self.n_channels, dtype=np.int32)

def _load_channel_shanks(self):
"""
Return a 1 x num_channels array of shank indices,
where the channels x-position is mapped
to shank idx (starting with lowest x-position, shank idx 0).

If channel positions cannot be loaded, return an array of zeros.
"""
try:
path = self._find_path('channel_shanks.npy', 'channels.shanks*.npy')
out = self._read_array(path).reshape((-1,))
assert out.ndim == 1
return out
channel_positions = self._load_channel_positions()

shanks = channel_positions[:, 0].astype(np.int32)
unqiue_x_channel_pos = np.sort(np.unique(shanks))

for idx, chan_pos in enumerate(unqiue_x_channel_pos):
shanks[np.where(shanks == chan_pos)] = idx

return shanks

except IOError:
logger.debug("No channel shank file found.")
return np.zeros(self.n_channels, dtype=np.int32)
Expand Down