
Dynamic Table for .nwb
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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;
0 commentaires
Réponses (1)
Zinea
le 8 Avr 2024
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!
0 commentaires
Voir également
Catégories
En savoir plus sur Call Python from MATLAB dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!