neuropixels icon indicating copy to clipboard operation
neuropixels copied to clipboard

Excising time window from imec.ap.bin file

Open MizrahiTeam opened this issue 4 years ago • 3 comments

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

MizrahiTeam avatar Sep 16 '20 11:09 MizrahiTeam

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 238530000*N 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 [email protected] 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 .

nsteinme avatar Sep 16 '20 15:09 nsteinme

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

m-okun avatar Sep 16 '20 15:09 m-okun

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

MizrahiTeam avatar Sep 16 '20 18:09 MizrahiTeam