Skip to content

Commit

Permalink
Move quad base shank acquisition into separate threads
Browse files Browse the repository at this point in the history
  • Loading branch information
jsiegle committed Apr 22, 2024
1 parent 8605669 commit f0f22e5
Show file tree
Hide file tree
Showing 8 changed files with 441 additions and 242 deletions.
21 changes: 20 additions & 1 deletion Source/NeuropixComponents.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ enum class ProbeType {
NP2_1,
NP2_4,
OPTO,
QuadBase
QUAD_BASE
};

enum class SourceStatus {
Expand All @@ -117,6 +117,22 @@ enum class Bank {
K = 10,
L = 11,
M = 12,
A1 = 13, // used for quad base
A2 = 14,
A3 = 15,
A4 = 16,
B1 = 17,
B2 = 18,
B3 = 19,
B4 = 20,
C1 = 21,
C2 = 22,
C3 = 23,
C4 = 24,
D1 = 25,
D2 = 26,
D3 = 27,
D4 = 28,
OFF = 255 //used in v1 API
};

Expand Down Expand Up @@ -424,6 +440,9 @@ class Probe : public DataSource
/** Separate buffer for LFP data */
DataBuffer* lfpBuffer;

/** Additional buffers for quad base probe */
Array<DataBuffer*> quadBaseBuffers;

float ap_sample_rate;
float lfp_sample_rate;

Expand Down
97 changes: 71 additions & 26 deletions Source/NeuropixThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,45 +336,77 @@ void NeuropixThread::updateStreamInfo()

if (source->sourceType == DataSourceType::PROBE)
{
StreamInfo apInfo;

Probe* probe = (Probe*) source;

apInfo.num_channels = probe->sendSync ? probe->channel_count + 1 : probe->channel_count;
apInfo.sample_rate = probe->ap_sample_rate;
apInfo.probe = probe;
apInfo.probe_index = probe_index++;
if (probe->type != ProbeType::QUAD_BASE)
{
StreamInfo apInfo;

if (probe->generatesLfpData())
apInfo.type = AP_BAND;
else
apInfo.type = BROAD_BAND;
apInfo.num_channels = probe->sendSync ? probe->channel_count + 1 : probe->channel_count;
apInfo.sample_rate = probe->ap_sample_rate;
apInfo.probe = probe;
apInfo.probe_index = probe_index++;

apInfo.sendSyncAsContinuousChannel = probe->sendSync;
if (probe->generatesLfpData())
apInfo.type = AP_BAND;
else
apInfo.type = BROAD_BAND;

streamInfo.add(apInfo);
apInfo.sendSyncAsContinuousChannel = probe->sendSync;

sourceBuffers.add(new DataBuffer(apInfo.num_channels, 460800)); // AP band buffer
probe->apBuffer = sourceBuffers.getLast();
streamInfo.add(apInfo);

if (probe->generatesLfpData())
{
sourceBuffers.add(new DataBuffer(apInfo.num_channels, 460800)); // AP band buffer
probe->apBuffer = sourceBuffers.getLast();

StreamInfo lfpInfo;
lfpInfo.num_channels = probe->sendSync ? probe->channel_count + 1 : probe->channel_count;
lfpInfo.sample_rate = probe->lfp_sample_rate;
lfpInfo.type = LFP_BAND;
lfpInfo.probe = probe;
lfpInfo.sendSyncAsContinuousChannel = probe->sendSync;
if (probe->generatesLfpData())
{

StreamInfo lfpInfo;
lfpInfo.num_channels = probe->sendSync ? probe->channel_count + 1 : probe->channel_count;
lfpInfo.sample_rate = probe->lfp_sample_rate;
lfpInfo.type = LFP_BAND;
lfpInfo.probe = probe;
lfpInfo.sendSyncAsContinuousChannel = probe->sendSync;

sourceBuffers.add(new DataBuffer(lfpInfo.num_channels, 38400)); // LFP band buffer
probe->lfpBuffer = sourceBuffers.getLast();
sourceBuffers.add(new DataBuffer(lfpInfo.num_channels, 38400)); // LFP band buffer
probe->lfpBuffer = sourceBuffers.getLast();

streamInfo.add(lfpInfo);
}

streamInfo.add(lfpInfo);
LOGD("Probe (slot=", probe->basestation->slot, ", port=", probe->headstage->port, ") CH=", apInfo.num_channels, " SR=", apInfo.sample_rate, " Hz");
}
else {

LOGD("Probe (slot=", probe->basestation->slot, ", port=", probe->headstage->port, ") CH=", apInfo.num_channels, " SR=", apInfo.sample_rate, " Hz");
}
for (int shank = 0; shank < 4; shank++)
{
StreamInfo apInfo;

apInfo.num_channels = probe->sendSync ? 385 : 384;
apInfo.sample_rate = probe->ap_sample_rate;
apInfo.probe = probe;
apInfo.probe_index = probe_index;
apInfo.type = QUAD_BASE;
apInfo.shank = shank;

apInfo.sendSyncAsContinuousChannel = probe->sendSync;

streamInfo.add(apInfo);

sourceBuffers.add(new DataBuffer(apInfo.num_channels, 460800)); // AP band buffer
probe->quadBaseBuffers.add(sourceBuffers.getLast());

std::cout << probe->quadBaseBuffers[shank] << std::endl;

LOGD("Probe (slot=", probe->basestation->slot, ", port=", probe->headstage->port, ") SHANK=", shank +1," CH = ", 384, " SR = ", apInfo.sample_rate, " Hz");

}

probe_index++;
}
}
else {

if (true)
Expand Down Expand Up @@ -901,6 +933,19 @@ void NeuropixThread::updateSettings(OwnedArray<ContinuousChannel>* continuousCha
identifier = "neuropixels.data.lfp";
}

else if (info.type == stream_type::QUAD_BASE)
{
lastName = generateProbeName(info.probe_index, info.probe->namingScheme);

if (info.probe->namingScheme != ProbeNameConfig::STREAM_INDICES)
streamName = lastName + "-" + String(info.shank + 1);
else
streamName = String(info.probe->streamIndex);

description = "Neuropixels Quad Base data stream";
identifier = "neuropixels.data.quad_base";
}

DataStream::Settings settings
{
streamName,
Expand Down
2 changes: 2 additions & 0 deletions Source/NeuropixThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ typedef enum {
AP_BAND,
LFP_BAND,
BROAD_BAND,
QUAD_BASE,
ADC
} stream_type;

Expand All @@ -52,6 +53,7 @@ struct StreamInfo {
int probe_index;
float sample_rate;
stream_type type;
int shank = -1;
bool sendSyncAsContinuousChannel;
Probe* probe;
OneBoxADC* adc;
Expand Down
Loading

0 comments on commit f0f22e5

Please sign in to comment.