Code Monkey home page Code Monkey logo

Comments (1)

dustinf1989 avatar dustinf1989 commented on July 16, 2024

So I think I've figured out the problem. If I eliminate the spikes where index is 1 from the sort_cat.h5 file, then the lengths match. I wrote simple script in Python that combined both h5 files and outputs a mat file to save some space.

#%%  This section works to load files created by combinato and check the spike times
import h5py
import numpy as np
from scipy.io import savemat
import os
from glob import glob

# Directory containing folder output from Combinato
folder = ''

for sfold in os.listdir(folder):
    if sfold.startswith("u"): # Enter micro folders only
        print(folder+sfold)
        sortf = folder+sfold+'/sort_pos_simple/sort_cat.h5' # Find sorting outcomes
        rawf = glob(folder+sfold+'/data_*')[0] # Raw file for waveforms
        if os.path.exists(sortf): # If files don't have any clusters, then none is created
            f = h5py.File(sortf, "r")
            group = f['groups'][:] # overall waveform groups: first index is overall unit index, second is group index (no within group index)
            # Use group to convert matches to neuron group
            classes = f['classes'][:] # each small cluster
            index = f['index'][:] #  seems to index spike times
            matches = f['matches'][:] # orange blue or cyan color in plots
    
            f2 = h5py.File(rawf, "r")
            spike_times = f2['pos']['times'][index] 
            pos_wave = f2['pos']['spikes'][index]
            # spike_timesneg = f2['neg']['times'][index] 
            spike_group = np.zeros(len(classes),dtype='int16')
    
            for i, ic in enumerate(np.unique(classes)): 
                spike_group[classes==ic] = group[i,1]
                
                
            class_times = np.c_[spike_times, classes]
    
            savedict = {'class_times': class_times, 'spike_group':spike_group, 'matches':matches, 'spikes':pos_wave}
    
            savemat(folder+sfold+r'/mat_spikes_'+sfold+'.mat',savedict)

from combinato.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.