Skip to content

Commit

Permalink
Merge pull request #2415 from robertoostenveld/spikeglx
Browse files Browse the repository at this point in the history
support for neuropixel data recorded with SpikeGLX
  • Loading branch information
robertoostenveld committed Jun 20, 2024
2 parents 546e454 + e8f2a12 commit 2d64b08
Show file tree
Hide file tree
Showing 28 changed files with 911 additions and 124 deletions.
45 changes: 45 additions & 0 deletions external/spikeglx/DemoReadSGLXData.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
% =============================================================
% Simple demo program calling functions from the
% SGLX_readMeta class.
%
function DemoReadSGLXData()

% Ask user for binary file
[binName,path] = uigetfile('*.bin', 'Select Binary File');

% Parse the corresponding metafile
meta = SGLX_readMeta.ReadMeta(binName, path);

% Get first one second of data
nSamp = floor(1.0 * SGLX_readMeta.SampRate(meta));
dataArray = SGLX_readMeta.ReadBin(0, nSamp, meta, binName, path);
dataType = 'A'; %set to 'A' for analog, 'D' for digital data

% For an analog channel: gain correct saved channel ch (1-based for MATLAB).
ch = 1;

% For a digital channel: read this digital word dw in the saved file
% (1-based). For imec data there is never more than one saved digital word.
dw = 1;

% Read these lines in dw (0-based).
% For 3B2 imec data: the sync pulse is stored in line 6.
% May be 1 or more line indices.
dLineList = [0,1,6];

if dataType == 'A'
if strcmp(meta.typeThis, 'imec')
dataArray = SGLX_readMeta.GainCorrectIM(dataArray, [ch], meta);
else
dataArray = SGLX_readMeta.GainCorrectNI(dataArray, [ch], meta);
end
plot(1e6*dataArray(ch,:));
else
digArray = SGLX_readMeta.ExtractDigital(dataArray, meta, dw, dLineList);
for i = 1:numel(dLineList)
plot(digArray(i,:));
hold on
end
hold off
end
end % DemoReadSGLXData
Loading

0 comments on commit 2d64b08

Please sign in to comment.