Code Monkey home page Code Monkey logo

Comments (12)

yger avatar yger commented on June 10, 2024

from spyking-circus.

alexgonzl avatar alexgonzl commented on June 10, 2024

Thanks for the quick response!

  1. yes that seemed to do the trick. the code however now hangs on the fitting stage after finding zero clusters (it is artificial data, so not surprised). I had to do a keyboard interrupt at that point, probably a smooth exit after finding zero clusters would be an improvement. Error snippet below

  2. i was running spyking-circus mydata.npy, I was able to eliminate the second error by decreasing output_dim to 3 in the params file.

`------------------------- Informations -------------------------
| No more isolated spikes in the recording, stop searching

Refining density estimations...
Node 0: 0-0 negative templates on channel 0 from 19 spikes: []
Node 0: 0-0 negative templates on channel 1 from 22 spikes: []
Node 0: 0-0 negative templates on channel 2 from 15 spikes: []
Node 0: 0-0 negative templates on channel 3 from 35 spikes: []
------------------------- Informations -------------------------
| Number of clusters found : 0
| Number of local merges : 0
| Not enough spikes gathered: -put safety_space=False?
| -decrease smart_search?

Estimating the templates with the median-raw procedure ...

100%|█████████████████████████████████████████|[00:00<00:00, 328.79it/s]------------------------- Informations -------------------------
| Number of global merges : 0
| Number of mixtures removed : 0

Pre-computing the overlaps of templates using 1 CPU...

100%|████████████████████████████████████████|[00:00<00:00, 9921.48it/s]
Here comes the SpyKING CIRCUS using 1 CPUs and 0 templates...
0%| |[00:00<?, ?it/s]Traceback (most recent call last):
File "/Users/alexgonzalez/anaconda3/bin/spyking-circus-subtask", line 11, in
load_entry_point('spyking-circus==0.6.7', 'console_scripts', 'spyking-circus-subtask')()
File "/Users/alexgonzalez/anaconda3/lib/python3.6/site-packages/circus/scripts/subtask.py", line 43, in main
circus.launch(task, filename, nb_cpu, nb_gpu, use_gpu)
File "/Users/alexgonzalez/anaconda3/lib/python3.6/site-packages/circus/init.py", line 21, in launch
module.main(params, nb_cpu, nb_gpu, use_gpu)
File "/Users/alexgonzalez/anaconda3/lib/python3.6/site-packages/circus/fitting.py", line 351, in main
argmax_bi = numpy.argsort(numpy.max(data, 0))[::-1]
File "/Users/alexgonzalez/anaconda3/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 2320, in amax
out=out, **kwargs)
File "/Users/alexgonzalez/anaconda3/lib/python3.6/site-packages/numpy/core/_methods.py", line 26, in _amax
return umr_maximum(a, axis, None, out, keepdims)
ValueError: zero-size array to reduction operation maximum which has no identity`

from spyking-circus.

alexgonzl avatar alexgonzl commented on June 10, 2024

also, if I only run clustering, e.g.:
spyking-circus mydata.npy -m clustering

the code seems to still look for existing templates from the whitening phase (I presume):

OSError: Unable to open file (unable to open file: name = '.../ecephys_example.basis.hdf5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)
-------------------------------------------------------

from spyking-circus.

yger avatar yger commented on June 10, 2024

from spyking-circus.

alexgonzl avatar alexgonzl commented on June 10, 2024

Thanks for the tip. I'm now running it with whitening step, and it did work on one of my files. I'm getting this error on others:

.../numpy/linalg/linalg.py", line 95, in _raise_linalgerror_eigenvalues_nonconvergence
    raise LinAlgError("Eigenvalues did not converge")
numpy.linalg.linalg.LinAlgError: Eigenvalues did not converge

and if I turn spatial = False on the params file, I get this other error:

Searching random spikes to sample amplitudes...
100%|██████████████████████████████████████████|[00:15<00:00,  5.68it/s]We found 8000 spikes over 32000 requested
Estimating amplitudes distributions...
Traceback (most recent call last):
  File "/Users/alexgonzalez/anaconda3/bin/spyking-circus-subtask", line 11, in <module>
    load_entry_point('spyking-circus==0.6.7', 'console_scripts', 'spyking-circus-subtask')()
  File "/Users/alexgonzalez/anaconda3/lib/python3.6/site-packages/circus/scripts/subtask.py", line 43, in main
    circus.launch(task, filename, nb_cpu, nb_gpu, use_gpu)
  File "/Users/alexgonzalez/anaconda3/lib/python3.6/site-packages/circus/__init__.py", line 21, in launch
    module.main(params, nb_cpu, nb_gpu, use_gpu)
  File "/Users/alexgonzalez/anaconda3/lib/python3.6/site-packages/circus/clustering.py", line 589, in main
    a, b  = numpy.histogram(result['tmp_%s_' %p + str(ielec)], bins)
  File "/Users/alexgonzalez/anaconda3/lib/python3.6/site-packages/numpy/lib/function_base.py", line 670, in histogram
    'range parameter must be finite.')
