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

Jacob/amplitudes #646

Merged
merged 5 commits into from
May 3, 2024
Merged
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
19 changes: 12 additions & 7 deletions kilosort/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,18 @@ def save_to_phy(st, clu, tF, Wall, probe, ops, imin, results_dir=None,
np.save((results_dir / 'channel_map.npy'), chan_map)
np.save((results_dir / 'channel_positions.npy'), channel_positions)

# whitening matrix ** saving real whitening matrix doesn't work with phy currently
whitening_mat = ops['Wrot'].cpu().numpy()
np.save((results_dir / 'whitening_mat_dat.npy'), whitening_mat)
whitening_mat = 0.005 * np.eye(len(chan_map), dtype='float32')
whitening_mat_inv = np.linalg.inv(whitening_mat + 1e-5 * np.eye(whitening_mat.shape[0]))
np.save((results_dir / 'whitening_mat.npy'), whitening_mat)
np.save((results_dir / 'whitening_mat_inv.npy'), whitening_mat_inv)
# whitening matrix
whitening_mat = ops['Wrot']
np.save((results_dir / 'whitening_mat_dat.npy'), whitening_mat.cpu())
# NOTE: commented out for reference, this was different in KS 2.5 because
# the binary file was already whitened.
# whitening_mat = 0.005 * np.eye(len(chan_map), dtype='float32')
whitening_mat_inv = torch.inverse(
whitening_mat
+ 1e-5 * torch.eye(whitening_mat.shape[0]).to(whitening_mat.device)
)
np.save((results_dir / 'whitening_mat.npy'), whitening_mat.cpu())
np.save((results_dir / 'whitening_mat_inv.npy'), whitening_mat_inv.cpu())

# spike properties
spike_times = st[:,0].astype('int64') + imin # shift by minimum sample index
Expand Down
Loading