SpikeInterface / MEArec

Fast and customizable of extracellular recordings on MEA
GNU General Public License v3.0
42 stars 19 forks source link

changing sampling frequency throws an error #147

Closed colehurwitz closed 1 year ago

colehurwitz commented 1 year ago

When I change the sampling frequency in the recording params, I get an error:

Traceback (most recent call last):
  File "/moto/home/ch3676/generate_simulated_dataset_samuel.py", line 266, in <module>
    generate_drift_recordings(base_folder=base_folder,
  File "/moto/home/ch3676/generate_simulated_dataset_samuel.py", line 243, in generate_drift_recordings
    recgen = mr.gen_recordings(params=recordings_params, tempgen=tempgen, tmp_folder=tmp_folder,
  File "/moto/home/ch3676/MEArec/MEArec/generation_tools.py", line 138, in gen_recordings
    recgen.generate_recordings(tmp_mode=tmp_mode, tmp_folder=tmp_folder, template_ids=template_ids,
  File "/moto/home/ch3676/MEArec/MEArec/generators/recordinggenerator.py", line 882, in generate_recordings
    templates_rs = resample_templates(templates_pad, n_resample, f_up, f_down, drifting, np.float32,
  File "/moto/home/ch3676/MEArec/MEArec/tools.py", line 1498, in resample_templates
    templates_rs = np.memmap(tmp_file, shape=(templates.shape[0], templates.shape[1],
  File "/moto/stats/users/ch3676/micromamba/envs/spike/lib/python3.10/site-packages/numpy/core/memmap.py", line 267, in __new__
    mm = mmap.mmap(fid.fileno(), bytes, access=acc, offset=start)
ValueError: cannot mmap an empty file

I looked into it and it seems like the: 'templates_resample.raw' file never gets generated which is required for changing the sampling frequency.

alejoe91 commented 1 year ago

Mmm.. not sure! The file should be generated on the fly with the w+ mode. What params are you using?

colehurwitz commented 1 year ago

I am using Samuel's data generation script but I set:

recordings_params["recordings"]['fs'] = 30
alejoe91 commented 1 year ago

@colehurwitz if you installed locally can you print the templates.shape right before the failing line in MEArec.tools? I suspect for some reason the templates are empty to start with

colehurwitz commented 1 year ago

Seems like the templates are fine

Elapsed pad time: 39.38595008850098
Resampling templates at 30.0 Hz
templates_pad = (64, 100, 64, 416)
alejoe91 commented 1 year ago

Oh! Maybe resampling frequency should be in Hz! Not khz!!

colehurwitz commented 1 year ago

Oops! That explains it maybe! Will test

alejoe91 commented 1 year ago

@colehurwitz does it work if you set fs=30000? If so, can we close it?

colehurwitz commented 1 year ago

Yep, this works. You can close. Thanks!