cortex-lab / neuropixels

Information about Neuropixels electrode arrays
83 stars 15 forks source link

Excising time window from imec.ap.bin file #40

Open MizrahiTeam opened 4 years ago

MizrahiTeam commented 4 years ago

Hi there, I'm trying to excise a time window from the spike GLX output file (we have recorded ephiz for several hours and I want to use only the first half of the recording in KS). Does anyone know a straightforward method to do it? Thanks, Ido

nsteinme commented 4 years ago

In matlab, use fopen to open the file, fseek to skip to the sample you want to start with, and fread to start reading data. Then fopen to open a second file for writing, fwrite to write the data that you read from the first file. Tip: with fseek you need to specify how many bytes to skip: each sample is 2 bytes and there are 385 channels per sample and 30000 samples per second. So you ought to skip 238530000N where N is number of seconds to skip. Tip2: in fread, use 'int16' as the format, which is equivalent to 'int16=>int16' which means "interpret the data in the file as int16, and return it to me in the workspace as int16".

You'll have to double-check that that works. Btw python has equivalent functions.

On Wed, Sep 16, 2020 at 4:31 AM MizrahiTeam notifications@github.com wrote:

Hi there, I'm trying to excise a time window from the spike GLX output file (we have recorded ephiz for several hours and I want to use only the first half of the recording in KS). Does anyone know a straightforward method to do it? Thanks, Ido

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cortex-lab/neuropixels/issues/40, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZ5IP5CU4PHIQXQTE4FYODSGCO2JANCNFSM4ROV46VQ .

m-okun commented 4 years ago

Also, SpikeGLX File Viewer allows to export a time range of interest into a new binary file.

MizrahiTeam commented 4 years ago

Thanks, guys. I also managed to work with the imec.saveTranformedDataset function @ https://github.com/djoshea/neuropixel-utils/