Extracting data from Blackrock files in Python #ephys #code

The problem

Recently, I’ve had the pleasure to get some data from to the very talented Paolo Papale working in Pieter Roelfsema’s lab. Both of them kindly sent me some electrophysiological data from their Utah array recordings. Their massively parallel recordings (about 1000 recording sites in visual cortices) are acquired and digitized through a Blackock Neurotech board that outputs the data in a proprietary .nev format.

Rather than bother them for access to properitary tools or in-house solutions, I wanted to play around with the data on my own

The solution

A very simple solution relies on the brillant Python NEO package. It becomes trivially simple to load data with their BlackRock I/O interface :

import numpy as np
import os
from neo.rawio import BlackrockRawIO
import time

recording_path = './path_to_recording/path_to_subfolder'
now = time.time()

print('> Loading array : %s/instance1_B001.nev . . .' % (recording_path))
reader = BlackrockRawIO(filename= '%s/instance1_B001.nev' % (recording_path))
reader.parse_header()

print('Getting analog signals . . .')
signals = reader.get_analogsignal_chunk(block_index=0, seg_index=0, i_start=None, i_stop=None, channel_indexes=None)
signals = signals[:,0:128] #  here an instance has 144 channels, but the last 16 are not signals

print('Writing to disk . . . ')
if os.path.isfile('./raw_array_1.bin') : os.remove('./raw_array_1.bin') # better safe than sorry
with open ('./raw_array_1.bin' % instance,'wb') as FileToWrite:
    signals.tofile(FileToWrite)

print('Total time : %s' % (time.time() - now))

which gives a .bin file that can easily be loaded for further processing, for example using Kilosort for spike sorting.

Simple as that ! For a .nev file of half a gigabyte, it takes less than a minute on a modern setup to convert everything to a bin file.

Hugo Ladret

PhD Student computational neuroscience + vision

Marseille + Montreal


'People are so into digital recording now they forgot how easy analog recording can be.' > Dave Grohl

By Hugo Ladret, 2023-04-17