ValueError: range parameter must be finite.

Thoughts?

from spyking-circus.

alexgonzl avatar alexgonzl commented on June 10, 2024

Tracked down the numpy histogram error. It has to do with NaN values being present in the data.

from spyking-circus.

alexgonzl avatar alexgonzl commented on June 10, 2024

Another error during clustering:
`Estimating the templates with the median-raw procedure ...

Traceback (most recent call last):
File "/Users/alexgonzalez/anaconda3/bin/spyking-circus-subtask", line 11, in
load_entry_point('spyking-circus==0.6.7', 'console_scripts', 'spyking-circus-subtask')()
File "/Users/alexgonzalez/anaconda3/lib/python3.6/site-packages/circus/scripts/subtask.py", line 43, in main
circus.launch(task, filename, nb_cpu, nb_gpu, use_gpu)
File "/Users/alexgonzalez/anaconda3/lib/python3.6/site-packages/circus/init.py", line 21, in launch
module.main(params, nb_cpu, nb_gpu, use_gpu)
File "/Users/alexgonzalez/anaconda3/lib/python3.6/site-packages/circus/clustering.py", line 783, in main
cfile = h5py.File(file_out_suff + '.clusters-%d.hdf5' %comm.rank, 'w', libver='earliest')
File "/Users/alexgonzalez/anaconda3/lib/python3.6/site-packages/h5py/_hl/files.py", line 269, in init
fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr)
File "/Users/alexgonzalez/anaconda3/lib/python3.6/site-packages/h5py/_hl/files.py", line 105, in make_fid
fid = h5f.create(name, h5f.ACC_TRUNC, fapl=fapl, fcpl=fcpl)
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py/h5f.pyx", line 98, in h5py.h5f.create
OSError: Unable to create file (unable to truncate a file which is already open)`

from spyking-circus.

yger avatar yger commented on June 10, 2024

from spyking-circus.

alexgonzl avatar alexgonzl commented on June 10, 2024

using on mac10.13.5, h5py 2.7.1.

in terms of it being open by another app, I don't think so. Is there any chance of different cpu cores accessing the same temp file? Will retry with one cpu to see if this comes up.

from spyking-circus.

yger avatar yger commented on June 10, 2024

from spyking-circus.

alexgonzl avatar alexgonzl commented on June 10, 2024

couldn't attach it, but here is the content of the params file. yeah, 1 or multicores produced the same error on line 783 of clustering.py

