Created
October 1, 2020 14:36
-
-
Save alisterburt/818c604af41050532a378afb93ae556f to your computer and use it in GitHub Desktop.
convert dynamo dipoleSet models into oversampled vesicle models
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dipoles2vesicles(catalogue_name, distance_between_particles) | |
%%% to be run in the folder which holds your catalogue | |
%%% | |
%%% catalogue name - name of catalogue containing your dipoleSet models | |
%%% distance_between_particles - expected distance between particles in px | |
%%% (output points will be oversampled relative to this value) | |
%%% | |
%%% if you want to restart - !rm */*/*/*/*rawVesicle*.omd | |
p = [catalogue_name,'/tomograms/*/models/*.omd']; | |
model_files = dir(p); | |
for model_idx = 1:length(model_files) | |
current_file = model_files(model_idx) | |
model_file = fullfile(current_file.folder, current_file.name) | |
fprintf('Now reading %s\n', model_file); | |
vesicles_from_dipoles(model_file, distance_between_particles) | |
end | |
end | |
function vesicles_from_dipoles(model_file, expected_inter_particle_distance) | |
ds = dread(model_file); | |
% checks the number of individual dipoles | |
disp(sprintf('Found %d dipoles in the set',length(ds.dipoles))); | |
% loops on all the dipoles present in the set | |
for i=1:length(ds.dipoles); | |
% selects the i-th individual dipole in the set | |
dipole = ds.dipoles{i}; | |
% creates a vesicle model | |
v = dmodels.vesicle(); | |
% prepares a name for each individual dipole | |
v.name = sprintf('%s_rawVesicle_%d',ds.name,i); | |
% links the created model with the catalogued volume | |
% of the dipole set module | |
v.cvolume = ds.cvolume; | |
% initiates the vesicle model | |
v.center = dipole.center; | |
v.radius = norm(dipole.center - dipole.north); | |
% add in info about average distance between particle positions on | |
% surface | |
v.separation = expected_inter_particle_distance / 1.5; | |
v.updateCrop(); | |
% saves the model back into the catalogue | |
v.saveInCatalogue(); | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment