-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
revised demo for Neuropixels that functionalizes the transformation s…
…o it is easier to understand
- Loading branch information
1 parent
7a9f906
commit e98c3c5
Showing
9 changed files
with
206 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
|
||
% this script was made to explore the input/output requirements of the | ||
% pretrained neuropixels network | ||
|
||
E = [[1:192]' [1:192]'+0.5]; % number electrodes by Y (whole number) and X 2*(mod 1) | ||
|
||
NP = repmat(E,1,1,500); % 500 frames of data | ||
% now transpose to be the same as the expected neuropixels data | ||
NP = permute(NP, [3 1 2]); | ||
|
||
nb_probes = 384; % Number of probes | ||
|
||
pre_post_omission = 3; % Number of frames omitted before and after the inferred frame | ||
|
||
pre_frame = 30; % Number of frames provided before the inferred frame | ||
post_frame = 30; % Number of frames provided after the inferred frame | ||
|
||
batch_size = 100; | ||
|
||
start_frame = 100; | ||
|
||
end_frame = 200; | ||
|
||
|
||
input_full = single(zeros(batch_size, nb_probes, 2, pre_frame + post_frame)); | ||
|
||
|
||
for frame_index = start_frame:end_frame | ||
|
||
input_index = (frame_index - pre_frame - pre_post_omission) : (frame_index + post_frame + pre_post_omission ); | ||
|
||
input_index = input_index(input_index ~= frame_index); % drop the predicted frame | ||
|
||
for index_padding = 1: pre_post_omission % drop pre_post_omission number of frames surrounding the predicted frame | ||
input_index = input_index(input_index ~= frame_index - index_padding); | ||
input_index = input_index(input_index ~= frame_index + index_padding); | ||
end | ||
|
||
data_img_input = ephys(input_index, :, :); | ||
|
||
data_img_input = permute(data_img_input,[2,3,1]); | ||
|
||
data_img_input = (single(data_img_input) - local_mean) / local_std; | ||
|
||
% alternating filling with zeros padding | ||
odd = 1: 2: nb_probes; | ||
even = odd + 1; | ||
|
||
input_full(frame_index-start_frame+1, odd, 1, :) = data_img_input(:, 1, :); | ||
input_full(frame_index-start_frame+1, even, 2, :) = data_img_input(:, 2, :); | ||
|
||
|
||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
function frame = checkerboard2NPframe(cb) | ||
% CHECKERBOARD2NPFRAME - convert geometrically realistic matrix to raw Neuropixels Phase 3 format | ||
% | ||
% FRAME = CHECKERBOARD2NPFRAME(CB) | ||
% | ||
% Convert geometrically-realistic matrix data CB (384 x 2 x NSAMPLES) | ||
% into a format that matches the raw data output of Neuropixels Phase 3 | ||
% probes. CB is expected to reflect the checkerboard layout of electrodes, | ||
% where every even linear index is 0. | ||
% | ||
% FRAME will be a 192 x 2 x NSAMPLES matrix. | ||
% | ||
% For example, the following single-frame example input where each data point has | ||
% been set, for illustration purposes, to the electrode number (incremented by 0.25) | ||
% would be transformed as follows: | ||
% | ||
% 1.0000 0 | ||
% 0 1.2500 | ||
% 2.0000 0 | ||
% 0 2.2500 | ||
% 3.0000 0 | ||
% 0 3.2500 | ||
% ... | ||
% 190.0000 0 | ||
% 0 190.2500 | ||
% 191.0000 0 | ||
% 0 191.2500 | ||
% 192.0000 0 | ||
% 0 192.2500 | ||
% | ||
% to | ||
% | ||
% 1.0000 1.2500 | ||
% 2.0000 2.2500 | ||
% 3.0000 3.2500 | ||
% ... | ||
% 189.0000 189.2500 | ||
% 190.0000 190.2500 | ||
% 191.0000 191.2500 | ||
% 192.0000 192.2500 | ||
|
||
% Check input dimensions | ||
if size(cb, 1) ~= 384 || size(cb, 2) ~= 2 | ||
error('Input matrix CB must be 384 x 2 x NSAMPLES.'); | ||
end | ||
|
||
frame = zeros(size(cb,1)/2, size(cb,2), size(cb,3)); | ||
odd = 1:2:size(cb,1); | ||
even = odd + 1; | ||
frame(:,1,:) = cb(odd,1,:); | ||
frame(:,2,:) = cb(even,2,:); | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
function cb = NPframe2checkerboard(frame) | ||
% NPFRAME2CHECKERBOARD - convert raw Neuropixels Phase 3 to geometrically realistic matrix | ||
% | ||
% CB = NPframe2checkerboard(FRAME) | ||
% | ||
% Convert Neuropixels data frame data FRAME (192 x 2 x NSAMPLES) | ||
% into a geometrically-realistic matrix that reflects the checkerboad | ||
% layout of electrodes such as the Phase 3 version. | ||
% | ||
% CB will be a 384 x 2 x NSAMPLES matrix where every even linear index | ||
% will be 0. | ||
% | ||
% For example, the following single-frame example input where each data point has | ||
% been set, for illustration purposes, to the electrode number (incremented by 0.5) | ||
% would be transformed as follows: | ||
% | ||
% 1.0000 1.5000 | ||
% 2.0000 2.5000 | ||
% 3.0000 3.5000 | ||
% ... | ||
% 189.0000 189.5000 | ||
% 190.0000 190.5000 | ||
% 191.0000 191.5000 | ||
% | ||
% to | ||
% | ||
% 1.0000 0 | ||
% 0 1.5000 | ||
% 2.0000 0 | ||
% 0 2.5000 | ||
% 3.0000 0 | ||
% 0 3.5000 | ||
%... | ||
% 190.0000 0 | ||
% 0 190.5000 | ||
% 191.0000 0 | ||
% 0 191.5000 | ||
% 192.0000 0 | ||
% 0 192.5000 | ||
|
||
cb = zeros(size(frame,1)*2,size(frame,2),size(frame,3)); | ||
|
||
odd = 1:2:size(frame,1)*2; | ||
even = odd + 1; | ||
|
||
cb(odd,1,:) = frame(:,1,:); | ||
cb(even,2,:) = frame(:,2,:); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters