chongxi / spiketag

Next generation of spike sorting package for BMI
BSD 3-Clause "New" or "Revised" License
6 stars 4 forks source link

integrate clu_manager into SPKTAG #27

Closed chongxi closed 2 years ago

chongxi commented 5 years ago

This would allow the restore the clustering state even you stop in the middle of the experiment.

chongxi commented 5 years ago

SPKTAG structure is:

class SPKTAG(object):
    def __init__(self, probe=None, spk=None, fet=None, clu=None, gtimes=None, filename=None):
        '''
        spk    : spk object
        fet    : fet object
        clu    : dictionary of clu object (each item is a channel based clu object)
        gtimes : dictionary of group with spike times
        '''
        self.probe = probe
        if filename is not None: # load from file
            self.fromfile(filename)
        elif gtimes is not None : # construct
            self.gtimes  = gtimes
            self.spk     = spk 
            self.fet     = fet 
            self.clu     = clu 
            self.spklen  = spk.spklen
            self.fetlen  = fet.fetlen
            self.grplen  = self.probe.group_len
            self.ngrp    = len(self.probe.grp_dict.keys())

            self.dtype   = [('t', 'int32'),
                            ('group','int32'),  
                            ('spk', 'f4', (self.spklen, self.grplen)), 
                            ('fet','f4',(self.fetlen,)),
                            ('clu','int32')]
        else:
            pass
chongxi commented 5 years ago

The idea is to build a meta file:

    def build_meta(self):
        meta = {}
        meta["ngrp"] = self.ngrp
        meta["grplen"] = self.probe.group_len
        meta["fetlen"] = self.fetlen
        meta["spklen"] = self.spklen
        return meta

and save it as a json file and read it later