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 Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by