`
[data]
file_format = numpy # Can be raw_binary, openephys, hdf5, ... See >> spyking-circus help -i for more info
stream_mode = None # None by default. Can be multi-files, or anything depending to the file format
mapping = tetrode.prb # Mapping of the electrode (see http://spyking-circus.rtfd.ord)
suffix = # Suffix to add to generated files
overwrite = True # Filter or remove artefacts on site (if write access is possible). Data are duplicated otherwise
parallel_hdf5 = True # Use the parallel HDF5 feature (if available)
output_dir = # By default, generated data are in the same folder as the data.
sampling_rate = 32000.0 # By default, generated data are in the same folder as the data.

[detection]
radius = auto # Radius [in um] (if auto, read from the prb file)
N_t = 3 # Width of the templates [in ms]
spike_thresh = 6 # Threshold for spike detection
peaks = both # Can be negative (default), positive or both
matched-filter = False # If True, we perform spike detection with matched filters
matched_thresh = 5 # Threshold for detection if matched filter is True
alignment = True # Realign the waveforms by oversampling
isolation = False # Enforce individual snippets to be isolated [experimental]
dead_channels = # If not empty or specified in the probe, a dictionary {channel_group : [list_of_valid_ids]}

[filtering]
cut_off = 100, auto # Min and Max (auto=nyquist) cut off frequencies for the band pass butterworth filter [Hz]
filter = False # If True, then a low-pass filtering is performed
remove_median = False # If True, median over all channels is substracted to each channels (movement artifacts)

[triggers]
trig_file = # External stimuli to be considered as putative artefacts [in trig units] (see documentation)
trig_windows = # The time windows of those external stimuli [in trig units]
trig_unit = ms # The unit in which times are expressed: can be ms or timestep
clean_artefact = False # If True, external artefacts induced by triggers will be suppressed from data
dead_file = # Portion of the signals that should be excluded from the analysis [in dead units]
dead_unit = ms # The unit in which times for dead regions are expressed: can be ms or timestep
ignore_times = False # If True, any spike in the dead regions will be ignored by the analysis
make_plots = # Generate sanity plots of the averaged artefacts [Nothing or None if no plots]

[whitening]
chunk_size = 30 # Size of the data chunks [in s]
safety_time = auto # Temporal zone around which templates are isolated [in ms, or auto]
temporal = False # Perform temporal whitening
spatial = False # Perform spatial whitening
max_elts = 10000 # Max number of events per electrode (should be compatible with nb_elts)
nb_elts = 0.8 # Fraction of max_elts that should be obtained per electrode [0-1]
output_dim = 3 # Can be in percent of variance explain, or num of dimensions for PCA on waveforms

[clustering]
extraction = median-raw # Can be either median-raw (default), median-pca, mean-pca, mean-raw
safety_space = False # If True, we exclude spikes in the vicinity of a selected spikes
safety_time = auto # Temporal zone around which templates are isolated [in ms, or auto]
max_elts = 10000 # Max number of events per electrode (should be compatible with nb_elts)
nb_elts = 0.8 # Fraction of max_elts that should be obtained per electrode [0-1]
nclus_min = 0.002 # Min number of elements in a cluster (given in percentage) [0-1]
max_clusters = 10 # Maximal number of clusters for every electrodes
nb_repeats = 3 # Number of passes used for the clustering
smart_search = True # Activate the smart search mode
smart_select = True # Experimental: activate the smart selection of centroids (max_clusters is ignored)
sim_same_elec = 3 # Distance within clusters under which they are re-merged
cc_merge = 0.975 # If CC between two templates is higher, they are merged
dispersion = (5, 5) # Min and Max dispersion allowed for amplitudes [in MAD]
noise_thr = 0.8 # Minimal amplitudes are such than ampmin(templates) < noise_thrthreshold in [0-1]
remove_mixture = True # At the end of the clustering, we remove mixtures of templates
cc_mixtures = 0.75 # If CC between a sum of two templates and a template is higher, it is removed
make_plots = # Generate sanity plots of the clustering [Nothing or None if no plots]

[fitting]
chunk_size = 1 # Size of chunks used during fitting [in second]
gpu_only = False # Use GPU for computation of b's AND fitting [not optimized yet]
amp_limits = (0.3, 5) # Amplitudes for the templates during spike detection [if not auto]
amp_auto = True # True if amplitudes are adjusted automatically for every templates
max_chunk = inf # Fit only up to max_chunk
collect_all = False # If True, one garbage template per electrode is created, to store unfitted spikes

[merging]
cc_overlap = 0.7 # Only templates with CC higher than cc_overlap may be merged
cc_bin = 2 # Bin size for computing CC [in ms]
correct_lag = True # If spikes are aligned when merging. May be better for phy usage
auto_mode = 0 # If >0, merging will be automatic (see doc, 0.1 is a good value)

[converting]
erase_all = True # If False, a prompt will ask you to export if export has already been done
export_pcs = some # Can be prompt [default] or in none, all, some
export_all = False # If True, unfitted spikes will be exported as the last Ne templates
sparse_export = False # For recent versions of phy, and large number of templates/channels

[validating]
nearest_elec = auto # Validation channel (e.g. electrode closest to the ground truth cell)
max_iter = 200 # Maximum number of iterations of the stochastic gradient descent (SGD)
learning_rate = 1.0e-3 # Initial learning rate which controls the step-size of the SGD
roc_sampling = 10 # Number of points to estimate the ROC curve of the BEER estimate
test_size = 0.3 # Portion of the dataset to include in the test split
radius_factor = 0.5 # Radius factor to modulate physical radius during validation
juxta_dtype = uint16 # Type of the juxtacellular data
juxta_thresh = 6 # Threshold for juxtacellular detection
juxta_valley = False # True if juxta-cellular spikes are negative peaks
juxta_spikes = # If none, spikes are automatically detected based on juxta_thresh
filter = True # If the juxta channel need to be filtered or not
make_plots = png # Generate sanity plots of the validation [Nothing or None if no plots]

[extracting]
safety_time = 1 # Temporal zone around which spikes are isolated [in ms]
max_elts = 1000 # Max number of collected events per templates
output_dim = 5 # Percentage of variance explained while performing PCA
cc_merge = 0.975 # If CC between two templates is higher, they are merged
noise_thr = 0.8 # Minimal amplitudes are such than ampmin(templates) < noise_thrthreshold

[noedits]
filter_done = False #
artefacts_done = False # Will become True automatically after removing artefacts
median_done = False # Will become True automatically after removing common median
`

from spyking-circus.

yger avatar yger commented on June 10, 2024

And does this also happen if you set parallel_hdf5 to False in the [data] section?

from spyking-circus.

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.