rastermap icon indicating copy to clipboard operation
rastermap copied to clipboard

run rastermap on binarized data

Open Pentabyteman opened this issue 1 year ago • 0 comments

Dear Team.

I was wondering whether it would be possible to run rastermap on already binarized data (meaning 0 = no spike; 1 = spike) and whether it would make more sense supplying just the peak, or setting the entire width at half maximum to 1 for the algorithms behind rastermap?

I tried to run the rastermap_singleneurons.ipnyb notebook with my own binarized matrix of 752 cells by 612 timepoints as this seemed the most applicable, however when I try to set n_clusters = None a ValueError gets raised in lines 363-364 of rastermap.py.

When I set n_clusters to some integer < 200, the following error occurs:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Cell In[7], line 1
----> 1 model = Rastermap(n_clusters=10, # None turns off clustering and sorts single neurons 
      2                   n_PCs=64, # use fewer PCs than neurons
      3                   locality=0.15, # some locality in sorting (this is a value from 0-1)
      4                   time_lag_window=15, # use future timepoints to compute correlation
      5                   normalize = None,
      6                   grid_upsample=0, # 0 turns off upsampling since we're using single neurons
      7                 ).fit(spks)
      8 y = model.embedding # neurons x 1
      9 isort = model.isort

File ~/miniconda3/envs/rastermap/lib/python3.8/site-packages/rastermap/rastermap.py:494, in Rastermap.fit(self, data, Usv, Vsv, U_nodes, itrain, compute_X_embedding, BBt)
    491     if (bin_size==0 or n_samples < bin_size or 
    492         (bin_size == 50 and n_samples < 1000)):
    493         bin_size = max(1, n_samples // 500)
--> 494     self.X_embedding = zscore(bin1d(X[igood][self.isort], bin_size, axis=0), axis=1)
    496 rmap_logger.info(f"rastermap complete, time {time.time() - t0:0.2f}sec")
    498 self.runtime = time.time() - t0

IndexError: index 751 is out of bounds for axis 0 with size 592

This happens both when explicitly setting bin_size = 0 or bin_size = 1

Pentabyteman avatar Jun 02 '24 21:06 Pentabyteman