def klusters_files(table,basename): CluFileName,FetFileName,ResFileName,SpkFileName,XMLFileName = (basename + ext for ext in [".clu.1",".fet.1",".res.1",".spk.1",".xml"]) output.write_clu(table.cols.clu[:],CluFileName) output.write_fet(to2d(table.cols.fet[:]),FetFileName,samples=table.cols.time[:]) output.write_res(table.cols.time[:],ResFileName) output.write_spk(table.cols.wave[:],SpkFileName) output.write_xml(n_ch=N_CH,n_samp=S_TOTAL,n_feat=N_CH*FPC,sample_rate=SAMPLE_RATE,filepath=XMLFileName)
def klustakwik_cluster(Fet_nc3): kk_path = "KlustaKwik" tempdir = tempfile.mkdtemp() kk_input_filepath = join(tempdir,'k_input.fet.1') kk_output_filepath = join(tempdir,'k_input.clu.1') Fet_nf = Fet_nc3.reshape(len(Fet_nc3),-1) write_fet(Fet_nf,kk_input_filepath) n_fet = Fet_nf.shape[1] os.system( ' '.join([kk_path, kk_input_filepath[:-6], '1', '-UseFeatures', '1'*n_fet,'-MinClusters',str(MINCLUSTERS),'-MaxClusters',str(MAXCLUSTERS),'-Screen','0']) ) return read_clu(kk_output_filepath)
def klustakwik_cluster(Fet_nc3, clusterdir): kk_path = "KlustaKwik" if not (os.path.exists(clusterdir)): os.makedirs(clusterdir) kk_input_filepath = join(clusterdir,'k_input.fet.1') kk_output_filepath = join(clusterdir,'k_input.clu.1') Fet_nf = Fet_nc3.reshape(len(Fet_nc3),-1) write_fet(Fet_nf,kk_input_filepath) n_fet = Fet_nf.shape[1] os.system( ' '.join([kk_path, kk_input_filepath[:-6], '1', '-UseFeatures', '1'*n_fet,'-MinClusters',str(MINCLUSTERS),'-MaxClusters',str(MAXCLUSTERS),'-Screen','0']) ) return read_clu(kk_output_filepath)
def write_files(basename,CluList,TmList,FetList,ChannelGraph=None,STArr=None): """Writes files that result from a clustering job.""" CluFileName = basename+'.clu.1' FetFileName = basename+'.fet.1' ResFileName = basename+'.res.1' XMLFileName = basename+'.xml' if CluList is not None: output.write_clu(np.array(CluList),CluFileName) output.write_res(np.array(TmList),ResFileName) output.write_fet(np.array(FetList),FetFileName,samples=np.array(TmList)) output.write_xml(n_ch=N_CH,n_samp=S_TOTAL,n_feat=N_CH*FPC,sample_rate=SAMPLE_RATE,filepath=XMLFileName) if STArr is not None: np.save("ST.npy",STArr)
def klusters_files(table, basename): CluFileName, FetFileName, ResFileName, SpkFileName, XMLFileName = ( basename + ext for ext in [".clu.1", ".fet.1", ".res.1", ".spk.1", ".xml"]) output.write_clu(table.cols.clu[:], CluFileName) output.write_fet(to2d(table.cols.fet[:]), FetFileName, samples=table.cols.time[:]) output.write_res(table.cols.time[:], ResFileName) output.write_spk(table.cols.wave[:], SpkFileName) output.write_xml(n_ch=N_CH, n_samp=S_TOTAL, n_feat=N_CH * FPC, sample_rate=SAMPLE_RATE, filepath=XMLFileName)
def klustakwik_cluster(Fet_nc3): kk_path = "KlustaKwik" tempdir = tempfile.mkdtemp() kk_input_filepath = join(tempdir, 'k_input.fet.1') kk_output_filepath = join(tempdir, 'k_input.clu.1') Fet_nf = Fet_nc3.reshape(len(Fet_nc3), -1) write_fet(Fet_nf, kk_input_filepath) n_fet = Fet_nf.shape[1] os.system(' '.join([ kk_path, kk_input_filepath[:-6], '1', '-UseFeatures', '1' * n_fet, '-MinClusters', str(MINCLUSTERS), '-MaxClusters', str(MAXCLUSTERS), '-Screen', '0' ])) return read_clu(kk_output_filepath)
def write_files(basename, CluList, TmList, FetList, ChannelGraph=None, STArr=None): """Writes files that result from a clustering job.""" CluFileName = basename + '.clu.1' FetFileName = basename + '.fet.1' ResFileName = basename + '.res.1' XMLFileName = basename + '.xml' if CluList is not None: output.write_clu(np.array(CluList), CluFileName) output.write_res(np.array(TmList), ResFileName) output.write_fet(np.array(FetList), FetFileName, samples=np.array(TmList)) output.write_xml(n_ch=N_CH, n_samp=S_TOTAL, n_feat=N_CH * FPC, sample_rate=SAMPLE_RATE, filepath=XMLFileName) if STArr is not None: np.save("ST.npy", STArr)