Skip to content

Commit

Permalink
Add spacing and comments to files
Browse files Browse the repository at this point in the history
  • Loading branch information
tsipkens committed Sep 22, 2023
1 parent fdacb9e commit d1f92bd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion +tools/convert2grid.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
% Author: Timothy Sipkens, 2020-07-16
%=========================================================================%

function [grid,idx] = convert2grid(sp_m, d_star)
function [grid,idx] = convert2grid(sp_m, d_star, b)

% adjust mass setpoint
if isstruct(sp_m); m_star = [sp_m.m_star] .* 1e18; % if setpoint structure
Expand Down
15 changes: 10 additions & 5 deletions +tools/fit_mm_median.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,20 @@
%-- Fit normal distribution to data in log(d) space --------%
opts = optimset('Display','none');
for bb=length(grid_b.edges{1}):-1:1
fun0 = @(x) x(1).*normpdf(log10(grid_b.edges{2}),x(2),x(3));
x0 = [max(b_plot_rs(bb,:))/5,log10(d_med(bb)),0.1];
% Function to fit, normal in log-space.
fun0 = @(x) x(1) .* normpdf(log10(grid_b.edges{2}),x(2),x(3));

% Initialize x0, using max. in scan.
x0 = [max(b_plot_rs(bb,:))/5 , log10(d_med(bb)), 0.1];

% Fitting procedure.
[x2(bb,:),~,~,~,~,~,jacob] = ...
lsqnonlin(@(x) (fun0(x)-b_plot_rs(bb,:)).^2,x0,[],[],opts);
lsqnonlin(@(x) (fun0(x) - b_plot_rs(bb,:)).^2, x0, [], [], opts);

t0 = inv(jacob'*jacob);
t0 = inv(jacob' * jacob); % use jacobian to get uncertainties
sx2(bb,1) = sqrt(t0(2,2)); % error in median, used to weight other analysis
end
d_med = 10.^x2(:,2);
d_med = 10 .^ x2(:,2);


%-- Linear regression on median/mode diameter --------------%
Expand Down
5 changes: 2 additions & 3 deletions +tools/overlay_phantom.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
function [pha, N, ci] = overlay_phantom(x_pha,grid,iso_levels,varargin)

%-- Parse inputs ---------------------------------------------------------%
if isa(x_pha,'Phantom')
if isa(x_pha, 'Phantom')
pha = x_pha;
grid = pha.grid;
N = [];
else
[pha, N, ~, ci] = Phantom.fit(x_pha, grid);
end

if ~exist('iso_levels','var'); iso_levels = []; end
if isempty(iso_levels); iso_levels = [1,2,3]; end % plot 1, 2, and 3 sigma
if ~exist('iso_levels', 'var'); iso_levels = [1,2,3]; end % plot 1, 2, and 3 sigma

if isempty(varargin); varargin = {'Color',[1,1,0,1]}; end
% specify line properties (default: yellow, no transparency)
Expand Down
2 changes: 1 addition & 1 deletion @Phantom/Phantom.m
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@

%-- OPTION 2: Using a mass-mobility parameter set (p) ----%
case {'mass-mobility'} % for custom mass-mobility phantom
% sepcified using a p structure
% specified using a p structure
obj.type = 'mass-mobility';
obj.modes = Sigma_modes;
obj.p = obj.fill_p(mu_p); % fill out p structure
Expand Down

0 comments on commit d1f92bd

Please sign in to comment.