-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnwbSessionParams.m
136 lines (128 loc) · 6.84 KB
/
nwbSessionParams.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
% Session-specific NWB parameters
% Parameters that are different for different animals are:
% sessionID
% sessionDescription
% sessionNotes
% areas
% endCh
% probeInserted
% electrodeName
% nChannelsPerShank
% electrodeCoordinates
% electrodeImplantationType
% General info
sessionID = {'20200324161349'};
sessionDescription = {'anaesthesia'};
sessionNotes = {'Probe 1: X Y Z D 1064.7 0 3992.4 4113.9. Probe 2: X Y Z D 1061.7 0 3918.7 4113.9. Anaesthesia recording with 0.5% isoflurane, heater set to 43 degrees, and the temperature probe showing 37.8 degrees. Increased isoflurane to 0.75% at minute 21.'};
endCh{1}{1} = [88 117 149 342 384]; % Corresponding probe end channels starting from the tip of the probe. Corresponding and previous end channels are used to work out probe channels that reside in the corresponding brain area.
endCh{1}{2} = [41 091 138 217 304 384];
for iSess = 1:numel(sessionID)
sessionStartTime{iSess} = datetime(str2double(sessionID{iSess}(1:4)), str2double(sessionID{iSess}(5:6)), str2double(sessionID{iSess}(7:8)),...
str2double(sessionID{iSess}(9:10)), str2double(sessionID{iSess}(11:12)), str2double(sessionID{iSess}(13:14))); %#ok<*SAGROW>
% Probe #1 info
ref = 1; % probe reference
probeInserted{iSess}{ref} = true; % If the probe used at all
if probeInserted{iSess}{ref} && ~isempty(endCh{iSess}{ref})
electrodeName{iSess}{ref} = 'Neuropixels 1.0';
electrodeDescription{iSess}{ref} = ['Single shank high density probe in position ' num2str(ref)];
electrodeManufacturer{iSess}{ref} = 'imec';
electrodeFolder{iSess}{ref} = [animalRawDataFolder filesep sessionID{iSess} '1'];
if ~exist(electrodeFolder{iSess}{ref}, 'file') % in case a probe is missing
electrodeFolder{iSess}{ref} = electrodeFolder{iSess}{ref}(1:end-1);
end
if contains(electrodeName{iSess}{ref}, 'neuropixels', 'IgnoreCase',true)
electrodeMap = [electrodeFolder{iSess}{ref} filesep 'forPRB_Neuropixels.mat'];
else
electrodeMap = [electrodeFolder{iSess}{ref} filesep 'forPRB_' electrodeName{iSess}{ref} '.mat'];
end
load(electrodeMap, 'ycoords');
nShanks{iSess}{ref} = 1;
nChannelsPerShank{iSess}{ref} = 384;
nChannelsPerShank{iSess}{ref} = min([numel(ycoords) nChannelsPerShank{iSess}{ref}]);
nCh{iSess}{ref} = nChannelsPerShank{iSess}{ref}*nShanks{iSess}{ref}; % total number of probe channels
areas = {'VB','LP','LGN','CA3','S1'}; % brain areas that this probe spans
electrodeLocation{iSess}{ref} = electrodeLocations(areas, endCh{iSess}{ref}, nCh{iSess}{ref}); % Brain area assigned to each recording channel.
electrodeCoordinates{iSess}{ref} = [-1.8, -2.5, 0]; % Electrode insertion location on the cortical surface in Paxinos coords: AP (posterior negative), ML (left negative), DV (recording site position starting with the tip of the probe.
electrodeCoordinates{iSess}{ref} = repmat(electrodeCoordinates{iSess}{ref}, nCh{iSess}{ref}, 1); % Coordinates of each probe recording channel (the probe rotation angle is not taken into account). Y coordinates are relative to the tip of the probe.
if size(ycoords,1) == 1
electrodeCoordinates{iSess}{ref}(:,3) = ycoords(1:nCh{iSess}{ref})'./1000;
else
electrodeCoordinates{iSess}{ref}(:,3) = ycoords(1:nCh{iSess}{ref})./1000;
end
electrodeLabel{iSess}{ref} = ['probe' num2str(ref)];
electrodeImplantationType{iSess}{ref} = 'acute';
else % The case when the probe #1 is missing
electrodeName{iSess}{ref} = []; %#ok<*UNRCH>
electrodeDescription{iSess}{ref} = [];
electrodeManufacturer{iSess}{ref} = [];
electrodeFolder{iSess}{ref} = [];
nShanks{iSess}{ref} = [];
nChannelsPerShank{iSess}{ref} = [];
nCh{iSess}{ref} = [];
electrodeLocation{iSess}{ref} = [];
electrodeCoordinates{iSess}{ref} = [];
electrodeLabel{iSess}{ref} = [];
electrodeImplantationType{iSess}{ref} = [];
end
% Probe #2 info
ref = 2;
probeInserted{iSess}{ref} = true;
if probeInserted{iSess}{ref} && ~isempty(endCh{iSess}{ref})
electrodeName{iSess}{ref} = 'Neuropixels 1.0';
electrodeDescription{iSess}{ref} = ['Single shank high density probe in position ' num2str(ref)];
electrodeManufacturer{iSess}{ref} = 'imec';
electrodeFolder{iSess}{ref} = [animalRawDataFolder filesep sessionID{iSess} '26'];
if ~exist(electrodeFolder{iSess}{ref},'file') || numel(dir(electrodeFolder{iSess}{ref})) <= 2 % in case the raw data folder name is shorter
electrodeFolder{iSess}{ref} = electrodeFolder{iSess}{ref}(1:end-1);
end
if ~exist(electrodeFolder{iSess}{ref}, 'file') % in case a probe is missing
electrodeFolder{iSess}{ref} = electrodeFolder{iSess}{ref}(1:end-1);
end
if strcmpi(electrodeFolder{iSess}{1}, electrodeFolder{iSess}{2})
probeInserted{iSess}{ref} = false;
continue
end
if contains(electrodeName{iSess}{ref}, 'neuropixels', 'IgnoreCase',true)
electrodeMap = [electrodeFolder{iSess}{ref} filesep 'forPRB_Neuropixels.mat'];
else
electrodeMap = [electrodeFolder{iSess}{ref} filesep 'forPRB_' electrodeName{iSess}{ref} '.mat'];
end
load(electrodeMap, 'ycoords');
nShanks{iSess}{ref} = 1;
nChannelsPerShank{iSess}{ref} = 384;
nChannelsPerShank{iSess}{ref} = min([numel(ycoords) nChannelsPerShank{iSess}{ref}]);
nCh{iSess}{ref} = nChannelsPerShank{iSess}{ref}*nShanks{iSess}{ref};
areas = {'VB','Po','LP','DG','CA1','RSC'};
electrodeLocation{iSess}{ref} = electrodeLocations(areas, endCh{iSess}{ref}, nCh{iSess}{ref});
electrodeCoordinates{iSess}{ref} = [-1.8, -0.5, 0];
electrodeCoordinates{iSess}{ref} = repmat(electrodeCoordinates{iSess}{ref}, nCh{iSess}{ref}, 1);
if size(ycoords,1) == 1
electrodeCoordinates{iSess}{ref}(:,3) = ycoords(1:nCh{iSess}{ref})'./1000;
else
electrodeCoordinates{iSess}{ref}(:,3) = ycoords(1:nCh{iSess}{ref})./1000;
end
electrodeLabel{iSess}{ref} = ['probe' num2str(ref)];
electrodeImplantationType{iSess}{ref} = 'acute';
else % The case when the probe #2 is missing
electrodeName{iSess}{ref} = []; %#ok<*UNRCH>
electrodeDescription{iSess}{ref} = [];
electrodeManufacturer{iSess}{ref} = [];
electrodeFolder{iSess}{ref} = [];
nShanks{iSess}{ref} = [];
nChannelsPerShank{iSess}{ref} = [];
nCh{iSess}{ref} = [];
electrodeLocation{iSess}{ref} = [];
electrodeCoordinates{iSess}{ref} = [];
electrodeLabel{iSess}{ref} = [];
electrodeImplantationType{iSess}{ref} = [];
end
end
%% Local functions
function electrodeLocationVec = electrodeLocations(areas, endCh, nCh)
% electrodeLocationVec = electrodeLocations(areas, endCh, nCh)
% Function assigns brain area to a channel
for iCh = 1:nCh
areaInd = find(endCh >= iCh,1);
electrodeLocationVec{iCh} = areas{areaInd};
end
end