필터 지우기
필터 지우기

Dynamic Table for .nwb

조회 수: 2 (최근 30일)
siri meka
siri meka 2024년 3월 4일
답변: Zinea 2024년 4월 8일
I have a dynamic table. the "location" column should pull data from another file "fields" and return the values. I have attached the code. Please help
'label', sprintf(fields)); --- I have tried this and left it as "fields"
numShanks = 1;
numChannelsPerShank = 8;
ElectrodesDynamicTable = types.hdmf_common.DynamicTable(...
'colnames', {'location', 'label'}, ...
'description', 'all electrodes');
Device = types.core.Device(...
'NeuroOmega', 'NeuroOmega', ...
'Alpha Omega', 'Alpha Omega' ...
);
nwb.general_devices.set('array', Device);
for iShank = 1:numShanks
shankGroupName = sprintf('shank%d', iShank);
EGroup = types.core.ElectrodeGroup( ...
'description', sprintf('electrode group for %s', shankGroupName), ...
'location', 'GPi', ...
'device', types.untyped.SoftLink(Device) ...
);
nwb.general_extracellular_ephys.set(shankGroupName, EGroup);
for iElectrode = 1:numChannelsPerShank
ElectrodesDynamicTable.addRow( ...
'location', 'GPi', ...
'label', sprintf(fields));
end
end
ElectrodesDynamicTable.toTable()
nwb.general_extracellular_ephys_electrodes = ElectrodesDynamicTable;

답변 (1개)

Zinea
Zinea 2024년 4월 8일
Hi Siri,
I gather from the code snippet that you are trying to pull the ‘label’ values from ‘fields.mat’ and use it in ‘ElectrodesDynamicTable’.
Here is the code for doing the same:
numShanks = 1;
numChannelsPerShank = 8;
% Assuming 'fields' is stored in a file named 'fields.mat' and is a cell array
% Load 'fields' from the file
load('fields.mat', 'fields'); % Make sure 'fields' is the correct variable name in your .mat file
ElectrodesDynamicTable = types.hdmf_common.DynamicTable(...
'colnames', {'location', 'label'}, ...
'description', 'all electrodes');
Device = types.core.Device(...
'NeuroOmega', 'NeuroOmega', ...
'Alpha Omega', 'Alpha Omega' ...
);
nwb.general_devices.set('array', Device);
for iShank = 1:numShanks
shankGroupName = sprintf('shank%d', iShank);
EGroup = types.core.ElectrodeGroup( ...
'description', sprintf('electrode group for %s', shankGroupName), ...
'location', 'GPi', ...
'device', types.untyped.SoftLink(Device) ...
);
nwb.general_extracellular_ephys.set(shankGroupName, EGroup);
for iElectrode = 1:numChannelsPerShank
% Ensure 'fields' has enough entries for each electrode
if iElectrode <= length(fields)
label = fields{iElectrode}; % Access the corresponding label from 'fields'
else
label = sprintf('Electrode%d', iElectrode); % Fallback label if 'fields' is shorter than expected
end
ElectrodesDynamicTable.addRow( ...
'location', 'GPi', ...
'label', label);
end
end
ElectrodesDynamicTable.toTable()
nwb.general_extracellular_ephys_electrodes = ElectrodesDynamicTable;
Here is the output of executing the above code :
For more information on working with NWB Data, refer to the following link:
Hope it helps!

카테고리

Help CenterFile Exchange에서 Geographic Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by