Skip to content

Instantly share code, notes, and snippets.

@alisterburt
Created October 7, 2020 14:01
Show Gist options
  • Save alisterburt/56568ee9243dd1918ed7af1dcdfda059 to your computer and use it in GitHub Desktop.
Save alisterburt/56568ee9243dd1918ed7af1dcdfda059 to your computer and use it in GitHub Desktop.
dynamo vll file to table and table map
function table = vll2table(vll_file)
%%% Convert a vll file into a table and corresponding tomogram table-map file
% Read volume list file
volume_list = ptdb.volumelisttext2object(vll_file).volumes;
% Prepare output filenames
table_file_name = strrep(vll_file, '.vll', '.tbl');
table_map_file_name = strrep(vll_file, '.vll', '_tablemap.doc');
% Prepare array to store tables from each model
tables = [];
% Prepare cell array to store index and volume file
table_map = {};
% Iterate over volumes, extracting tables from associated models
for vol_idx = 1:size(volume_list, 2)
% Get file names
current_volume_struct = volume_list{1, vol_idx};
current_volume_file = current_volume_struct.file;
model_file = current_volume_struct.crop_geometry{1}.file;
% Extract table from model
model = dread(model_file);
table = model.grepTable();
table(:, 20) = vol_idx;
% append table to cell array of tables
tables = cat(1, tables, table);
% append table map info
table_map{end+1} = vol_idx;
table_map{end+1} = current_volume_file;
end
% Write out table and table map file
dwrite(tables, table_file_name);
f_id = fopen('tmp.txt', 'w');
for idx = 1:2:size(table_map, 2)
fprintf(f_id,'%d %s\n',table_map{1, idx}, table_map{1, idx+1})
end
fclose(f_id)
movefile('tmp.txt', table_map_file_name, 'f')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment